content
content copied to clipboard
Document import assertions
Summary
Motivation
Fix #19220
Supporting details
Related issues
Metadata
- [x] Adds a new document
- [ ] Rewrites (or significantly expands) a document
- [ ] Fixes a typo, bug, or other error
Pending: some more sources to the HTML specification, especially around JSON modules. I don't know the HTML spec that well.
BCD: https://github.com/mdn/browser-compat-data/pull/17366
Preview URLs (6 pages)
- /en-US/docs/Web/JavaScript/Reference/Lexical_grammar
- /en-US/docs/Web/JavaScript/Reference/Operators/import
- /en-US/docs/Web/JavaScript/Reference/Statements/export
- /en-US/docs/Web/JavaScript/Reference/Statements/import/assert
- /en-US/docs/Web/JavaScript/Reference/Statements/import
- /en-US/docs/Web/JavaScript/Reference/Trailing_commas
External URLs (3)
URL: /en-US/docs/Web/JavaScript/Reference/Statements/import/assert
Title: Import assertion
- https://github.com/tc39/proposal-import-assertions (1 time) (Note! This may be a new URL 👀)
- https://github.com/tc39/proposal-json-modules (1 time) (Note! This may be a new URL 👀)
- https://html.spec.whatwg.org/multipage/webappapis.html (1 time) (Note! This may be a new URL 👀)
(comment last updated: 2023-05-20 00:14:49)
cc @jpmedley in case this needs some attention from V8 folks since they are the only ones implementing this so far.
I'm not up to speed on this. I've asked my team for help.
Let's still see if someone from Google (or from Mozilla!) can get to look at this.
@teoli2003 @wbamberg Can we get a review on this?
If desired I can comment on whether it makes sense to me, but not on whether it is correct/complete.
@hamishwillee I'd very appreciate it if you can comment on whether it makes sense, from the perspective of a reader 😄
This is hard to get right... I spent a few months wrapping my head around this feature until it clicked.
Import assertions got downgraded to stage 2 due to https://github.com/tc39/proposal-import-assertions/issues/125. I guess that gives us some more time before documentation because it won't be implemented by other engines anyway.
Import assertions got downgraded to stage 2 due to https://github.com/tc39/proposal-import-assertions/issues/125. I guess that gives us some more time before documentation because it won't be implemented by other engines anyway.
Do we need to do any intermediate "fix up"? My initial thinking was no, since the BCD says "non standard" so people should be using with care anyway. But on reflection, it is perhaps worth adding a note to chrome 91 BCD (i.e. to both the import assertion lines shown here to note that this was downgraded and likely to change.
Why? Because presumably at some point this will standardize, and that that point we'll need to do something to indicate that this older version is not the same version as the standard. Having a note now might help make this clear later.
Up to you.
If it's shipped in one browser and noted as an experimental feature, I don't think we need any immediate fixup since things are expected to change anyway. It's lucky we don't have content yet. We can watch until a good alternative has been proposed.
This feature is now called "import-attributes" and the assertion invariant has been removed. The new keyword is with instead of assert. This PR would be on hold until new implementations land.
Instead of letting this PR sit around forever, I'm going to close this and open a new PR when the new syntax and semantics get shipped in browsers. There will be significant changes from the currently documented behavior.