babel-plugin-source-map-support

raw JSON →
2.2.0 verified Sat Apr 25 auth: no javascript

A Babel plugin (v2.2.0) that automatically prepends `import 'source-map-support/register'` to every transpiled file, enabling source-map-aware stack traces in v8 environments (Node.js, Chrome). It requires the separate `source-map-support` runtime dependency (v0.5+). Unlike manual registration or other plugins, it works with all Babel 7 presets and can be scoped to development builds via the `env` option. Stable, low maintenance, no known breaking changes since v1.

error Error: Cannot find module 'source-map-support/register'
cause source-map-support package not installed or not in node_modules
fix
Run: npm install --save source-map-support
error Babel 6 is not supported
cause Plugin requires Babel 7+; earlier versions not compatible
fix
Upgrade Babel to version 7 or later, or use an older version of the plugin (not recommended).
error Stack traces still show transpiled line numbers
cause Source maps not generated or not loaded; plugin only adds registration, source maps must be generated separately
fix
Enable source maps in Babel config: 'sourceMaps: true' or 'sourceMaps: "inline"'
gotcha Requires source-map-support package to be installed separately as a runtime dependency
fix Run: npm install --save source-map-support
gotcha Only works in environments with v8 stack trace API (Node.js, Chrome). Harmless in others but no effect.
fix Do not use for browser production builds; scope to development only via Babel 'env' option.
npm install babel-plugin-source-map-support
yarn add babel-plugin-source-map-support
pnpm add babel-plugin-source-map-support

Install plugin and runtime, configure in Babel, compile a file to see automatic source map support registration.

// Install: npm install --save-dev babel-plugin-source-map-support source-map-support
// .babelrc
{
  "plugins": ["source-map-support"],
  "sourceMaps": "inline"
}

// Input: test.js
import foo from 'foo';
foo();

// Compile: npx babel test.js --out-file test-compiled.js
// Output: test-compiled.js will have import 'source-map-support/register' prepended