Registry / devops / rollup-plugin-sourcemaps2

rollup-plugin-sourcemaps2

JSON →
library0.5.6jsnpmunverified

Rollup plugin that loads existing source maps from sourceMappingURL comments in files, enabling proper source map chaining when input files already contain source maps (e.g., after transpilation with Babel, TypeScript, or ESBuild). Current stable version is 0.5.6, with monthly patch releases and a major update to Rollup 4 in v0.5.0. Key differentiators: actively maintained fork of the abandoned rollup-plugin-sourcemaps, supports both async and sync loading, handles multiple sourceMappingURLs, and encodes non-ASCII characters correctly. Requires Rollup >=4 and Node >=18.

npm install rollup-plugin-sourcemaps2
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-SOUR
R
rollup-plugin-sourcemaps2
devopsjavascriptv0.5.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sourcemaps
import sourcemaps from 'rollup-plugin-sourcemaps2'
const sourcemaps = require('rollup-plugin-sourcemaps2')
Since Rollup plugins are ESM-only, use import syntax. CommonJS require works in some environments but may fail.
default
import sourcemaps from 'rollup-plugin-sourcemaps2'
import { sourcemaps } from 'rollup-plugin-sourcemaps2'
The package exports a default function; named import will not work.
rollup-plugin-sourcemaps2/types
import type { Options } from 'rollup-plugin-sourcemaps2'
import { Options } from 'rollup-plugin-sourcemaps2'
TypeScript types are exported under the main entry. For options interface, use type import to avoid runtime issues.

Shows setup with rollup-plugin-babel where inputSourceMap is disabled to avoid conflicts, and sourcemaps plugin loads existing maps.

import sourcemaps from 'rollup-plugin-sourcemaps2'; import babel from '@rollup/plugin-babel'; import { defineConfig } from 'rollup'; export default defineConfig({ input: 'src/index.js', plugins: [ babel({ babelHelpers: 'bundled', inputSourceMap: false }), sourcemaps({ // include/exclude patterns (optional) exclude: /node_modules/, filter: (file) => file.endsWith('.js') }) ], output: { file: 'dist/bundle.js', format: 'esm', sourcemap: true } });
Debug
Known issues
breakingRollup 4 required: v0.5.0 dropped support for Rollup <4. Ensure your build uses Rollup 4.x.
fix
Upgrade Rollup to v4 or later: npm install rollup@4
affects: >=0.5.0
breakingNode 18 required: Package engine requires Node >=18.0.0.
fix
Upgrade Node.js to v18 or later.
affects: >=0.5.0
deprecatedThe original rollup-plugin-sourcemaps is abandoned. Migrate to this fork.
fix
Replace rollup-plugin-sourcemaps with rollup-plugin-sourcemaps2 in package.json and imports.
affects: *
gotchaBabel inputSourceMap conflict: Using this plugin together with @rollup/plugin-babel without setting inputSourceMap to false may cause duplicate/incorrect source maps.
fix
Set babel({ inputSourceMap: false }) in your Rollup config.
affects: *
gotchaMultiple sourceMappingURLs: Prior to v0.5.0, the plugin resolved only the first source mapping URL. In v0.5.0+, it resolves the last URL, which may break builds relying on old behavior.
fix
If you need the old behavior, pin to v0.4.x or update your source maps to have only one mapping URL.
affects: >=0.5.0
Errors
Common errors & fixes
Error: Could not resolve source map for 'xxx.js' (sourcemap not found)
The sourceMappingURL points to a relative path that does not exist or is inaccessible.
fix
Ensure the source map file exists at the referenced location, or use filter/include/exclude options to skip that file.
TypeError: sourcemaps is not a function
Using wrong import (e.g., destructuring a named export instead of default import).
fix
Use import sourcemaps from 'rollup-plugin-sourcemaps2' (default import).
Error: The 'sourceMap' option for Rollup must be an object, not a boolean (when using output.sourcemap: true)
While this plugin works with boolean sourcemap: true, some Rollup versions expect an object for advanced settings. Rare but possible.
fix
Set output.sourcemap: true or output.sourcemap: 'inline' as needed.
Upgrade
Version history
0.5.6latest on npm
Audit
Dependencies
rolluprequiredPeer dependency required as a Rollup plugin
@types/nodeoptionalPeer dependency for TypeScript type definitions
Agent activity
6 hits · last 30 days
node
6
Resources
rollup-plugin-sourcemaps2 — npm install rollup-plugin-sourcemaps2 · libregistry