Uh oh!
There was an error while loading. Please reload this page.
module: link module with a module request record - #58886
Conversation
nodejs-github-bot
commented
Jun 29, 2025
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #58886 +/- ##
==========================================
- Coverage 90.10% 90.08% -0.03%
==========================================
Files 640 640 Lines 188493 188502 +9 Branches 36971 36977 +6 ==========================================
- Hits 169843 169805 -38 - Misses 11358 11428 +70 + Partials 7292 7269 -23
🚀 New features to boost your workflow:
|
a8faeb0 to
5ea8994Comparenodejs-github-bot
commented
Jun 29, 2025
aduh95
commented
Jun 30, 2025
That's not how I interpret the spec, AFAICT the spec says nothing about what the behavior should if they are different. If |
The spec didn't say the two specifier may be mapped to a single module. The issue is that, if a loader resolves a single specifier with different import attributes, to two modules, the current implementation take the latter because the cache is keyed by specifier only. If a loader interprets additional attributes, like: import*assecret1from'a-json-package'with{type: 'json',integrity: 'frozen'};import*assecret2from'a-json-package'with{type: 'json'};This will be problematic because both namespaces |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
guybedford
left a comment
There was a problem hiding this comment.
This definitely better aligns with the specification, thanks for doing this work.
There was a problem hiding this comment.
I wasn't aware of a convention to import Module instead of module here. What makes Module different from other core libs here? Seems it should use the same casing unless there is a good reason.
There was a problem hiding this comment.
It's just my preference lasted from CJS that to prevent name collision with CJS module.
There was a problem hiding this comment.
In node:module, module.exports = Module, so the default export is also the Module constructor.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
6a8b7e7 to
1abf30bComparenodejs-github-bot
commented
Jul 1, 2025
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
1abf30b to
f7185b1Comparenodejs-github-bot
commented
Jul 2, 2025
Uh oh!
There was an error while loading. Please reload this page.
f7185b1 to
008345aComparenodejs-github-bot
commented
Jul 3, 2025
legendecas
commented
Jul 3, 2025
@aduh95@guybedford@joyeecheung updated PR to use hash+equality caching. PTAL again, thanks! |
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Jul 3, 2025
joyeecheung
commented
Jul 3, 2025
I think we might still be able to avoid the extra string storage & transcoding with cppgc-managed wrappers; but that's probably a task for another PR. |
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Jul 3, 2025
When a module is being statically linked with module requests, if two module requests with a same specifier but different attributes are resolved to two modules, the module requests should be linked to these two modules.
008345a to
ed81a84Comparenodejs-github-bot
commented
Jul 4, 2025
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Jul 4, 2025
Landed in cc856b3 |
When a module is being statically linked with module requests, if two module requests with a same specifier but different attributes are resolved to two modules, the module requests should be linked to these two modules. PR-URL: #58886 Refs: https://tc39.es/ecma262/#sec-HostLoadImportedModule Refs: https://github.com/tc39/proposal-import-attributes?tab=readme-ov-file#how-would-this-proposal-work-with-caching Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
aduh95
commented
Jul 21, 2025
This doesn't land cleanly on v22.x-staging |
When a module is being statically linked with module requests, if two module requests with a same specifier but different attributes are resolved to two modules, the module requests should be linked to these two modules. PR-URL: #58886 Backport-PR-URL: #60000 Refs: https://tc39.es/ecma262/#sec-HostLoadImportedModule Refs: https://github.com/tc39/proposal-import-attributes?tab=readme-ov-file#how-would-this-proposal-work-with-caching Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
When a module is being statically linked with module requests, if two
module requests with a same specifier but different attributes are
resolved to two modules, the module requests should be linked to these
two modules.
For example,
should result in two different module instances, if the second import
is been evaluated as a CommonJS/ESM module by a loader.
ECMA-262 requires that in
HostLoadImportedModule, if the operation is calledmultiple times with two (referrer, moduleRequest) pairs, it should return the same
result. But if the moduleRequest is different, and the module loader resolves to
different module instances, it should return different module instances.
Refs: https://tc39.es/ecma262/#sec-HostLoadImportedModule
Refs: https://github.com/tc39/proposal-import-attributes?tab=readme-ov-file#how-would-this-proposal-work-with-caching