Skip to content

remorses/esbuild-plugins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

373b449 · Aug 4, 2023
Jan 27, 2023
Jan 26, 2023
Jan 27, 2023
Jan 27, 2023
Jan 27, 2023
Jan 27, 2023
Jan 27, 2023
Jan 27, 2023
Jan 27, 2023
Jan 27, 2023
Dec 3, 2020
Dec 3, 2020
Aug 4, 2023
Dec 3, 2020
Jan 26, 2023
Mar 31, 2021
Jan 27, 2023

Repository files navigation




Esbuild plugins



Plugins

  • @esbuild-plugins/node-resolve
  • @esbuild-plugins/esm-externals
  • @esbuild-plugins/node-modules-polyfill (out of date, use esbuild-plugin-polyfill-node for up to date polyfills)
  • @esbuild-plugins/node-globals-polyfill (out of date, use esbuild-plugin-polyfill-node for up to date polyfills)

@esbuild-plugins/node-resolve

Resolve files with the resolve package and adds support for Yarn berry PnP.

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

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

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

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

Holocron

About

Collection of useful esbuild js plugins

Resources

Stars

Watchers

Forks

Packages

No packages published