esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

add an optional cache and `exclude` option to the `onResolve` plugin hook

Open sod opened this issue 1 year ago • 1 comments

As the angular-cli right now fully commits to esbuild, the onResolve hook reveals itself as a pretty stark performance hinderance to the otherwise astonishing speed of esbuild.

In my mind this is how the API could look like to improve:

build.onResolve({ filter: /^[^./]/, exclude: /^(@angular|rxjs)\// } }, async (args) => {
    if (/* some condition */) {
        return { path: args.path, external: true, cachable: true };
    }

    return { path: args.path, cachable: true };
});
  1. The exclude option could be a way around the missing lookahead feature of go-regex. To stamp out imports we don't want to look at
  2. The opt-in cachable: true could tell esbuild to not ask for the same information again, which would be nice for watcher performance

Would you be open to this idea and if yes, would you appreciate a PR contribution?

sod avatar Feb 23 '24 10:02 sod

Maybe the cachable is a bit much. But the exclude option could go a long way.

sod avatar Feb 24 '24 13:02 sod