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 grabbing source maps from sourceMappingURLs.
Useful for working with precompiled modules with existing source maps, without resorting to sorcery.
Requires Rollup v0.31.2 or later.
Inspired by webpack/source-map-loader.
Usage
import sourcemaps from 'rollup-plugin-sourcemaps';
export default {
entry: 'src/index.js',
dest: 'dist/my-awesome-package.js',
sourceMap: true,
plugins: [
sourcemaps()
]
};