Skip to content

Re-flag assert syntax for import attributes in Node.js 22 #51622

Description

@nicolo-ribaudo

What is the problem this feature will solve?

The assert syntax has been replaced by with, and it's currently only shipped by Chrome and Node.js. Other browsers will only ship the with syntax.

Chrome will ship with unflagged in 123, and is planning to remove support for assert in 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 assert back 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]

Activity

  1. aduh95 commented on Jan 31, 2024

    @aduh95
    Contributor

    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 assert syntax (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 (using with) has since landed on 20.x+, and the current plan is to keep the assert syntax 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-modules to gatekeep the support for assert, 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:

    1. Keep supporting assert syntax unflagged until Node.js 24.x (likely we need to float a V8 patch for Node.js 23.x)
    2. Drop support for assert in 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.
    3. Put assert syntax 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?

  2. richardlau commented on Jan 31, 2024

    @richardlau
    Member

    FWIW I'm open to landing #51136 on v18.x if it makes it easier to migrate to the newer syntax. cc @nodejs/lts

  3. GeoffreyBooth commented on Jan 31, 2024

    @GeoffreyBooth
    Member

    Just to be clear, I assume you’re proposing flagging assert syntax but not with syntax, 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 assert in 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.

  4. joyeecheung commented on Jan 31, 2024

    @joyeecheung
    Member

    I 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).

  5. mcollina commented on Feb 1, 2024

    @mcollina
    SponsorMember

    I think removing it in 22 is the best course of action.

  6. added
    release-agendaIssues and PRs to discuss during Release team meetings.
    on Feb 2, 2024
  7. aduh95 commented on Feb 2, 2024

    @aduh95
    Contributor

    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).

  8. nicolo-ribaudo commented on Mar 15, 2024

    @nicolo-ribaudo
    ContributorAuthor

    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?

  9. GeoffreyBooth commented on Mar 15, 2024

    @GeoffreyBooth
    Member

    I vote for removing assert in 22 and adding a warning for all previous lines. What do others think?

    And with would be unflagged.

  10. nicolo-ribaudo commented on Mar 15, 2024

    @nicolo-ribaudo
    ContributorAuthor

    Note that with is already unflagged in 20 and 21 (and in 18 right now it just doesn't exist, not even behind a flag).

  11. richardlau commented on Mar 15, 2024

    @richardlau
    Member

    Note that with is already unflagged in 20 and 21 (and in 18 right now it just doesn't exist, not even behind a flag).

    #51622 (comment)

  12. 7 remaining items

  13. moved this from Awaiting Triage to Done in Node.js feature requestson Jun 27, 2024
  14. shellscape commented on Oct 9, 2024

    @shellscape

    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.

  15. nicolo-ribaudo commented on Oct 9, 2024

    @nicolo-ribaudo
    ContributorAuthor

    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.

  16. shellscape commented on Oct 9, 2024

    @shellscape

    @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.

  17. nicolo-ribaudo commented on Oct 9, 2024

    @nicolo-ribaudo
    ContributorAuthor

    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 😅

  18. shellscape commented on Oct 9, 2024

    @shellscape

    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.

  19. aduh95 commented on Oct 9, 2024

    @aduh95
    Contributor

    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 with to 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.

  20. added a commit that references this issue on Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.release-agendaIssues and PRs to discuss during Release team meetings.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions