An esbuild plugin that maps external modules to global variables, enabling bundle-size reduction by excluding dependencies like React, ReactDOM, or jQuery and referencing them via globals such as window.React. Version 1.0.1 is stable with minimal API surface. It provides a simple mapping object where keys are module names and values are global variable expressions. The plugin is commonly used in library builds where certain dependencies are provided by the host environment. It has TypeScript types and works with both CJS and ESM esbuild configurations. Compared to similar plugins like esbuild-plugin-externalize, this one focuses specifically on global variable fallbacks rather than file-based externals.
npm install esbuild-plugin-external-globalNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Build a bundle excluding React and ReactDOM, expecting them as globals.
Replace 'externalGlobal' with 'externalGlobalPlugin' in imports and usage.
Add 'external: ["react", "react-dom"]' to esbuild options.
Use 'window.React' not '"window.React"'.
Change 'import externalGlobalPlugin from...' to 'import { externalGlobalPlugin } from...'.Ensure plugin is an object with setup function: wrap result of externalGlobalPlugin() in brackets: plugins: [externalGlobalPlugin({...})].No dependency data recorded yet.