tc39 / proposal-import-attributes

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

Allow `type` in the cache key, and only pass that to the host #127

Closed nicolo-ribaudo closed 1 year ago

nicolo-ribaudo commented 1 year ago

This PR:

This is a draft. Please don't focus on the exact syntax, but on the general idea.

Ref https://github.com/whatwg/html/issues/7233, https://gist.github.com/peetklecha/a55532165dbd4905aa91bbe59e8b1001

Preview: https://raw.githack.com/nicolo-ribaudo/proposal-import-assertions/attributes/dist/index.html

aduh95 commented 1 year ago

The Node.js TSC has discussed the recent change of import assertions from stage 3 to 2. We support TC39’s efforts to improve this proposal, and we want to communicate that we agree with the Chromium/V8 team that our preference would be that the syntax not change. Import assertions have been unflagged in Node.js for over a year, including in our LTS release lines (16.x and 18.x), and it would be a disruptive change for our users to reflag the feature. Lacking some indication whether the current syntax will remain unchanged, we plan to resume requiring a runtime flag for using import assertions in Node.js 20.0.0; we would need to make that decision by April 1st. We expect this move to be quite breaking for some of our users. Would it be possible for the TC39 to communicate a (hopefully final) decision regarding the syntax during the March meeting?

guybedford commented 1 year ago

After some discussion I'm also starting to come around on the compat argument brought up by @aduh95 in retaining the syntax. That we have a year of unflagged usage in Node.js and Deno is certainly a strong consideration to make.

Regarding this spec change in particular, I was wondering if rather than specializing on the "type", it would be beneficial to treat the local linkage as keyed by the exact attributes list for now. Just like a relative and absolute URL can have two key entries pointing to the same module, it would still be possible to share instances via host-level deduping. This would at least set up a framework for other types to be able to support unique reinstancing as required.

nicolo-ribaudo commented 1 year ago

@aduh95 I will present #131 in the March meeting. While the preference of the champions is to migrate from assert to with, there are different possible final outcomes:

(I can't post this in nodejs/node#46830, feel free to copy it if you want!)

nicolo-ribaudo commented 1 year ago

Closing in favor of #131