Skip to content
This repository has been archived by the owner on Feb 26, 2025. It is now read-only.

Having import attributes in mind? #299

Closed
shaedrich opened this issue Nov 25, 2024 · 2 comments
Closed

Having import attributes in mind? #299

shaedrich opened this issue Nov 25, 2024 · 2 comments

Comments

@shaedrich
Copy link

shaedrich commented Nov 25, 2024

The ECMAScript import attributes proposal will allow JS to import MIME types other than JS files. There are also several other proposals (for example, compartments, parser augmentation, etc.) that try to add similar functionality to the JS ecosystem

All proposed metadata so far is applicable to any sort of resource, not just JavaScript modules. A solution should probably work at a more general level.
README.md

Adding .js to every import is redundant. Can this feature cover a simple way to automatically make it so all extension-less specifiers use .js?
@trusktr in #7

Will this be kept in mind for this proposal or is this currently out of scope?

@ljharb
Copy link

ljharb commented Nov 25, 2024

The proposal doesn't directly allow that - it allows the syntax, such that hosts (like web browsers) can choose to leverage it to add other mime types.

As for specifiers, on the web, all specifiers are opaque URLs, and "extensions" don't exist - meaning, it's up to the web server how it interprets the specifier, including whether it decides that the characters following the last . determine the MIME type.

@shaedrich
Copy link
Author

Ah, okay. So it will be implicitly possible once the other proposals are implemented, yet not explicitly formalized since this is not the goal of the proposal. Got it 👍🏻 Thanks for the clarification

@domenic domenic closed this as completed Feb 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants