esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

onResolve chain not work

Open SeekingMini opened this issue 2 years ago • 1 comments

I wrote two plugins which implement onResolve.

let plugin1 = {
  name: "plugin1",
  setup(build) {
    build.onResolve({ filter: /.*/ }, function (args) {
      return { };
    });
  },
};
let plugin2 = {
  name: "plugin2",
  setup(build) {
    build.onResolve({ filter: /.*/ }, (args) => {
      console.log(args);
    });
  },
};

but plugin2 doesn't print anything. I read the doc and this is what it said about OnResolveResult.path:

If this is not set, esbuild will continue to run on-resolve callbacks that were registered after the current one.

I don't set path in return value to plugin1,but plugin2 doesn't seem to work.

SeekingMini avatar Apr 28 '22 17:04 SeekingMini

For a given import path, all onResolve callbacks from all plugins will be run in the order they were registered until one takes responsibility for path resolution.

Looks like if one of onResolve callback return path, then it won't execute rest callbacks, code is here However, the condition seems not follow the doc which I posted above. it should be

path != null

Also, onLoad have same problem, although contents is the key in onLoad case

For a given module, all onLoad callbacks from all plugins will be run in the order they were registered until one takes responsibility for loading the module

contents != null

Hi @evanw Could yuou verify it? I'm very happy to make a PR for it.

susiwen8 avatar May 08 '22 14:05 susiwen8