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.
Common errors
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'
Warnings
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.
Install
npm install esbuild-plugin-noexternal yarn add esbuild-plugin-noexternal pnpm add esbuild-plugin-noexternal Imports
- default wrong
const externalizeAllPackagesExcept = require('esbuild-plugin-noexternal')correctimport externalizeAllPackagesExcept from 'esbuild-plugin-noexternal' - externalizeAllPackagesExcept (named) wrong
import externalizeAllPackagesExcept from 'esbuild-plugin-noexternal'correctimport { externalizeAllPackagesExcept } from 'esbuild-plugin-noexternal' - Plugin type wrong
import { Plugin } from 'esbuild-plugin-noexternal'correctimport type { Plugin } from 'esbuild'
Quickstart
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'])],
});