Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

esbuild-plugin-node-externals

LinbuduLab6.2kMIT1.0.1TypeScript support: included

ESBuild plugin for node externals.

ESBuild, plugin

readme

esbuild-plugin-node-externals

ESBuild plugin for node externals handing.

Usage

npm install esbuild-plugin-node-externals --save-dev
pnpm install esbuild-plugin-node-externals --save-dev
yarn add esbuild-plugin-node-externals --save-dev
import { build } from 'esbuild';
import { nodeExternals } from 'esbuild-plugin-node-externals';

(async () => {
  const res = await build({
    entryPoints: ['.src/main.ts'],
    bundle: true,
    outfile: './dist/main.js',
    plugins: [
      nodeExternals({
        packagePaths: 'package.json',
        include: ['SOME_PKG_YOU_WANT_TO_INCLUDE_AT_BUNDLE'],
      }),
    ],
  });
})();

Configurations

export interface NodeExternalsOptions {
  /**
   * list of package.json paths to read from
   * if not specified, will read from cwd
   */
  packagePaths: string | string[];

  /**
   * mark all dependencies as external
   * @default true
   */
  withDeps: boolean;

  /**
   * mark all devDependencies as external
   * @default true
   */
  withDevDeps: boolean;

  /**
   * mark all peerDependencies as external
   * @default true
   */
  withPeerDeps: boolean;

  /**
   * mark all optionalDependencies as external
   * @default true
   */
  withOptDeps: boolean;

  /**
   * list of packages to exclude from externalization
   */
  include: string[];
}

changelog

CHANGELOG

Released 1.0.1

  • BugFix: Update build configuration for better CJS & ESM compat support.

Released 1.0.0

  • No significant changes.
  • CHORE: Both CJS and ESM output will be published now, as with exports field in packages.json, you will be using the ESM version by import, and CJS version by require.