Registry / devops / esbuild-externals-plugin

esbuild-externals-plugin

JSON →
library1.4.0jsnpmunverified

An esbuild plugin that provides fine-grained control over external dependencies, ensuring that when a package like 'rxjs' is marked external, its subpath imports (e.g., 'rxjs/operators') are not also externalized unless explicitly specified. This prevents surprises in microfrontend or library builds where partial bundling of submodules is desired. Current stable version is 1.4.0, released as part of the piral-cli-esbuild ecosystem. Actively maintained with a strong focus on correct external handling for monorepos and shared dependency scenarios. Ships TypeScript types. Requires Node >=16.0.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CommonJS require works, but ESM import is preferred. The package exports a named function, not a default export.

import { externalsPlugin } from 'esbuild-externals-plugin'

There is no default export; only a named export. Using a default import will result in undefined.

import { externalsPlugin } from 'esbuild-externals-plugin'

CommonJS usage should destructure the named export. There is no .default property.

const { externalsPlugin } = require('esbuild-externals-plugin')

Shows how to use externalsPlugin with esbuild to externalize 'lodash' and 'react' while keeping subpath imports like 'lodash/fp' bundled.

const { build } = require('esbuild'); const { externalsPlugin } = require('esbuild-externals-plugin'); build({ entryPoints: ['src/index.js'], outfile: 'dist/bundle.js', bundle: true, plugins: [externalsPlugin(['lodash', 'react'])], }).catch(() => process.exit(1));
Debug
Known footguns
breakingIn v1.3.0, required Node.js version was raised to >=20.18.1 for security reasons.
gotchaThe plugin only externalizes the exact package names provided; subpath imports (e.g., 'rxjs/operators') are NOT externalized. If you need subpaths external, you must list them explicitly.
deprecatedSupport for esbuild versions before 0.18 is deprecated and may be removed in future releases.
gotchaWhen using CJS require, the exported function is named, not default. Using require('esbuild-externals-plugin').default yields undefined.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
10 hits · last 30 days
claudebot
4
gptbot
3
ahrefsbot
3
Resources