# @esbuild-plugins/node-modules-polyfill

Latest version **0.2.2** (published 2023-01-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install @esbuild-plugins/node-modules-polyfill
pnpm add @esbuild-plugins/node-modules-polyfill
yarn add @esbuild-plugins/node-modules-polyfill
bun add @esbuild-plugins/node-modules-polyfill
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2023-01-27 |
| First published | 2020-12-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 69.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 286 |
| Author | Tommaso De Rossi, morse |
| Maintainers | xmorse |

## Links

- npm: https://www.npmjs.com/package/@esbuild-plugins/node-modules-polyfill
- Repository: https://github.com/remorses/esbuild-plugins
- Homepage: https://github.com/remorses/esbuild-plugins#readme
- Issues: https://github.com/remorses/esbuild-plugins/issues
- npm.io page: https://npm.io/package/@esbuild-plugins/node-modules-polyfill

## Dependencies (2)

- [escape-string-regexp](https://npm.io/package/escape-string-regexp.md) ^4.0.0
- [rollup-plugin-node-polyfills](https://npm.io/package/rollup-plugin-node-polyfills.md) ^0.2.1

## Recent versions

- 0.2.2 (latest) — 2023-01-27
- 0.2.1 — 2023-01-27
- 0.2.0 — 2023-01-26
- 0.1.4 — 2022-01-01
- 0.1.3 — 2022-01-01
- 0.1.2 — 2021-09-04
- 0.1.1 — 2021-03-30
- 0.1.0 — 2021-03-30
- 0.0.2 — 2020-12-21
- 0.0.1 — 2020-12-03

## README

<div align='center'>
    <br/>
    <br/>
    <!-- <img src='' width='320px'> -->
    <br/>
    <h3>Esbuild plugins</h3>
    <br/>
    <br/>
</div>

# Plugins

-   [x] `@esbuild-plugins/node-resolve`
-   [x] `@esbuild-plugins/esm-externals`
-   [x] `@esbuild-plugins/node-modules-polyfill` (out of date, use [esbuild-plugin-polyfill-node](https://github.com/cyco130/esbuild-plugin-polyfill-node) for up to date polyfills)
-   [x] `@esbuild-plugins/node-globals-polyfill` (out of date, use [esbuild-plugin-polyfill-node](https://github.com/cyco130/esbuild-plugin-polyfill-node) for up to date polyfills)

## @esbuild-plugins/node-resolve

Resolve files with the [resolve](https://www.npmjs.com/package/resolve) package and adds support for Yarn berry PnP.

```ts
import NodeResolve from '@esbuild-plugins/node-resolve'
import { build } from 'esbuild'
build({
    plugins: [
        NodeResolve({
            extensions: ['.ts', '.js'],
            onResolved: (resolved) => {
                if (resolved.includes('node_modules')) {
                    return {
                        external: true,
                    }
                }
                return resolved
            },
        }),
    ],
})
```

## @esbuild-plugins/esm-externals

Makes some packages externals and forces the output to be valid ESM

```ts
import EsmExternals from '@esbuild-plugins/esm-externals'
import { build } from 'esbuild'
build({
    plugins: [EsmExternals({ externals: ['react', 'react-dom'] })],
})
```

## @esbuild-plugins/node-modules-polyfill

Polyfills nodejs builtin modules for the browser

```ts
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
import { build } from 'esbuild'
build({
    plugins: [NodeModulesPolyfillPlugin()],
})
```

## @esbuild-plugins/node-globals-polyfill

Polyfills nodejs globals like `process`

```ts
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import { build } from 'esbuild'
build({
    plugins: [
        NodeGlobalsPolyfillPlugin({
            process: true,
            buffer: true,
            define: { 'process.env.var': '"hello"' }, // inject will override define, to keep env vars you must also pass define here https://github.com/evanw/esbuild/issues/660
        }),
    ],
})
```


## Sponsors

[**Holocron**](https://holocron.so#github-esbuild-plugins)

[![Holocron](https://holocron.so/banners/github.png)](https://holocron.so#github-esbuild-plugins)

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