{"id":22228,"library":"rollup-plugin-sourcemaps2","title":"rollup-plugin-sourcemaps2","description":"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.","status":"active","version":"0.5.6","language":"javascript","source_language":"en","source_url":"https://github.com/2wce/rollup-plugin-sourcemaps2","tags":["javascript","rollup","rollup-plugin","sourcemap","source-map","sourceMappingURL","typescript"],"install":[{"cmd":"npm install rollup-plugin-sourcemaps2","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-sourcemaps2","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-sourcemaps2","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required as a Rollup plugin","package":"rollup","optional":false},{"reason":"Peer dependency for TypeScript type definitions","package":"@types/node","optional":true}],"imports":[{"note":"Since Rollup plugins are ESM-only, use import syntax. CommonJS require works in some environments but may fail.","wrong":"const sourcemaps = require('rollup-plugin-sourcemaps2')","symbol":"sourcemaps","correct":"import sourcemaps from 'rollup-plugin-sourcemaps2'"},{"note":"The package exports a default function; named import will not work.","wrong":"import { sourcemaps } from 'rollup-plugin-sourcemaps2'","symbol":"default","correct":"import sourcemaps from 'rollup-plugin-sourcemaps2'"},{"note":"TypeScript types are exported under the main entry. For options interface, use type import to avoid runtime issues.","wrong":"import { Options } from 'rollup-plugin-sourcemaps2'","symbol":"rollup-plugin-sourcemaps2/types","correct":"import type { Options } from 'rollup-plugin-sourcemaps2'"}],"quickstart":{"code":"import sourcemaps from 'rollup-plugin-sourcemaps2';\nimport babel from '@rollup/plugin-babel';\nimport { defineConfig } from 'rollup';\n\nexport default defineConfig({\n  input: 'src/index.js',\n  plugins: [\n    babel({ babelHelpers: 'bundled', inputSourceMap: false }),\n    sourcemaps({\n      // include/exclude patterns (optional)\n      exclude: /node_modules/,\n      filter: (file) => file.endsWith('.js')\n    })\n  ],\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm',\n    sourcemap: true\n  }\n});","lang":"typescript","description":"Shows setup with rollup-plugin-babel where inputSourceMap is disabled to avoid conflicts, and sourcemaps plugin loads existing maps."},"warnings":[{"fix":"Upgrade Rollup to v4 or later: npm install rollup@4","message":"Rollup 4 required: v0.5.0 dropped support for Rollup <4. Ensure your build uses Rollup 4.x.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Upgrade Node.js to v18 or later.","message":"Node 18 required: Package engine requires Node >=18.0.0.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Replace rollup-plugin-sourcemaps with rollup-plugin-sourcemaps2 in package.json and imports.","message":"The original rollup-plugin-sourcemaps is abandoned. Migrate to this fork.","severity":"deprecated","affected_versions":"*"},{"fix":"Set babel({ inputSourceMap: false }) in your Rollup config.","message":"Babel inputSourceMap conflict: Using this plugin together with @rollup/plugin-babel without setting inputSourceMap to false may cause duplicate/incorrect source maps.","severity":"gotcha","affected_versions":"*"},{"fix":"If you need the old behavior, pin to v0.4.x or update your source maps to have only one mapping URL.","message":"Multiple 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.","severity":"gotcha","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure the source map file exists at the referenced location, or use filter/include/exclude options to skip that file.","cause":"The sourceMappingURL points to a relative path that does not exist or is inaccessible.","error":"Error: Could not resolve source map for 'xxx.js' (sourcemap not found)"},{"fix":"Use import sourcemaps from 'rollup-plugin-sourcemaps2' (default import).","cause":"Using wrong import (e.g., destructuring a named export instead of default import).","error":"TypeError: sourcemaps is not a function"},{"fix":"Set output.sourcemap: true or output.sourcemap: 'inline' as needed.","cause":"While this plugin works with boolean sourcemap: true, some Rollup versions expect an object for advanced settings. Rare but possible.","error":"Error: The 'sourceMap' option for Rollup must be an object, not a boolean (when using output.sourcemap: true)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}