Skip to content
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

Multiple Import Maps #381

Closed
yoavweiss opened this issue Aug 9, 2024 · 3 comments
Closed

Multiple Import Maps #381

yoavweiss opened this issue Aug 9, 2024 · 3 comments
Labels
from: other Proposed, edited, or co-edited by an individual or entity that doesn't have a more specific label. position: support topic: html Spec relates to HTML (Hypertext Markup Language) topic: javascript Spec relates to the JavaScript programming language venue: WHATWG HTML Workstream

Comments

@yoavweiss
Copy link

yoavweiss commented Aug 9, 2024

WebKittens

@annevk

Title of the spec

Dynamic import maps

URL to the spec

whatwg/html#10528

URL to the spec's repository

https://github.com/whatwg/html

Issue Tracker URL

No response

Explainer URL

whatwg/html#10528 (comment)

TAG Design Review URL

w3ctag/design-reviews#980

Mozilla standards-positions issue URL

mozilla/standards-positions#1058

WebKit Bugzilla URL

https://bugs.webkit.org/show_bug.cgi?id=279025

Radar URL

rdar://135555516

Description

Import maps currently have to load before any ES module and there can only be a single import map per document. That makes them fragile and potentially slow to use in real-life scenarios: Any module that loads before them breaks the entire app, and in apps with many modules the become a large blocking resource, as the entire map for all possible modules needs to load first.

This proposal is to enable multiple import maps per document, by merging them in a consistent and deterministic way.

@marcoscaceres

This comment was marked as resolved.

@annevk annevk added topic: html Spec relates to HTML (Hypertext Markup Language) topic: javascript Spec relates to the JavaScript programming language from: other Proposed, edited, or co-edited by an individual or entity that doesn't have a more specific label. labels Oct 7, 2024
@yoavweiss yoavweiss changed the title Dynamic Import Maps Multiple Import Maps Oct 8, 2024
@yoavweiss

This comment was marked as resolved.

@annevk
Copy link
Contributor

annevk commented Nov 4, 2024

Colleagues and I consider this a reasonable improvement to Import Maps. As such I suggest we mark it "position: supports" one week from now.

@annevk annevk closed this as completed Nov 12, 2024
yoavweiss added a commit to yoavweiss/WebKit that referenced this issue Dec 10, 2024
https://bugs.webkit.org/show_bug.cgi?id=284286

Reviewed by NOBODY (OOPS!).

This PR removes support for external import maps and ensures they throw an
error instead. That would align WebKit's behavior with the HTML standard
and other browsers.

It also imports a new WPT test that validates the standard requirement
this fixes, as well as adjusts relevant WPT results. This adjustment
results in some progressions and some regressions. The regressions would
be fixed as part of
WebKit/standards-positions#381.

Upstream commit: web-platform-tests/wpt@ef41368

* LayoutTests/imported/w3c/web-platform-tests/import-maps/acquiring/dynamic-import-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/acquiring/script-tag-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/acquiring/script-tag-inline-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/external-import-map-errors-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/import-maps/external-import-map-errors.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/import-maps/multiple-import-maps/already-resolved-dropped-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/multiple-import-maps/resolution-consistency-in-module-tree-inline-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/not-overridden/dynamic-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/not-overridden/external-script-descendent-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/not-overridden/failed-resolution-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/not-overridden/prefix-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/not-overridden/script-descendent-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/not-overridden/url-resolution-conflict-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/import-maps/w3c-import.log:
* Source/JavaScriptCore/builtins/BuiltinNames.h: remove importMapStatus
  promise.
* Source/JavaScriptCore/builtins/ModuleLoader.js: remove importMapStatus
  promise.
(visibility.PrivateRecursive.async loadModule):
(visibility.PrivateRecursive.async loadAndEvaluateModule):
(visibility.PrivateRecursive.async requestImportModule):
* Source/JavaScriptCore/bytecode/LinkTimeConstant.h: remove
  importMapStatus promise.
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp: remove
  importMapStatus promise.
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildrenImpl):
(JSC::JSGlobalObject::setPendingImportMaps): Deleted.
(JSC::JSGlobalObject::clearPendingImportMaps): Deleted.
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::importMap):
(JSC::JSGlobalObject::importMapStatusPromise const): Deleted.
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp: remove
  importMapStatus promise.
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h:
* Source/WebCore/Sources.txt: remove LoadableImportMap
* Source/WebCore/WebCore.xcodeproj/project.pbxproj: remove
  LoadableImportMap
