Bug report
#17931 introduced functionality to support __dirname and __filename shims for module output.
Unfortunately, there are false assumptions in the behavior - namely any import.meta.url that has a query param will break.
https://github.com/webpack/webpack/pull/17931/files#diff-ec15f6ea9baa75e9b3ca10449f3b9b7e04e56828330aa5a31d8a83aadd733ed0R225
https://github.com/webpack/webpack/blame/e97af9b5317bc0e7fdbc035b98a577edfe258b83/lib/NodeStuffPlugin.js#L230
What is the current behavior?
Current behavior just string appends '/..' to the import.meta.url value to try to get a directory. This is inaccurate behavior for any import urls which contain query params.
If the current behavior is a bug, please provide the steps to reproduce.
Don't have an easy example I can generate offhand here, but any webpack node build with __dirname: 'node-module' is prone to this issue when running, e.g., const x = import('./relative_path.mjs?reload=123');
What is the expected behavior?
Other relevant information:
webpack version: 6.91.0
Node.js version: 20.11.1
Operating System: linux/windows x64
Additional tools:
Bug report
#17931 introduced functionality to support __dirname and __filename shims for module output.
Unfortunately, there are false assumptions in the behavior - namely any import.meta.url that has a query param will break.
https://github.com/webpack/webpack/pull/17931/files#diff-ec15f6ea9baa75e9b3ca10449f3b9b7e04e56828330aa5a31d8a83aadd733ed0R225
https://github.com/webpack/webpack/blame/e97af9b5317bc0e7fdbc035b98a577edfe258b83/lib/NodeStuffPlugin.js#L230
What is the current behavior?
Current behavior just string appends
'/..'to theimport.meta.urlvalue to try to get a directory. This is inaccurate behavior for any import urls which contain query params.If the current behavior is a bug, please provide the steps to reproduce.
Don't have an easy example I can generate offhand here, but any webpack node build with
__dirname: 'node-module'is prone to this issue when running, e.g.,const x = import('./relative_path.mjs?reload=123');What is the expected behavior?
Other relevant information:
webpack version: 6.91.0
Node.js version: 20.11.1
Operating System: linux/windows x64
Additional tools: