/esbuild-plugin-external-global

external modules as global variables

Primary LanguageTypeScriptMIT LicenseMIT

esbuild-plugin-external-global

External modules as global variables with esbuild.

Install

yarn add -D esbuild-plugin-external-global

or

npm i -D esbuild-plugin-external-global

Usage

Add to your esbuild plugins list:

const esbuild = require("esbuild");
const { externalGlobalPlugin } = require("esbuild-plugin-external-global");

esbuild.build({
  ...
  plugins: [
    externalGlobalPlugin({
      'react': 'window.React',
      'react-dom': 'window.ReactDOM',
      'jQuery': '$',
      'fetch-json': 'globalThis'
    })
  ]
  ...
});