* Source/WebCore/bindings/js/ScriptController.cpp: remove
  pendingImportMap logic
(WebCore::ScriptController::registerImportMap):
(WebCore::ScriptController::setPendingImportMaps): Deleted.
(WebCore::ScriptController::clearPendingImportMaps): Deleted.
* Source/WebCore/bindings/js/ScriptController.h:
* Source/WebCore/dom/LoadableClassicScript.cpp:
* Source/WebCore/dom/LoadableImportMap.cpp: Removed.
* Source/WebCore/dom/LoadableImportMap.h: Removed.
* Source/WebCore/dom/ScriptElement.cpp:
(WebCore::ScriptElement::prepareScript): Fire an error event if
an importmap script has a source.
(WebCore::ScriptElement::registerImportMap): remove
  pendingImportMap logic
(WebCore::ScriptElement::executePendingScript): remove
  pendingImportMap and loadableImportMap logic
(WebCore::ScriptElement::requestImportMap): Deleted.
* Source/WebCore/dom/ScriptElement.h: Remove `requestImportMap`.
yoavweiss added a commit to yoavweiss/WebKit that referenced this issue Dec 10, 2024
https://bugs.webkit.org/show_bug.cgi?id=284286

Reviewed by NOBODY (OOPS!).

This PR removes support for external import maps and ensures they throw an
error instead. That would align WebKit's behavior with the HTML standard
and other browsers.

It also imports a new WPT test that validates the standard requirement
this fixes, as well as adjusts relevant WPT results. This adjustment
results in some progressions and some regressions. The regressions would
be fixed as part of
WebKit/standards-positions#381.

Upstream commit: web-platform-tests/wpt@ef41368

* LayoutTests/imported/w3c/web-platform-tests/import-maps/external-import-map-errors-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/import-maps/external-import-map-errors.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/import-maps/w3c-import.log:
* Source/WebCore/Sources.txt: remove LoadableImportMap
* Source/WebCore/WebCore.xcodeproj/project.pbxproj: remove LoadableImportMap
* Source/WebCore/dom/LoadableClassicScript.cpp: remove LoadableImportMap
  logic
* Source/WebCore/dom/LoadableImportMap.cpp: Removed.
* Source/WebCore/dom/LoadableImportMap.h: Removed.
(WebCore::ScriptElement::prepareScript): Fire an error event if
an importmap script has a source.
(WebCore::ScriptElement::executePendingScript): remove
  loadableImportMap logic
(WebCore::ScriptElement::requestImportMap): Deleted.
* Source/WebCore/dom/ScriptElement.h: Remove `requestImportMap`.
webkit-commit-queue pushed a commit to yoavweiss/WebKit that referenced this issue Dec 12, 2024
https://bugs.webkit.org/show_bug.cgi?id=284286

Reviewed by Yusuke Suzuki.

This PR removes support for external import maps and ensures they throw an
error instead. That would align WebKit's behavior with the HTML standard
and other browsers.

It also imports a new WPT test that validates the standard requirement
this fixes, as well as adjusts relevant WPT results. This adjustment
results in some progressions and some regressions. The regressions would
be fixed as part of
WebKit/standards-positions#381.

Upstream commit: web-platform-tests/wpt@ef41368

* LayoutTests/imported/w3c/web-platform-tests/import-maps/external-import-map-errors-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/import-maps/external-import-map-errors.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/import-maps/w3c-import.log:
* Source/WebCore/Sources.txt: remove LoadableImportMap
* Source/WebCore/WebCore.xcodeproj/project.pbxproj: remove LoadableImportMap
* Source/WebCore/dom/LoadableClassicScript.cpp: remove LoadableImportMap
  logic
* Source/WebCore/dom/LoadableImportMap.cpp: Removed.
* Source/WebCore/dom/LoadableImportMap.h: Removed.
(WebCore::ScriptElement::prepareScript): Fire an error event if
an importmap script has a source.
(WebCore::ScriptElement::executePendingScript): remove
  loadableImportMap logic
(WebCore::ScriptElement::requestImportMap): Deleted.
* Source/WebCore/dom/ScriptElement.h: Remove `requestImportMap`.

Canonical link: https://commits.webkit.org/287725@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from: other Proposed, edited, or co-edited by an individual or entity that doesn't have a more specific label. position: support topic: html Spec relates to HTML (Hypertext Markup Language) topic: javascript Spec relates to the JavaScript programming language venue: WHATWG HTML Workstream
Projects
None yet
Development

No branches or pull requests

3 participants