esbuild-plugin-exclude-vendor-from-source-map

raw JSON →
0.0.3 verified Fri May 01 auth: no javascript

An esbuild plugin that excludes node_modules from source maps to reduce source map size. Current stable version is 0.0.3. This plugin modifies the generated source map by removing entries from vendor (node_modules) paths, which can significantly reduce file size for bundled applications. Key differentiator: it's a lightweight esbuild-specific solution for source map trimming, similar in spirit to Webpack's hidden-source-map or exclude options.

error Cannot find module 'esbuild-plugin-exclude-vendor-from-source-map'
cause Package not installed or not in node_modules.
fix
Run 'npm i --save-dev esbuild-plugin-exclude-vendor-from-source-map'
error The requested module 'esbuild-plugin-exclude-vendor-from-source-map' does not provide an export named 'default'
cause Default import used incorrectly; plugin only has named export.
fix
Use named import: import { excludeVendorFromSourceMap } from 'esbuild-plugin-exclude-vendor-from-source-map'
gotcha The plugin only affects source maps, not the bundle output. Source map paths are rewritten but not removed.
fix Verify your source map by inspecting the output file. If vendor entries still appear, ensure the plugin is in the plugins array and that esbuild generates source maps (sourcemap: true).
gotcha Plugin version is 0.0.3; API may change. No TypeScript declarations included.
fix Consider pinning the version and using @ts-ignore or writing your own declaration file if using TypeScript.
gotcha Only works with esbuild's JavaScript API, not the CLI directly.
fix Use the JavaScript API as shown in the quickstart.
npm install esbuild-plugin-exclude-vendor-from-source-map
yarn add esbuild-plugin-exclude-vendor-from-source-map
pnpm add esbuild-plugin-exclude-vendor-from-source-map

Demonstrates basic usage of the plugin with esbuild to exclude node_modules from source maps.

import esbuild from 'esbuild';
import { excludeVendorFromSourceMap } from 'esbuild-plugin-exclude-vendor-from-source-map';

await esbuild.build({
    entryPoints: ['./src/index.js'],
    outfile: './dist/index.js',
    bundle: true,
    minify: true,
    sourcemap: true,
    plugins: [
        excludeVendorFromSourceMap(),
    ],
});