-
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
metadata returned by plugin is inconsistent happens #2177
Comments
This also happens with https://stackblitz.com/edit/node-dmisef?file=bundle.js. plugin of first reproduction const aliasPlugin = {
name: 'alias',
setup({ onResolve }) {
onResolve({ filter: /^@/ }, ({ path: p, importer }) => {
return {
path: path.resolve(path.dirname(importer), p.replace(/^@/, '.')),
};
});
},
}; plugin of second reproduction const aliasPlugin = {
name: 'alias',
setup({ onResolve, resolve }) {
onResolve({ filter: /^@/ }, async ({ path: p, importer }) => {
return await resolve(p.replace(/^@/, '.'), {
resolveDir: path.dirname(importer),
});
});
},
}; |
Definitely happing locally here on OSX |
can reproduce on Linux as well |
I confirmed this happens with linux by using docker. |
The diff of esbuild/internal/bundler/bundler.go Lines 788 to 794 in 757d7d9
esbuild/internal/resolver/resolver.go Lines 654 to 782 in 757d7d9
|
Yes, I can confirm locally as well. Thanks for the report and for the suggested fix. This clearly should have been introduced as a warning instead of an error though. My apologies. I believe what esbuild is flagging here may be representative of a real issue that was previously undiscovered. The discrepancy between the module types could hypothetically lead to a divergence in build behavior in this case depending on which set of metadata is chosen first. I will revert this for now and then work on getting this fixed. |
The revert has been published as 0.14.36, so that version should work. Sorry about the breakage. A bit more background: As a performance shortcut, esbuild's internals pass metadata about the resolved file (e.g. However, when the plugin API was added that design wasn't changed, and is error-prone as a result because plugins can inject arbitrary code that doesn't follow the original rules. I could make the suggested change above to call |
Maybe Related: #2176, vitejs/vite#7683, vitejs/vite#7685
Reproduction
npm i
andnode bundle.js
On windows,
Detected inconsistent metadata for the path "src/c.js" when it was imported here:
happens.But on stackblitz, it does not happen.
Full error log
The text was updated successfully, but these errors were encountered: