Skip to content

Conversation

devjiwonchoi
Copy link
Member

@devjiwonchoi devjiwonchoi commented Sep 8, 2025

This PR adds docs for using Node.js native TS resolver for next.config.ts. It states:

  • Supports Node.js native TS resolver
  • Why use it
  • How to use it
  • Restrictions
  • Why use 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.

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. labels Sep 8, 2025
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Contributor

github-actions bot commented Sep 8, 2025

All broken links are now fixed, thank you!

@devjiwonchoi devjiwonchoi force-pushed the jiwon/09-08-docs_add_next.config.ts_node.js_native_resolver branch from 8348f4d to 6952b51 Compare September 16, 2025 12:27
Copy link
Contributor

@Copilot Copilot AI left a 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.

@devjiwonchoi devjiwonchoi marked this pull request as ready for review September 16, 2025 12:37
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.
Copy link
Contributor

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"?

Copy link
Contributor

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

@devjiwonchoi devjiwonchoi force-pushed the jiwon/09-08-docs_add_next.config.ts_node.js_native_resolver branch from 457c22c to 0286ac5 Compare September 17, 2025 11:32
@devjiwonchoi devjiwonchoi merged commit 09c5a7c into canary Sep 17, 2025
79 checks passed
@devjiwonchoi devjiwonchoi deleted the jiwon/09-08-docs_add_next.config.ts_node.js_native_resolver branch September 17, 2025 19:12
@github-actions github-actions bot added the locked label Oct 2, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants