You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 90b2ecf
Browse filesBrowse the repository at this point in the historyBrowse files
[JSC] hostResolveImportedModule should respect the module request's import attribute type
https://bugs.webkit.org/show_bug.cgi?id=320341
Reviewed by Yusuke Suzuki.
Since 317844@main, hostResolveImportedModule looks up [[LoadedModules]] by specifier
alone, probing each ScriptFetchParameters::Type in a fixed order (JavaScript first).
When one specifier is loaded under two types, JSON/WebAssembly-typed bindings resolve
against the JavaScript module:
// a.js contains `42`, run with --useImportDefer=1
import jsonValue from "./a.js" with { type: "json" }; // SyntaxError: no default export in the JavaScript module
import defer * as ns from "./a.js";
This patch:
1. Records the request's ScriptFetchParameters::Type in ImportEntry, ExportEntry, and
star export entries, and makes hostResolveImportedModule an exact (specifier, type)
lookup. The enum fits existing struct padding, so entry sizes are unchanged.
2. Dedups ModuleAnalyzer's requested modules by (specifier, type) instead of specifier
alone, so two same-specifier requests with different types are both loaded.
3. Keys m_starExportEntries by (module name, type) instead of module name alone (still
an OrderedHashSet, so occurrence order is preserved), which keeps `export * from "./a"`
and `export * from "./a" with { type: "json" }` distinct.
Tests: JSTests/modules/import-attributes-same-specifier-different-type.js
JSTests/modules/import-attributes-same-specifier-same-phase.js
* JSTests/modules/import-attributes-same-specifier-different-type.js: Added.
* JSTests/modules/import-attributes-same-specifier-same-phase.js: Added.
* JSTests/modules/resources/dual-type-reexport.js: Added.
* JSTests/modules/resources/dual-type.js: Added.
* Source/JavaScriptCore/parser/ModuleAnalyzer.cpp:
(JSC::ModuleAnalyzer::appendRequestedModule):
(JSC::ModuleAnalyzer::exportVariable):
* Source/JavaScriptCore/parser/ModuleAnalyzer.h:
* Source/JavaScriptCore/parser/NodesAnalyzeModule.cpp:
(JSC::ImportDeclarationNode::analyzeModule):
(JSC::ExportAllDeclarationNode::analyzeModule):
(JSC::ExportNamedDeclarationNode::analyzeModule):
* Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp:
(JSC::AbstractModuleRecord::addStarExportEntry):
(JSC::AbstractModuleRecord::ExportEntry::createLocal):
(JSC::AbstractModuleRecord::ExportEntry::createIndirect):
(JSC::AbstractModuleRecord::ExportEntry::createNamespace):
(JSC::AbstractModuleRecord::hostResolveImportedModule):
(JSC::AbstractModuleRecord::resolveImport):
(JSC::AbstractModuleRecord::resolveExportImpl):
(JSC::AbstractModuleRecord::resolveExport):
(JSC::AbstractModuleRecord::getModuleNamespace):
(JSC::AbstractModuleRecord::dump):
* Source/JavaScriptCore/runtime/AbstractModuleRecord.h:
* Source/JavaScriptCore/runtime/CyclicModuleRecord.cpp:
(JSC::CyclicModuleRecord::initializeEnvironment):
* Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::tryCreate):
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::initializeImports):
Canonical link: https://commits.webkit.org/318292@main
0 commit comments