What is rollup-plugin-sourcemaps?
The rollup-plugin-sourcemaps package is a Rollup plugin that allows you to include existing source maps in your build process. This is particularly useful when you are working with libraries that already have source maps, and you want to preserve them in your final bundle.
What are rollup-plugin-sourcemaps's main functionalities?
Include existing source maps
This feature allows you to include existing source maps in your Rollup build. By using the sourcemaps() plugin, Rollup will read the source maps from your input files and include them in the final bundle.
{"plugins":["sourcemaps()"]}
Generate source maps for transformed code
This feature allows you to generate source maps for the transformed code. By setting the sourcemap option to true in the output configuration and using the sourcemaps() plugin, Rollup will generate source maps for the final bundle.
{"input":"src/main.js","output":{"file":"bundle.js","format":"cjs","sourcemap":true},"plugins":["sourcemaps()"]}
Other packages similar to rollup-plugin-sourcemaps
rollup-plugin-terser
The rollup-plugin-terser package is a Rollup plugin that minifies your code using Terser. While it does not directly handle source maps, it can work in conjunction with rollup-plugin-sourcemaps to minify code while preserving source maps.
rollup-plugin-babel
The rollup-plugin-babel package is a Rollup plugin that allows you to use Babel to transpile your code. It can generate source maps for the transformed code, similar to rollup-plugin-sourcemaps, but it focuses on code transformation rather than source map inclusion.
rollup-plugin-typescript2
The rollup-plugin-typescript2 package is a Rollup plugin that integrates TypeScript with Rollup. It can generate source maps for TypeScript code, similar to rollup-plugin-sourcemaps, but it is specifically designed for TypeScript projects.
rollup-plugin-sourcemaps
Rollup plugin for loading files with existing source maps.
Inspired by webpack/source-map-loader.
Works with rollup 0.31.2 or later.
If you use rollup-plugin-babel,
you might be able to use the inputSourceMap
option instead of this plugin.
Why?
- You transpile your files with source maps before bundling with rollup
- You consume external modules with bundled source maps
Usage
import sourcemaps from 'rollup-plugin-sourcemaps';
export default {
input: 'src/index.js',
plugins: [sourcemaps()],
output: {
sourcemap: true,
file: 'dist/my-awesome-package.js',
},
};