After executing build.Onload execution is passed to the loader
- Dominant language
- Go
- Stars
- 40.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
I have written the following plugins:
```js
const pathReplacePlugin = ((filter) => {
return {
name: "path-replace",
setup(build){
build.onLoad({ filter: /\.svelte$/ }, (opts) => {
let source = fs.readFileSync(opts.path, 'utf8').toString();
source = source.replace(/(\/static\/images|@\{img_path\})/g, function handleReplace(match) {
let dirname = __dirname
const relPath = path.relative(opts.path, dirname).replace(/\\/g, '/')
let relativeUrl = Array(this.file.relative.split(path.sep).length + 1).fill('..').join('/')
relativeUrl += '/images';
return relativeUrl;
});
return {
contents: source,
pluginData: opts.pluginData,
};
})
}
}
});
```
according to my idea, after it, the control should go to *esbuildSvelte* according to the order in which they are listed in the plugins *option*:

but I ran into the following error:

I assume that this is due to the fact that management immediately goes to the default loader (`js`). And then the collector assumes that the tag is js (since it is imported into a js file, it may seem that this is the case), but it is not. The next plugin on the list should handle the processing, not the loader.
Is there a way to transfer control to the next plugin, bypassing loaders?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the build.onLoad callback and the plugins option shown in the issue, then reproduce the behavior with the path-replace and esbuildSvelte plugins in that order. Compare the observed loader selection with esbuild's plugin lifecycle documentation; done means establishing whether control can bypass the loader and documenting or correcting the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100