-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdin not supports onLoad && onResolve plugin #720
Comments
@hardfist I’d recommend adding some reproducible code snippets -- whatever you tried for example. |
if i pass entry throungh entrypoints, load and resolve plugin are called, but when i pass entry through stdin load and resolve plugins are not called const result = await build({
// entryPoints: [path.join(__dirname, 'src/index.js')], // resolve and load plugin are called
stdin: { // resolve and load plugin are not called
contents: 'export default 42',
loader: 'js',
resolveDir: '',
sourcefile: 'test.js',
},
bundle: true,
format: 'esm',
splitting: true,
outdir: 'dist',
write: false,
plugins: [
{
name: 'esbuild',
setup(build) {
build.onResolve({ filter: /.*/ }, (args) => {
console.log('load args:', args);
});
build.onLoad({ filter: /.*/ }, (args) => {
console.log('resolve args2:', args);
});
},
},
],
}); src/index.js export default 42 |
If I'm understanding your issue correctly, this is by design. The stdin API is a convenience API and has limited features. If you need the behavior I think you're asking for, you should be able to implement it yourself: const result = await build({
entryPoints: ['<stdin>'],
bundle: true,
format: 'esm',
splitting: true,
outdir: 'dist',
write: false,
plugins: [
{
name: 'esbuild',
setup(build) {
build.onResolve({ filter: /^<stdin>$/ }, (args) => {
return { path: 'test.js', namespace: 'stdin' };
});
build.onLoad({ filter: /.*/, namespace: 'stdin' }, (args) => {
return { contents: 'export default 42', loader: 'js' };
});
},
},
],
}); |
yes, It works , but kind of awkard, If it's by design, then I think it's ok。 |
Closing since this is by design, and there is a workaround. |
It seems that stdin contents isn't handled by onLoad && onResolve plugin, and it seems doesn't support namespace too
The text was updated successfully, but these errors were encountered: