-
Notifications
You must be signed in to change notification settings - Fork 29.5k
docs: add next.config.ts
Node.js native resolver
#83561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add next.config.ts
Node.js native resolver
#83561
Conversation
All broken links are now fixed, thank you! |
8348f4d
to
6952b51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds documentation for Node.js native TypeScript resolver support in next.config.ts
files, enabling ECMAScript Modules (ESM) syntax when using Node.js v22.10.0 and higher.
- Documents the Node.js native TypeScript resolver feature for
next.config.ts
- Explains version requirements and configuration steps for enabling the feature
- Recommends using
next.config.mts
for CommonJS projects to avoid reparsing issues
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
NODE_OPTIONS=--experimental-transform-types next <command> | ||
``` | ||
|
||
By default, Node treats `.ts` files as CommonJS. If `next.config.ts` uses ESM syntax, Node re-parses it as ESM, which works but prints a warning about performance overhead. To avoid this extra pass, use `next.config.mts` to declare ESM up front. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth mentioning that we can keep next.config.ts
if we set "type": "module"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty - we are iterating this - I think we can add a mention on how to set module, and link to Node's documentation, https://nodejs.org/api/packages.html#type
Co-authored-by: Joseph <[email protected]>
Co-authored-by: Joseph <[email protected]>
Co-authored-by: Abdón Rodríguez <[email protected]>
457c22c
to
0286ac5
Compare
Co-authored-by: Joseph <[email protected]>
This PR adds docs for using Node.js native TS resolver for
next.config.ts
. It states:next.config.mts
I didn't mention how much it's faster compared to the legacy resolver (~68% faster in the hello world app - link) because the experience may vary for users.