esbuild-external-global
This is a plugin for esbuild that allows you to define global variables that are not bundled by esbuild.
Installation
npm install esbuild-external-global
Usage
const esbuild = require("esbuild");
const { externalGlobal } = require("esbuild-external-global");
const externalReact = externalGlobal({
react: "window.React",
});
esbuild
.build(
externalReact({
entryPoints: [path.resolve(__dirname, "fixtures/react/index.tsx")],
bundle: true,
write: false,
}),
)
.then(() => {
console.log("Build succeeded");
})
.catch(() => {
console.error("Build failed");
});
Why not use plugins?
There is no difference in essence esbuild#337, except that plugins in esbuild cannot be called by pipes esbuild#1902. In order not to affect other existing plugins, we use aliases instead.