Intent to Prototype: Deprecate and remove import assertion 'assert' syntax

1,393 views
Skip to first unread message

Shu-yu Guo

unread,
Nov 15, 2023, 4:39:53 PM11/15/23
to blink-dev

Contact emails

s...@chromium.orgnrib...@igalia.com

Explainer

None

Specification

https://tc39.es/proposal-import-attributes

Summary

TC39 has consensus for trying to deprecate and remove the `assert` keyword in favor of the new `with` keyword in import attribute syntax. That is, `import m from 'foo' assert { type: 'json' }` will now throw a SyntaxError, and developers must change to `import m from 'foo' with { type: 'json' }`. https://github.com/tc39/proposal-import-attributes/issues/135



Blink component

Blink>JavaScript>Language

Motivation

The import assertions proposal (now called "import attributes") [1] in TC39 shipped in M91 with the `import mod from 'foo' assert { type: 'json' }` syntax. The original semantics was that additional information following the `assert` keyword cannot cause the module to be reinterpreted or change the semantics of the module in any way, i.e., a pure assertion. Following an HTML integration issue with CSP [2] that required changing Accept headers depending on the requested module type, TC39 reached consensus that the "pure assertion" semantics are to be relaxed to allow reinterpretation, and that the `assert` keyword be changed to `with` to reflect the new semantics. [1] https://github.com/tc39/proposal-import-attributes/ [2] https://github.com/whatwg/html/issues/7233



Initial public proposal

None

TAG review

None

TAG review status

Not applicable

Risks



Interoperability and Compatibility

There is no interoperability risk because Safari and Firefox never shipped the `assert` syntax. There is compatibility risk within Chrome as we shipped in M91.



Gecko: N/A

WebKit: N/A

Web developers: No signals

Other signals:

Ergonomics

None.



Activation

None.



Security

None.



WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Debuggability

None.



Is this feature fully tested by web-platform-tests?

In test262

Flag name on chrome://flags

--harmony-import-assertions

Finch feature name

None

Non-finch justification

Use counter metric shows current usage at 0.0002% https://chromestatus.com/metrics/feature/timeline/popularity/4528 Additionally, analysis shows that sites that do use it have fallbacks: https://github.com/tc39/proposal-import-attributes/issues/135#issuecomment-1625217926 This data suggests that a finch trial is not needed, and a clean removal is possible.



Requires code in //chrome?

False

Estimated milestones

No milestones specified



Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/4689167795879936

This intent message was generated by Chrome Platform Status.

Mike Taylor

unread,
Nov 22, 2023, 2:03:20 PM11/22/23
to Shu-yu Guo, blink-dev

[noting that the subject is a typo, hence my edit in the subject line]

On 11/15/23 4:39 PM, Shu-yu Guo wrote:

Contact emails

s...@chromium.orgnrib...@igalia.com

Explainer

None

Specification

https://tc39.es/proposal-import-attributes

Summary

TC39 has consensus for trying to deprecate and remove the `assert` keyword in favor of the new `with` keyword in import attribute syntax. That is, `import m from 'foo' assert { type: 'json' }` will now throw a SyntaxError, and developers must change to `import m from 'foo' with { type: 'json' }`. https://github.com/tc39/proposal-import-attributes/issues/135



Blink component

Blink>JavaScript>Language

Motivation

The import assertions proposal (now called "import attributes") [1] in TC39 shipped in M91 with the `import mod from 'foo' assert { type: 'json' }` syntax. The original semantics was that additional information following the `assert` keyword cannot cause the module to be reinterpreted or change the semantics of the module in any way, i.e., a pure assertion. Following an HTML integration issue with CSP [2] that required changing Accept headers depending on the requested module type, TC39 reached consensus that the "pure assertion" semantics are to be relaxed to allow reinterpretation, and that the `assert` keyword be changed to `with` to reflect the new semantics. [1] https://github.com/tc39/proposal-import-attributes/ [2] https://github.com/whatwg/html/issues/7233



Initial public proposal

None

TAG review

None

TAG review status

Not applicable

Risks



Interoperability and Compatibility

There is no interoperability risk because Safari and Firefox never shipped the `assert` syntax. There is compatibility risk within Chrome as we shipped in M91.



Gecko: N/A

WebKit: N/A
Obviously less problematic for Gecko and WebKit, but do we know of any plans they have to implement?


Web developers: No signals

Other signals:

Ergonomics

None.



Activation

None.



Security

None.



WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Debuggability

None.



Is this feature fully tested by web-platform-tests?

In test262

Flag name on chrome://flags

--harmony-import-assertions

Finch feature name

None

Non-finch justification

Use counter metric shows current usage at 0.0002% https://chromestatus.com/metrics/feature/timeline/popularity/4528 Additionally, analysis shows that sites that do use it have fallbacks: https://github.com/tc39/proposal-import-attributes/issues/135#issuecomment-1625217926 This data suggests that a finch trial is not needed, and a clean removal is possible.

Thanks for the analysis! From the 14 sites that were looked at we have:

Minor breakage:

Major breakage: 

  • classlocator.live: search stop working. Given the whole point of the site is to search for classes... we might categorize as Severe breakage.
  • labdash.net: a map of testing locations doesn't work. Seem not great.
  • secure.labdash.net: same as above

No breakage: the rest of the 7 out of 14.

Even thought the use counter is quite small, the breakage doesn't seem insignificant (even if the sites area already busted in Firefox or Safari).

Have you thought about a deprecation period, with some developer-facing comms or DevTools issue? Not sure that outreach is the right option, but something else to consider.



Requires code in //chrome?

False

Estimated milestones

No milestones specified



Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/4689167795879936

This intent message was generated by Chrome Platform Status.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAN-e9e_cMbiPO2AhV%3D%3DP_r%3Dov%2BKvxyXqkyosej9a%3DuJO7zt5_Q%40mail.gmail.com.

Shu-yu Guo

unread,
Nov 22, 2023, 2:40:44 PM11/22/23
to Mike Taylor, blink-dev
Thank you for the review. Replies inline below.

The alternate `with` syntax is Stage 3 in TC39, so Mozilla and Apple have agreed to implement it.

I have thought, given the use counter, a deprecation period would be unnecessary, but I admit to not fully understanding the calculus. I am supportive of a deprecation period of 3 releases, a v8.dev blog post, and a DevTools warning.

Mike Taylor

unread,
Nov 22, 2023, 3:50:46 PM11/22/23
to Shu-yu Guo, blink-dev

LGTM to deprecate for 3 milestones, with some outreach efforts as outlined below.

Can you come back and report then to request re-review? You'll need 3 LGTMs to actually remove, but for now you're good w/ the deprecation. Good luck on getting the message out!

Chris Harrelson

unread,
Dec 6, 2023, 11:44:12 AM12/6/23
to Mike Taylor, Shu-yu Guo, blink-dev
I'm good with what Mike said. Shu, does this plan sound ok to you?

Shu-yu Guo

unread,
Dec 6, 2023, 11:53:11 AM12/6/23
to Chris Harrelson, Mike Taylor, blink-dev
Mike's plan sgtm. I'm also currently holding off starting the deprecation period until we ship the replacement `with` syntax, so that there is a ready-to-use replacement during the deprecation period for affected sites.

Rick Byers

unread,
Dec 7, 2023, 10:27:16 AM12/7/23
to Shu-yu Guo, Chris Harrelson, Mike Taylor, blink-dev
Thank you for not doing the "the old thing is deprecated, the new thing isn't ready yet" thing 😂. Your deprecation warning should also link to the chromestatus entry, which I think explains the situation pretty clearly. So hopefully that's enough to make it trivial for developers to know how to fix the warning? Often we also do a blog post, but perhaps this case is sufficiently trivial that the chromestatus entry alone is sufficient?

Rick

Philip Jägenstedt

unread,
Dec 13, 2023, 12:03:37 PM12/13/23
to Rick Byers, Shu-yu Guo, Chris Harrelson, Mike Taylor, blink-dev
LGTM2 for Mike's plan of deprecating for 3 milestones, doing outreach, and then revisiting this thread.

If we still know of serious breakage after this, is it an option to simply support both keywords indefinitely, but treat `assert` as legacy? Documentation, linters and autoformatters could all direct developers to `with`, without breaking any existing sites.

Shu-yu Guo

unread,
Dec 13, 2023, 12:10:38 PM12/13/23
to Philip Jägenstedt, Rick Byers, Chris Harrelson, Mike Taylor, blink-dev
On Wed, Dec 13, 2023 at 9:03 AM Philip Jägenstedt <foo...@chromium.org> wrote:
LGTM2 for Mike's plan of deprecating for 3 milestones, doing outreach, and then revisiting this thread.

If we still know of serious breakage after this, is it an option to simply support both keywords indefinitely, but treat `assert` as legacy? Documentation, linters and autoformatters could all direct developers to `with`, without breaking any existing sites.

Yes, it is an option to support both keywords indefinitely and treat `assert` as legacy. TC39 consensus includes `assert` legacy support, on account of Chrome having shipped in good faith. We're trying to remove it for maximal interop since no other browsers shipped `assert`, but if it's not feasible it will not be a willful violation of spec to continue shipping it.

Philip Jägenstedt

unread,
Dec 14, 2023, 4:18:57 AM12/14/23
to Shu-yu Guo, Rick Byers, Chris Harrelson, Mike Taylor, blink-dev
On Wed, Dec 13, 2023 at 6:10 PM Shu-yu Guo <s...@chromium.org> wrote:
On Wed, Dec 13, 2023 at 9:03 AM Philip Jägenstedt <foo...@chromium.org> wrote:
LGTM2 for Mike's plan of deprecating for 3 milestones, doing outreach, and then revisiting this thread.

If we still know of serious breakage after this, is it an option to simply support both keywords indefinitely, but treat `assert` as legacy? Documentation, linters and autoformatters could all direct developers to `with`, without breaking any existing sites.

Yes, it is an option to support both keywords indefinitely and treat `assert` as legacy. TC39 consensus includes `assert` legacy support, on account of Chrome having shipped in good faith. We're trying to remove it for maximal interop since no other browsers shipped `assert`, but if it's not feasible it will not be a willful violation of spec to continue shipping it.

I see, thank you for clarifying. Looking forward to seeing what the deprecation and outreach result in.

Daniel Bratell

unread,
Dec 20, 2023, 11:42:53 AM12/20/23
to Philip Jägenstedt, Shu-yu Guo, Rick Byers, Chris Harrelson, Mike Taylor, blink-dev

LGTM3 for the plan as outlined by Mike and Philip.

/Daniel

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Anton Bershanskyi

unread,
Jan 28, 2024, 8:58:34 AMJan 28
to blink-dev, Daniel Bratell, Rick Byers, Chris Harrelson, Mike Taylor, blink-dev, Philip Jägenstedt, Shu-yu Guo
For the record, relevant V8 commit landed with removal planned for V8 12.6.[1]

Reply all
Reply to author
Forward
0 new messages