Skip to content

Design Meeting Notes, 12/3/2024 #60707

Open
@DanielRosenwasser

Description

@DanielRosenwasser

New --module Targets for Node.js

#60589
#60534

  • Previously, we were pretty loose about JSON imports in nodenext.
    • We need to stop allowing named imports from these JSON files.
    • Also, Node.js requires you to use import attributes for JSON files.
  • In 5.7 we added fixes for cases when we resolve to JSON files.
  • We enabled this for node16 as well, but we error saying that you can only use import attributes in nodenext.
  • In Node.js 16, you can only use import assertions (the old deprecated thing), not import attributes.
    • We will probably make things loose again in node16 as well - no checks for JSON modules.
  • Node.js 16 is already EOL.
  • So where does this leave us?
    • Node.js 18 is still in maintenance, but does support import attributes.
    • Node 23 will have require(ESM) support.
  • Proposal:
    • --module nodenext allows require(ESM) (for Node.js 23/24, possibly 22)
      • Eventually settle on a specific line.
    • --module node20 depending on if the above features get back-ported.
    • --module node18 for import assertions and JSON import checks (what nodenext should be in TypeScript 5.7)
    • --module node16 to be deprecated farther down.
      • It is not the most ideal state (it is EOL, doesn't support JSON imports correctly), but TBD.
  • We like this plan, we feel okay to move forward with this for TypeScript 5.8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design NotesNotes from our design meetings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions