Add import assertions
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
"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.
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!
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.)
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?
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.
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
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?
@queengooborg ^^^ Could you please propose fixes as suggestions to unblock this?
I have proposed a solution already, actually -- see https://github.com/mdn/browser-compat-data/pull/17366#issuecomment-1214894126!
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...
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!