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

Add import attributes feature post #729

Merged
merged 3 commits into from
Jan 31, 2024
Merged

Add import attributes feature post #729

merged 3 commits into from
Jan 31, 2024

Conversation

syg
Copy link
Contributor

@syg syg commented Jan 30, 2024

No description provided.

@syg syg requested a review from dtig January 30, 2024 21:46
@syg
Copy link
Contributor Author

syg commented Jan 30, 2024

@rmahdav PTAL. We should publish this ASAP so we have something to point to for the deprecation of the assert syntax.

@dtig for lgtm stamp since @rmahdav isn't on the V8 Core GH team yet.

@syg
Copy link
Contributor Author

syg commented Jan 30, 2024

Also @nicolo-ribaudo PTAL if you have some time.

src/features/import-attributes.md Outdated Show resolved Hide resolved
src/features/import-attributes.md Outdated Show resolved Hide resolved
@rmahdav
Copy link
Contributor

rmahdav commented Jan 31, 2024

@syg Thanks for the post. It looks good to me.


Since then, import assertions has evolved into [import attributes](https://github.com/tc39/proposal-import-attributes). The point of the feature remains the same: to allow module import statements to include additional information.

The most important difference is that import assertions had assert-only semantics, while import attributes has more relaxed semantics. Assert-only semantics means that the additional information as part no effect on _how_ a module is loaded, only on _whether_ it is loaded. For example, a JSON module is always loaded as JSON module by virtue of its MIME type, and the `assert { type: 'json' }` clause can cause loading to fail if the requested module's MIME type is not `application/json`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The most important difference is that import assertions had assert-only semantics, while import attributes has more relaxed semantics. Assert-only semantics means that the additional information as part no effect on _how_ a module is loaded, only on _whether_ it is loaded. For example, a JSON module is always loaded as JSON module by virtue of its MIME type, and the `assert { type: 'json' }` clause can cause loading to fail if the requested module's MIME type is not `application/json`.
The most important difference is that import assertions had assert-only semantics, while import attributes has more relaxed semantics. Assert-only semantics means that the additional information as part no effect on _how_ a module is loaded, only on _whether_ it can be executed. For example, a JSON module is always loaded as JSON module by virtue of its MIME type, and the `assert { type: 'json' }` clause can cause loading to fail if the requested module's MIME type is not `application/json`.

Nit, but with assertions even when the module was loaded before checking the assertion, and the assertion only prevented it from being actually "executed" (if we can call execution the conversion of JSON/CSS files into JS values)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to leave this as is. That level of understanding of "loaded" is not what's intended here, and I think using "executed" in the context of a JSON module, which developers would think of as data instead of code, would be more confusing.

src/features/import-attributes.md Outdated Show resolved Hide resolved
src/features/import-attributes.md Outdated Show resolved Hide resolved
@syg syg merged commit 3537541 into v8:main Jan 31, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants