Support `"module": "nodenext"` in `tsconfig.json`
See original GitHub issueDescribe 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.
Issue Analytics
- State:
- Created a year ago
- Reactions:8
- Comments:5 (2 by maintainers)
Top GitHub Comments
Is there some progress on this?
👋 @ctjlewis, you can try playing with https://github.com/kachkaev/njt/pull/186 where I attempt to switch a small Next.js 13 project to pure ESM with native Node module resolution. I need to use these two workarounds and it’d be great to see them implemented in Next: https://github.com/vercel/next.js/discussions/41189#discussioncomment-4026895. I’m also unable to use
"module": "NodeNext"
as mentioned in this issue.Keeping Next.js aligned with native Node module transpiling and resolution helps keep scripts or tests alongside the app.