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-sourcemaps2Verified import paths — ran on the pinned version, not inferred.
Shows setup with rollup-plugin-babel where inputSourceMap is disabled to avoid conflicts, and sourcemaps plugin loads existing maps.
Upgrade Rollup to v4 or later: npm install rollup@4
Upgrade Node.js to v18 or later.
Replace rollup-plugin-sourcemaps with rollup-plugin-sourcemaps2 in package.json and imports.
Set babel({ inputSourceMap: false }) in your Rollup config.If you need the old behavior, pin to v0.4.x or update your source maps to have only one mapping URL.
Ensure the source map file exists at the referenced location, or use filter/include/exclude options to skip that file.
Use import sourcemaps from 'rollup-plugin-sourcemaps2' (default import).
Set output.sourcemap: true or output.sourcemap: 'inline' as needed.