esbuild-plugin-noexternal

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

An esbuild plugin that externalizes all npm packages except those explicitly allowed. v0.1.6, stable but minimal release cadence. The key differentiator is simplicity: it inverts esbuild's default externalization logic by marking everything external except a user-defined list, similar to Vite's `noExternal` option. Best for build scenarios like SSR or bundling where most dependencies should be excluded. Ships TypeScript types.

error Cannot find module 'esbuild-plugin-noexternal'
cause Package not installed.
fix
npm install -D esbuild-plugin-noexternal
error The requested module 'esbuild-plugin-noexternal' does not provide an export named 'default'
cause Using named import instead of default import incorrectly.
fix
Use: import externalizeAllPackagesExcept from 'esbuild-plugin-noexternal'
gotcha Plugin uses 'onResolve' to mark packages as external; does not support custom filter or namespace.
fix If you need more control, consider writing a custom 'onResolve' plugin or using esbuild-plugin-external-global-packages.
gotcha All external packages must be installed; the plugin does not validate package existence.
fix Ensure all dependencies not in the listed array are installed; otherwise imports will fail at runtime.
deprecated No known deprecations.
npm install esbuild-plugin-noexternal
yarn add esbuild-plugin-noexternal
pnpm add esbuild-plugin-noexternal

Builds a bundle that includes only 'nanoid' and 'slash'; all other npm packages are treated as external.

import esbuild from 'esbuild';
import externalizeAllPackagesExcept from 'esbuild-plugin-noexternal';

await esbuild.build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  outfile: 'out.js',
  plugins: [externalizeAllPackagesExcept(['nanoid', 'slash'])],
});