Repository navigation
Re-flag assert syntax for import attributes in Node.js 22 #51622
Description
Activity
- addedfeature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Jan 31, 2024 One year ago in #46830 there was a lot of support from TSC members to re-flag this syntax
To be clear, #46830 is about re-flagging the JSON modules implementation (which was downgraded from stage 3 to stage 2 by TC39 when that issue was opened), not the
assertsyntax (which is almost the same thing, because JSON modules are the only supported use case for import assertions/attributes atm).
Because the TC39 went back to stage 3, nothing was re-flagged.
Support for the newer syntax (usingwith) has since landed on 20.x+, and the current plan is to keep theassertsyntax around until v18.x reaches EOL – the last non-EOL version of Node.js which currently does not support the newer syntax.A few things to consider:
- If we introduced a new flag, it likely won't be backported to v18.x, which is in maintenance mode.
- We don't want folks to use harmony V8 flags.
- We could consider re-introduce the
--experimental-json-modulesto gatekeep the support forassert, and folks who want to support both Node.js 18.x and 22.x would need to pass that flag. Technically very easy to implement, however a bit hard to document. - Node.js 18.x EOL is scheduled for 2025-04-30 (circa Node.js 24.x release date).
- If V8 drops support for
assert, we could still float a patch to keep supporting it, although we probably want to avoid that if we can.
Our options seem to be:
- Keep supporting
assertsyntax unflagged until Node.js 24.x (likely we need to float a V8 patch for Node.js 23.x) - Drop support for
assertin 22.x. Folks who use JSON modules and want to support both 18.x and 22.x must use a harmony flag. Likely it won't be possible for them to support both 18.x and 23.x. - Put
assertsyntax support behind--experimental-json-modules. (we might still need to float a V8 patch for 23.x, or drop support for it).
@nodejs/tsc wdyt?
FWIW I'm open to landing #51136 on v18.x if it makes it easier to migrate to the newer syntax. cc @nodejs/lts
Reacted by dnalborczyk, Antoine du Hamel and Sindre SorhusReacted by Nicolò RibaudoReacted by dnalborczykJust to be clear, I assume you’re proposing flagging
assertsyntax but notwithsyntax, correct? We shouldn’t be flagging the latter.I don’t see much point in flagging something that is going to be removed. We should add a deprecation warning and then just remove it in a semver-major. I would even go so far as to aim to remove
assertin 22 unless there’s some reason we need to wait for 23. It’s never graduated to stable, despite being unflagged, so I don’t think it needs a full deprecation cycle.Reacted by Ruy Adorno and dnalborczykI would suggest to just remove support for assert in the next semver major. I don't really see the point floating a V8 patch like this when the proposal itself has already shifted direction (I don't quite understand why we were unflagging it when V8 had not shipped it in the first place TBH).
I think removing it in 22 is the best course of action.
- addedrelease-agendaIssues and PRs to discuss during Release team meetings.Issues and PRs to discuss during Release team meetings.
on Feb 2, 2024 Adding the release-agenda
Issues and PRs to discuss during Release team meetings. label as my position would depend on the decision of the LTS team regarding #51622 (comment).Hey just checking what's the current expectation on this, given that Node.js 22 is coming in just one month. I can open a PR to re-flag (or remove?) it, but maybe #51631 should first be released in 21 and 20?
I vote for removing
assertin 22 and adding a warning for all previous lines. What do others think?And
withwould be unflagged.Note that
withis already unflagged in 20 and 21 (and in 18 right now it just doesn't exist, not even behind a flag).Reacted by Geoffrey BoothNote that
withis already unflagged in 20 and 21 (and in 18 right now it just doesn't exist, not even behind a flag).Reacted by Nicolò Ribaudo7 remaining items
- added a commit that references this issue
on May 2, 2024 Did anyone consider that v18 is in maintenance for another year? We've got no path forward to support v18.x (less than 18.20.0) as well as v22 due to this change. Bananas.
Its the latest version of v18 that is still supported for one year, and not versions below v18.20.
v18.19 is getting no security fixes, for example.
@nicolo-ribaudo there are environments where that version is pinned and we have to support them. this effectively backported a breaking change to an older version.
this effectively backported a breaking change to an older version.
A breaking change on a feature that was logging on your terminal "Warning: it might change at any time" in red every time you used it in any meaningful way 😅
I don't think that language nor the emoji was necessary; I have not been disrespectful and am disappointed you've chosen to be. The project has consistently set reasonable expectations for experimental and deprecated features, and that expectation has been broken in this instance.
Did anyone consider that v18 is in maintenance for another year?
Obviously we did, you can read that in that very thread, and that's also why we spent time backporting support for
withto v18.x branch.We've got no path forward to support v18.x (less than 18.20.0) as well as v22 due to this change.
The only choice you have is either to drop support for Node.js <18.20 (recommended, as said above those do not receive security patches), or to build you own binaries including the commits for the new syntax support. I guess I'm not telling anything you don't already know though
I don't think that language nor the emoji was necessary; I have not been disrespectful and am disappointed you've chosen to be.
I'm not sure what language you found disrespectful, I personally interpret the tone of Nicolò's comments as friendly. Anyway, commenting on each other supposed intent is unlikely to result in a productive discussion, so let's not.
The project has consistently set reasonable expectations for experimental and deprecated features, and that expectation has been broken in this instance.
TBH we should probably break this more often for experimental features, having folks relying on experimental features, and complaining when it breaks (despite being clearly documented as "can break at any time") is such a pain. I very much disagree that "support until the end of maintenance cycle" is a reasonable expectation for experimental feature.
- added a commit that references this issue
on Dec 1, 2024 - added 3 commits that reference this issue
on Dec 4, 2024 - added a commit that references this issue
on Dec 9, 2024 - added a commit that references this issue
on Dec 9, 2024
What is the problem this feature will solve?
The
assertsyntax has been replaced bywith, and it's currently only shipped by Chrome and Node.js. Other browsers will only ship thewithsyntax.Chrome will ship
withunflagged in 123, and is planning to remove support forassertin 126: https://v8.dev/features/import-attributes#deprecation-and-eventual-removal-of-assert. According to https://chromiumdash.appspot.com/schedule, Chrome 126 will be released in May.What is the feature you are proposing to solve the problem?
One year ago in #46830 there was a lot of support from TSC members to re-flag this syntax, but then nothing has been done. Node.js 22, which will be released in April, would be a good release to put
assertback behind a flag.What alternatives have you considered?
[node: I'm opening a new issue rather than commenting in #46830 because it was meant to be a place of discussion for Node.js collaborators, and as such it's locked]