berry: [Bug?]: Dynamic import of module with query string param doesn't work
Self-service
- I’d be willing to implement a fix
Describe the bug
When I enable the pnpEnableEsmLoader
flag & try to import local module in this manner:
import('./module.js?cache=busted');
I get errors such as these (real path prefixes replaced):
/path/to/.pnp.cjs:46662
return Object.defineProperties(new Error(message), {
^
Error: Qualified path resolution failed - none of those files can be found on the disk.
Source path: /path/to/module.js?cache=busted
Not found: /path/to/module.js?cache=busted
at internalTools_makeError (/path/to/.pnp.cjs:46662:34)
at resolveUnqualified (/path/to/.pnp.cjs:48025:13)
at resolveRequest (/path/to/.pnp.cjs:48058:14)
at Object.resolveRequest (/path/to/.pnp.cjs:48130:26)
at resolve$1 (file:///path/to/.pnp.loader.mjs:206:25)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ESMLoader.import (node:internal/modules/esm/loader:276:22)
at importModuleDynamically (node:internal/modules/esm/translators:111:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
The whole reason behind doing this is that described here (tl;dr: CommonJS allows you to manipulate its import cache, but ES-modules don’t have that any more)
To reproduce
Minimal repro is a rather esoteric concept at this stage & I do believe that this is a question of such imports even being supported by yarn.
If it is indeed supported, and you believe that this should work as is, I will gladly supply more information as requested.
Environment
System:
OS: Linux 5.11 Ubuntu 21.10 21.10 (Impish Indri)
CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Binaries:
Node: 16.13.1 - /tmp/xfs-3cc39734/node
Yarn: 3.2.0-rc.5 - /tmp/xfs-3cc39734/yarn
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (7 by maintainers)
Fixed cache busting in https://github.com/yarnpkg/berry/pull/3895/commits/0594e33342b65e8e07538299f1b6e2d823a1c15c