← All recipes
Moderne licensed

Enable native source maps at launch and drop source-map-support

Recipe IDorg.openrewrite.node.migrate.source-map-support.enable-source-maps-at-launchArtifact@openrewrite/recipes-nodejs

Where source-map-support is installed too late for process.setSourceMapsEnabled(true) to stand in for it — in an ES module, every import is evaluated before any statement runs, so the call would only map what loads after it — this puts --enable-source-maps on whatever launches the process instead, which Node applies before the first module loads. The flag goes into the package's bin shebang (as #!/usr/bin/env -S node --enable-source-maps) and into any package.json script that runs node or mocha directly. The install() call and register import are then redundant and are removed, rather than replaced by a call that would map less. A package with no launcher this recipe can reach is left alone and reported by FindSourceMapSupportManualMigrations.

Single recipesource-map-supportProprietary

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.enable-source-maps-at-launch

If the recipe isn’t available locally, install it with:

mod config recipes npm install @openrewrite/recipes-nodejs