esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

feat #3666 add optional exclude option for plugin `onLoad` and `onResolve` hooks

Open sod opened this issue 4 months ago • 1 comments

This allows plugins that are very broadly applied to user code, to ignore files and folders it knows not to touch, like node_modules, static files or shared folders.

As the cost of calling a plugin is not 0, especially onResolve hooks, this could help improve performance of plugins.

See #3666

used like:

const myPlugin = {
  name: 'my-plugin',
  setup(build) {
    build.onResolve({ filter: /.js$/, exclude: /^(static|my-lib)\// }, args => {
    })
    build.onLoad({ filter: /.js$/, exclude: /\/node_modules\// }, args => {
    })
  }
}

the exclude is optional and the filter-only syntax stil works.

sod avatar Feb 24 '24 14:02 sod

@evanw whats your stance on this? Should I rebase, change something or drop? :)

sod avatar May 02 '24 10:05 sod