Skip to main content
Moderne OnlyThis recipe is proprietary to Moderne and runs on the Moderne platform or CLI — it isn’t part of the open-source catalog. Available with a Moderne subscription.Contact Sales

Replace source-map-support with process.setSourceMapsEnabled()

Recipe IDorg.openrewrite.node.migrate.source-map-support.replace-source-map-support-install
Artifact@openrewrite/recipes-nodejs

Replaces require('source-map-support').install(), import 'source-map-support/register' and their variants with Node's native process.setSourceMapsEnabled(true) (Node.js 16.6+). Calls passing options Node has no equivalent for (retrieveSourceMap, retrieveFile, environment: 'browser', ...) are left to ReplaceSourceMapSupportApi. Native source maps only apply to modules loaded after they are enabled, where source-map-support maps every stack frame, so by default a call is only replaced where no other module is loaded before it: no other runtime import in the file, and no earlier require. Elsewhere, launch Node with --enable-source-maps, which ReplaceSourceMapSupportRegisterInPackageJson sets in package.json scripts.

Single recipeOpenRewritesource-map-supportModerne Proprietary License
Try in PlatformTry this recipe in the Moderne platform. Not a user yet? You’ll get a no-setup demo environment, with nothing to install or configure.

Options​

1 parameters
1 optional
ParameterExampleTypeRequired
allowPartialMapping—StringOptional
Also replace calls made after other modules are loaded, such as in an ES module with static imports. Stack frames in the modules loaded first are then no longer source-mapped.

Usage​

Run this recipe

In order to run JavaScript recipes, you will need to use the Moderne CLI. For JavaScript specific configuration instructions, please see our configuring JavaScript guide.

Once the CLI is installed, you can install this JavaScript recipe package by running the following command:

Install the recipe package
mod config recipes npm install @openrewrite/recipes-nodejs

Then, you can run the recipe via:

Run the recipe
mod run . --recipe org.openrewrite.node.migrate.source-map-support.replace-source-map-support-install