rollup-plugin-include-sourcemaps

raw JSON →
0.7.0 verified Mon Apr 27 auth: no javascript

Rollup plugin (v0.7.0) that loads existing source maps from sourceMappingURL comments in transpiled files. Designed for workflows where files are pre-transpiled (e.g., with Babel or TypeScript) before bundling, or when consuming external modules that include inline source maps. It automatically reads and attaches source maps so Rollup's output contains accurate mappings. Lightweight alternative to webpack's source-map-loader, with no extra configuration needed. Works with Rollup >=0.31.2 and Node >=10.0.0. Ships TypeScript declarations. Last updated 2021, stable release.

error Error: Cannot find module 'rollup-plugin-include-sourcemaps'
cause Missing npm install or wrong import path when using ESM.
fix
Run npm install rollup-plugin-include-sourcemaps and ensure the import statement uses default import (no curly braces).
error TypeError: sourcemaps is not a function
cause Named import used instead of default import.
fix
Change to import sourcemaps from 'rollup-plugin-include-sourcemaps'.
error Source map not found for file: ...
cause Plugin cannot find sourceMappingURL comment or the .map file is missing/not adjacent.
fix
Ensure the input file has a valid sourceMappingURL comment (inline or reference) and the source map file exists adjacent to the source.
gotcha Plugin must be placed before other plugins that transform code (e.g., babel) to ensure source maps from pre-transpiled files are captured.
fix Order plugins: sourcemaps() first, then other transforms.
gotcha Output must have sourcemap: true for the plugin's work to be reflected in the final bundle source map.
fix Set output.sourcemap to true or 'inline'.
deprecated This plugin is no longer actively maintained; consider using Rollup's built-in source map handling or a maintained alternative.
fix Use Rollup's output.sourcemap or plugins like @rollup/plugin-sourcemaps if needed.
breaking Version 0.6.0 changed options interface; old 'exclude' option was renamed to 'excludeFile' and 'include' to 'includeFile'.
fix Use 'includeFile' and 'excludeFile' instead of 'include' and 'exclude'.
npm install rollup-plugin-include-sourcemaps
yarn add rollup-plugin-include-sourcemaps
pnpm add rollup-plugin-include-sourcemaps

Shows minimal Rollup config using the plugin to include existing source maps from transpiled input files.

import sourcemaps from 'rollup-plugin-include-sourcemaps';

export default {
  input: 'src/index.js',
  plugins: [sourcemaps()],
  output: {
    sourcemap: true,
    file: 'dist/bundle.js',
  },
};