# esbuild-plugin-globals

> esbuild plugin that provides Webpack's externals functionality.

Latest version **0.2.0** (published 2023-03-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install esbuild-plugin-globals
pnpm add esbuild-plugin-globals
yarn add esbuild-plugin-globals
bun add esbuild-plugin-globals
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2023-03-06 |
| First published | 2021-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=7 |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Andy Brown |
| Maintainers | astephenb |
| Keywords | esbuild, esbuild-plugin |

## Links

- npm: https://www.npmjs.com/package/esbuild-plugin-globals
- Repository: https://github.com/a-b-r-o-w-n/esbuild-plugin-globals
- Homepage: https://github.com/a-b-r-o-w-n/esbuild-plugin-globals#readme
- Issues: https://github.com/a-b-r-o-w-n/esbuild-plugin-globals/issues
- npm.io page: https://npm.io/package/esbuild-plugin-globals

## 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

- 0.2.0 (latest) — 2023-03-06
- 0.1.1 — 2021-02-12
- 0.1.0 — 2021-02-05

## README

# esbuild-plugin-globals

Provides Webpack's [externals](https://webpack.js.org/configuration/externals/) functionality for [esbuild](https://webpack.js.org/configuration/externals/).

## Install

npm:

```bash
npm install --save-dev esbuild-plugin-globals
```

yarn:

```bash
yarn add --dev esbuild-plugin-globals
```

## Usage

```js
import esbuild from "esbuild";
import GlobalsPlugin from "esbuild-plugin-globals";

esbuild.build({
  entryPoints: ["src/index.ts"],
  bundle: true,
  plugins: [
    GlobalsPlugin({
      /**
       * Simple string pattern
       * Any module matching "react" will be replaced with
       * `module.exports = React`
       */
      react: "React",
      /**
       * Regular expression + resolver function
       * Invoked with matched module name and returns the module exports (or undefined).
       */
      "@some-scope/.*": (moduleName) => {
        /** strip the scope */
        const name = name.substring(12);
        /** generates module.exports = CamelCasedName */
        return camelCase(name);
      },
    }),
  ],
});
```

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