browser-compat-data icon indicating copy to clipboard operation
browser-compat-data copied to clipboard

Add import assertions

Open Josh-Cena opened this issue 3 years ago • 6 comments

Summary

Fix https://github.com/mdn/browser-compat-data/issues/14052, part of https://github.com/mdn/content/issues/19220

First time doing actual compat data changes... I don't really know how this ought to be done. I don't know if this addresses https://github.com/mdn/browser-compat-data/issues/14053 either.

Test results and supporting details

See https://v8.dev/features/import-assertions

Node versions are hand-tested.

Related issues

Josh-Cena avatar Aug 15 '22 08:08 Josh-Cena

"16.14.0" is NOT a valid version number for nodejs

Okay that looks hilarious...

Also, I'm pretty confident it should be called experimental, since we only have V8 support.

Josh-Cena avatar Aug 15 '22 10:08 Josh-Cena

Experimental set to true sounds good to me!

I've opened up https://github.com/mdn/browser-compat-data/pull/17367 to add v16.14.0 to the browser data, and will merge that promptly so this PR passes!

queengooborg avatar Aug 15 '22 10:08 queengooborg

It's complicated for JSON modules. IIRC it's unflagged in 17.5, but backported to 16.15. I don't think we've reached resolution on what to do in that case—do we? I also don't plan to address https://github.com/mdn/browser-compat-data/issues/14053 — just focusing on the syntax in this PR. JSON modules would also involve web API I think. (Again it's complicated.)

Josh-Cena avatar Aug 15 '22 11:08 Josh-Cena

In a case like that, I'd say that we should do the following:

[
  {
    "version_added": "17.5.0"
  },
  {
    "version_added": "16.15.0",
    "version_removed": "17.0.0"
  },
  {
    "version_added": "17.0.0",
    "version_removed": "17.5.0",
    "flags": [
      {
        "type": "runtime_flag",
        "name": "--experimental-json-modules"
      }
    ]
  },
  {
    "version_added": "16.0.0",
    "version_removed": "16.15.0",
    "flags": [
      {
        "type": "runtime_flag",
        "name": "--experimental-json-modules"
      }
    ]
  }
]

It's kind of messy, especially with the flag data, but it's the best we can do with Node's LTS release cycle. WDYT?

queengooborg avatar Aug 15 '22 11:08 queengooborg

This problem is kind of non-unique—also present in https://github.com/mdn/browser-compat-data/issues/15123.

Also, do you want to me to do the --experimental-json-modules flag in this PR as well? Frankly I didn't check that. In fact JSON modules and import assertions are two separate things: the latter is merely syntax. I only included a "partial implementation" note about JSON modules in Node for convenience.

Josh-Cena avatar Aug 15 '22 11:08 Josh-Cena

Yeah, it's an ugly solution, but I feel it is a necessary one due to how NodeJS' release cycle works. On the plus side, doing this allows us to better represent exactly which versions support the feature!

As for the flag, if you're down to incorporate it, that would be great! Otherwise, no big deal; flags quickly become useless to document once they're no longer needed for a feature. ;P

queengooborg avatar Aug 20 '22 10:08 queengooborg

Sorry @queengooborg I think I'm a bit lost on this. Could you update the PR in the way you want (or in the form of a suggestion) so we can get to merge this?

Josh-Cena avatar Oct 31 '22 06:10 Josh-Cena

@queengooborg ^^^ Could you please propose fixes as suggestions to unblock this?

hamishwillee avatar Nov 06 '22 23:11 hamishwillee

I have proposed a solution already, actually -- see https://github.com/mdn/browser-compat-data/pull/17366#issuecomment-1214894126!

queengooborg avatar Nov 06 '22 23:11 queengooborg

The flags data for Node is a bit of a mess—there are two flags: --harmony-import-assertions and --experimental-json-modules. The first one enables the parser feature, the second one makes assert { type: "json" } actually "work" (turns on the JSON loader). I don't really know what to do here...

Josh-Cena avatar Nov 07 '22 00:11 Josh-Cena

I went ahead and pushed the changes I'm looking to see to reduce the back-and-forth and to help get this merged quicker!

queengooborg avatar Nov 22 '22 13:11 queengooborg