Rolldown plugin for grabbing source maps from sourceMappingURLs
npm install rolldown-plugin-sourcemaps

!Build Status
Rolldown plugin for loading files with existing source maps from sourceMappingURL comments.
- You consume external modules (from node_modules) with bundled source maps
- You want accurate stack traces pointing to original source code
- You need to chain source maps from pre-compiled dependencies
``bash`
npm install rolldown-plugin-sourcemaps --save-devor
pnpm add rolldown-plugin-sourcemaps -D
`javascript
import sourcemaps from 'rolldown-plugin-sourcemaps';
import { defineConfig } from 'vite';
export default defineConfig({
build: {
sourcemap: true,
rollupOptions: {
plugins: [sourcemaps()]
}
}
});
`
`javascript
import sourcemaps from 'rolldown-plugin-sourcemaps';
export default {
input: 'src/index.js',
plugins: [sourcemaps()],
output: {
sourcemap: true,
file: 'dist/bundle.js',
},
};
`
Type: string | RegExp | (string | RegExp)[]
Default: /[/\\]node_modules[/\\]/ (only processes files in node_modules)
Files to include for source map processing. By default, only files in node_modules are processed since that's where pre-compiled source maps typically exist.
`javascript
// Process all files
sourcemaps({ include: /./ })
// Only process specific packages
sourcemaps({ include: /[/\\]node_modules[/\\]@myorg[/\\]/ })
`
Type: string | RegExp | (string | RegExp)[]
Default: undefined
Files to exclude from source map processing.
`javascript`
// Exclude specific packages
sourcemaps({ exclude: /[/\\]node_modules[/\\]some-large-package[/\\]/ })
This plugin is optimized for performance:
- Targeted processing: Only processes node_modules by default (where pre-compiled source maps exist)sourcesContent` already exists
- Fast detection: Uses simple string matching before regex parsing
- Parallel I/O: Resolves multiple source files in parallel
- Early termination: Skips unnecessary work when
MIT
This project is a fork and modernization for Rolldown of the original work by:
- Max Davidson - Creator of rollup-plugin-sourcemaps
- Kudakwashe Mupeni - Maintainer of rollup-plugin-sourcemaps2
Inspired by webpack/source-map-loader.