# esbuild-plugin-node-externals

> ESBuild plugin for node externals.

Latest version **1.0.1** (published 2022-11-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install esbuild-plugin-node-externals
pnpm add esbuild-plugin-node-externals
yarn add esbuild-plugin-node-externals
bun add esbuild-plugin-node-externals
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-11-21 |
| First published | 2021-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Linbudu |
| Maintainers | linbudu |
| Keywords | ESBuild, plugin |

## Links

- npm: https://www.npmjs.com/package/esbuild-plugin-node-externals
- Repository: https://github.com/LinbuduLab/esbuild-plugins
- Homepage: https://github.com/LinbuduLab/esbuild-plugins/tree/master/packages/esbuild-plugin-node-externals#readme
- Issues: https://github.com/LinbuduLab/esbuild-plugins/issues
- npm.io page: https://npm.io/package/esbuild-plugin-node-externals

## Dependencies (2)

- [find-up](https://npm.io/package/find-up.md) 5.0.0
- [jsonfile](https://npm.io/package/jsonfile.md) ^6.1.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-11-21
- 1.0.0 — 2022-11-17
- 0.3.0 — 2022-03-05
- 0.2.0 — 2021-09-20
- 0.1.2 — 2021-05-27
- 0.1.0 — 2021-05-20
- 0.0.1-1 — 2021-04-08

## README

# esbuild-plugin-node-externals

ESBuild plugin for node externals handing.

- [Author](https://github.com/linbudu599)
- [GitHub Repo](https://github.com/LinbuduLab/esbuild-plugins/tree/master/packages/esbuild-plugin-node-externals#readme)
- [Changelog](https://github.com/LinbuduLab/esbuild-plugins/blob/main/packages/esbuild-plugin-node-externals/CHANGELOG.md)

## Usage

```bash
npm install esbuild-plugin-node-externals --save-dev
pnpm install esbuild-plugin-node-externals --save-dev
yarn add esbuild-plugin-node-externals --save-dev
```

```typescript
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

```typescript
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[];
}
```

---
_Source: https://npm.io/package/esbuild-plugin-node-externals · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
