Skip to content

gjsify/esbuild-plugin-glob

 
 

Repository files navigation

⚡️ esbuild plugin glob ⚡️

Use glob entry points in esbuild.

This plugin allows the usage of glob patterns as entry points for esbuild. It supports single builds as well as watch mode.

Installation

Use a package manager like yarn or npm

yarn add esbuild-plugin-glob

Usage

import { globPlugin } from 'esbuild-plugin-glob';

esbuild.build({
  entryPoints: ['src/**/*.tsx'],
  // watch: true,
  plugins: [globPlugin()],
});

API and defaults

globPlugin({
  // Optional additional entrypoints/glob patterns
  additionalEntrypoints: [],
  // Options directly passed to chokidar when in watch mode
  chokidarOptions: {},
  // Make the function return a `controls` object, see below
  controls: false,
  // Disables logging on file changes
  silent: false,
})

Controls

By passing the option controls: true the globPlugin function returns a tuple with the plugin object and a controls object.

import { globPlugin } from 'esbuild-plugin-glob';

const [glob, globControls] = globPlugin({ controls: true });

esbuild.build({
  entryPoints: ['src/**/*.tsx'],
  watch: true,
  plugins: [glob],
});

// Stops watching the entry files when in watch mode
await globControls.stopWatching();

How it works

For single builds it simply resolves the provided glob patterns before esbuild runs.

In watch mode it uses chokidar to watch the provided glob patterns and inspects the corresponding esbuild build results to make sure dependencies are also being watched.

Contribute

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

glob entry points in esbuild

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 94.7%
  • JavaScript 4.9%
  • Shell 0.4%