Migrate source-map-support to Node.js native source maps
org.openrewrite.node.migrate.source-map-support.migrate-source-map-support-to-nativeArtifact@openrewrite/recipes-nodejsReplaces the source-map-support package with Node.js's built-in source map support. Where Node is launched from package.json scripts or mocha/ava configuration, source-map-support/register becomes the --enable-source-maps flag; in code, install() and register imports become process.setSourceMapsEnabled(true). Uses with no native equivalent (custom retrieveSourceMap, browser bundles, webpack banners) are left in place, and the dependency is removed from each package.json that no longer needs it. Everything left in place is recorded in the SourceMapSupportManualMigrationSteps data table with a suggested replacement.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.node.migrate.source-map-support.migrate-source-map-support-to-nativeIf the recipe isn’t available locally, install it with:
mod config recipes npm install @openrewrite/recipes-nodejsDefinition
This recipe runs the following recipes in order.
- Replace
source-map-support/registerwith--enable-source-mapsinpackage.jsonorg.openrewrite.node.migrate.source-map-support.replace-source-map-support-register-in-package-json - Replace
source-map-support/registerwithenable-source-mapsin mocha configorg.openrewrite.node.migrate.source-map-support.replace-source-map-support-register-in-mocha-config - Replace
source-map-supportwithprocess.setSourceMapsEnabled()org.openrewrite.node.migrate.source-map-support.replace-source-map-support-install - Find source-map-support usages that need manual migration
org.openrewrite.node.migrate.source-map-support.find-source-map-support-manual-migrations - Remove unused
source-map-supportdependencyorg.openrewrite.node.migrate.source-map-support.remove-unused-source-map-support-dependency