Replace source-map-support with process.setSourceMapsEnabled()
ProprietaryReplaces 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.
org. openrewrite. node. migrate. source-map-support. replace-source-map-support-installOptional
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.
mod run . --recipe= org. openrewrite. node. migrate. source-map-support. replace-source-map-support-installInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.