esbuild-plugin-globals
esbuild plugin that provides Webpack's externals functionality.
Last updated 5 years ago by astephenb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install esbuild-plugin-globals 
SYNC missed versions from official npm registry.

esbuild-plugin-globals

Provides Webpack's externals functionality for esbuild.

Install

npm:

npm install --save-dev esbuild-plugin-globals

yarn:

yarn add --dev esbuild-plugin-globals

Usage

import esbuild from "esbuild";
import GlobalsPlugin from "esbuild-plugin-globals";

esbuild.build({
  entryPoints: ["src/index.ts"],
  bundle: true,
  plugins: [
    GlobalsPlugin({
      /**
       * Simple string pattern
       * Any module matching "react" will be replaced with
       * `module.exports = React`
       */
      react: "React",
      /**
       * Regular expression + resolver function
       * Invoked with matched module name and returns the module exports (or undefined).
       */
      "@some-scope/.*": (moduleName) => {
        /** strip the scope */
        const name = name.substring(12);
        /** generates module.exports = CamelCasedName */
        return camelCase(name);
      },
    }),
  ],
});

Current Tags

  • 0.1.1                                ...           latest (5 years ago)

2 Versions

  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 2
Last Month 1
Dependencies (0)
None
Dev Dependencies (13)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org | Home |