Skip to content
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

feat(next): next.config.ts #63051

Open
wants to merge 166 commits into
base: canary
Choose a base branch
from

Conversation

devjiwonchoi
Copy link
Contributor

@devjiwonchoi devjiwonchoi commented Mar 8, 2024

Note: port of #57656

What?

This PR initiated support of next.config.ts.

Follow ups:

  • update docs (x-ref)
  • update cna ts templates (x-ref)

Why?

Next.js provides a TypeScript-first development experience for building your React application.

This PR can resolve the two main needs:

  1. Import TS files to the config.
  2. Conduct a type check directly by importing type instead of JSDoc.

x-ref: #5318 #35969 #44632 #50121 #50126

How?

Goals

Used require.extensions hooks to transpile the imported files on the fly.

To reduce I/O operation on disk, used custom module.exports to require directly from a transpiled code string.

Expected

Added tests for the cases below:

Importing Files

  • nested imports (config -> A -> B)
  • import alias (tsconfig baseUrl and paths)
  • import from node_modules
  • import JSON

Extensions

  • .ts
  • .cts
  • .mts
  • .cjs
  • .mjs
  • .js (both ESM and CJS w/o extra change)

devjiwonchoi and others added 30 commits October 27, 2023 12:15
ref: vercel#57656 (comment)

Co-authored-by: Donny/강동윤 <kdy1997.dev@gmail.com>
Co-authored-by: rodrigo
<falsepopsky@protonmail.com>
Co-authored-by: Sukka <isukkaw@gmail.com>
@devjiwonchoi
Copy link
Contributor Author

devjiwonchoi commented Apr 24, 2024

@ijjk Understood. Can I have a day for the last try? 😊

Edit: All tests pass, successful w/o bundling, will work on refactor & reducing fs operations!

@devjiwonchoi devjiwonchoi requested a review from ijjk April 25, 2024 06:23
Co-authored-by: Ahmed Abdelbaset <A7med3bdulBaset@gmail.com>
@ijjk ijjk added the CI approved Approve running CI for fork label Apr 25, 2024
@devjiwonchoi
Copy link
Contributor Author

@ijjk Thank you for waiting! Current change meets the major expectations we discussed before:

  • no bundling
  • no restrictions
  • less fs operations and writing on disk (readFile only)

devjiwonchoi and others added 2 commits April 27, 2024 09:38
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI approved Approve running CI for fork create-next-app Related to our CLI tool for quickly starting a new Next.js application. Documentation Related to Next.js' official documentation. tests type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants