tc39 / proposal-import-attributes

Proposal for syntax to import ES modules with assertions
https://tc39.es/proposal-import-attributes/
Apache License 2.0
586 stars 26 forks source link

Tracking feasibility of unshipping `assert` contextual keyword in Chrome #135

Closed syg closed 2 months ago

syg commented 1 year ago

Chrome has landed use counters tracking the use of the deprecated assert contextual keyword in import attributes.

This will go to stable in 114, which is scheduled for May 30, 2023. We will need some time after the counter reaches the stable population to gather numbers.

nicolo-ribaudo commented 1 year ago

Usage stats: https://chromestatus.com/metrics/feature/timeline/popularity/4528 (⚠️ as mentioned above, the number is so close to zero just because the counter is not in stable yet)

nicolo-ribaudo commented 1 year ago

I was exploring Chrome use counters, and I found counters for JSON modules (https://chromestatus.com/metrics/feature/timeline/popularity/3804 - 0.012% of page loads) and CSS modules (https://chromestatus.com/metrics/feature/timeline/popularity/3805 - 0.000061% of page loads). I don't think it's unreasonable to expect the usage of import assertions to roughly match the usage of JSON modules.

I manually checked some of the sample URLs, and all the usages I found (using the assert[:{ ] regexp on their code) are from https://github.com/guybedford/es-module-shims/blob/main/src/features.js, which try/catches around evaluating CSS/JSON modules with import assertions to detect if they are supported and thus if they need to be polyfilled. Removing support for assert would cause the polyfill to kick in, and to restore such support in websites that rely on it.

guybedford commented 1 year ago

Note that es-module-shims does not by default engage the JSON / CSS modules feature detection path at all in polyfill mode, unless it is explicitly enabled via https://github.com/guybedford/es-module-shims#pollyfill-enable-option, which I'd expect would be a very small percentage of es-module-shims users.

nicolo-ribaudo commented 1 year ago

Going back to https://github.com/tc39/proposal-import-attributes/issues/135#issuecomment-1537367056 again, it looks like many of the usages of CSS/JSON modules are from v0.13.1 of es-modules-shims, that performs feature-detection even if then they are not used.

syg commented 1 year ago

There are now some URLs at the bottom of https://chromestatus.com/metrics/feature/timeline/popularity/4528 now, if you want to take a look again @nicolo-ribaudo.

nicolo-ribaudo commented 1 year ago

Thank you!

Some preliminary analysis of the the first websites listed there (I only checked the homepage), searching with the assert[ /{] regex:

Overall, it looks like most those website have been designed to fail gracefully in browsers without import assertions support, so that they keep working just with (sometimes) one specific feature unavailable.

nicolo-ribaudo commented 1 year ago
image

Looking good :)

syg commented 8 months ago

V8 has landed a CL that will warn on assert usage, recommending to use with instead. The plan is to remove assert support by 12.6, which will be stable by mid-June, 2024.

Edit: I should say the plan is, barring new data, like newly discovered incompat.