Skip to content

Support "module": "nodenext" in tsconfig.json #37525

Closed
@michaelhays

Description

@michaelhays

Describe the feature you'd like to request

With TypeScript 4.7 providing ECMAScript Module Support, we can now set this in our tsconfig.json file for the module option:

{
  "compilerOptions": {
    "module": "nodenext",
  }
}

However, Next.js rejects this value, and overwrites it with "esnext".

#36189 did add support for "moduleResolution": "nodenext", but not "module": "nodenext".

Describe the solution you'd like

Add "nodenext" and "node16" to module.parsedValues:

parsedValues: [
  ts.ModuleKind.ES2020,
  ts.ModuleKind.ESNext,
  ts.ModuleKind.NodeNext,
  ts.ModuleKind.Node16,
  ts.ModuleKind.CommonJS,
  ts.ModuleKind.AMD,
]

I figure there may be other changes necessary to make this work, and that the TypeScript version should be bumped to 4.7+ with it.

Describe alternatives you've considered

I edited writeConfigurationDefaults.js directly in my node_modules for a local project, and it seemed to work.

Relevant aside: I think the discussion at #32237 is a bug that needs to be resolved before this can work as expected. I still haven't been able to import files with the .js extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeScriptRelated to types with Next.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions