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

Merged
merged 181 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 132 commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
7c24a69
allow next.config.ts on load
devjiwonchoi Oct 27, 2023
21b18e0
test: add test for next.config.ts
devjiwonchoi Oct 27, 2023
407658d
add compile config
devjiwonchoi Oct 28, 2023
3075e2a
chore: compile as mjs
devjiwonchoi Oct 28, 2023
bd61aec
test: add test case for production
devjiwonchoi Oct 28, 2023
4ba992b
chore: add cache original config and skip compile if identical
devjiwonchoi Oct 28, 2023
5fcfd50
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Oct 28, 2023
834bdba
add next.config.ts to error message
devjiwonchoi Oct 28, 2023
7c25030
remove caching snapshot of config
devjiwonchoi Oct 28, 2023
7a0518c
fix: modify target version to esnext
devjiwonchoi Oct 29, 2023
5a394a9
refac: convert to async job, error handle
devjiwonchoi Oct 29, 2023
cd2c8d8
test: modify test to look for rendered element
devjiwonchoi Oct 29, 2023
22b1497
chore: use curLog for errors when failed compiling
devjiwonchoi Oct 29, 2023
57ea7ff
chore: add read off tsconfig for module type
devjiwonchoi Oct 30, 2023
7006fd3
chore: remove production test
devjiwonchoi Oct 30, 2023
bec6170
refac: output file ext always mjs
devjiwonchoi Oct 30, 2023
8de3c81
test: add esm test
devjiwonchoi Oct 30, 2023
5df0813
test: add cjs test
devjiwonchoi Oct 30, 2023
540f6ae
fix: file ext mjs if not cjs
devjiwonchoi Oct 30, 2023
de02ca8
chore: add type for Log
devjiwonchoi Oct 30, 2023
ab6e908
refac: explicit type for error log
devjiwonchoi Oct 30, 2023
c9d2eb6
test: import type at esm
devjiwonchoi Oct 30, 2023
4b2ed5a
chore: no module type check, just compile them as cjs
devjiwonchoi Oct 30, 2023
ff17aef
add more tests
devjiwonchoi Oct 30, 2023
75758cc
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Oct 30, 2023
f6aea6e
add failing tests
devjiwonchoi Oct 30, 2023
ab52aff
chore: naming as transpileConfig
devjiwonchoi Oct 30, 2023
3c87454
test: remove unnecessary tsconfig
devjiwonchoi Oct 31, 2023
1aeb69c
test: add necessary tsconfig.json
devjiwonchoi Oct 31, 2023
6375316
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Nov 6, 2023
d368dc4
Add strict mode and pure ESM import
devjiwonchoi Nov 7, 2023
b008c20
Refactor transpileConfig and loadConfig functions
devjiwonchoi Nov 7, 2023
2b6c10b
Fix transpile-config and loadConfig functions
devjiwonchoi Nov 7, 2023
5205dba
Update transpile-config and add new files for next-config-ts tests
devjiwonchoi Nov 7, 2023
7dfc842
Add next.compiled.config.* to gitignore
devjiwonchoi Nov 7, 2023
26c3e22
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Nov 7, 2023
e4c7acf
refac: use temporary config
devjiwonchoi Nov 21, 2023
fcc0d55
Remove next.compiled.config from gitignore
devjiwonchoi Nov 21, 2023
7e0855a
ensure import url
devjiwonchoi Nov 21, 2023
d8108e1
refac: transpile-config focus on returning code
devjiwonchoi Nov 21, 2023
ea5b249
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Nov 22, 2023
db7836e
Delete tsconfig.json and .gitignore files
devjiwonchoi Nov 22, 2023
f972c6f
remove log type declaration
devjiwonchoi Nov 22, 2023
02a47b2
Remove unused 'cwd' parameter in transpileConfig
devjiwonchoi Nov 22, 2023
2b84702
modify test names
devjiwonchoi Nov 22, 2023
1b9c204
test: add import from other ts
devjiwonchoi Dec 7, 2023
fa7a424
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Dec 7, 2023
379aabc
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Dec 30, 2023
1d3adfe
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Feb 7, 2024
5e57291
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Feb 18, 2024
39736a3
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Feb 20, 2024
db25521
chore: save current work
devjiwonchoi Feb 20, 2024
43a39d1
fix: taskfile and bundle5 terser-plugin path
devjiwonchoi Feb 20, 2024
20f8c42
save for now - webpack does complete bundle but output is 0 byte
devjiwonchoi Feb 20, 2024
8c63c93
refactor: re-compile if needed
devjiwonchoi Feb 21, 2024
4c70e92
test: import-alias
devjiwonchoi Feb 21, 2024
0aa3154
refactor: support path alias
devjiwonchoi Feb 21, 2024
c8d072b
chore: remove import-from-other-ts since path-alias can handle it
devjiwonchoi Feb 21, 2024
03ce640
refactor: error handling transpile config
devjiwonchoi Feb 21, 2024
0783399
refactor: remove resolve.extensions for webpack option
devjiwonchoi Feb 21, 2024
fb55de4
test: remove ALL current tests
devjiwonchoi Feb 21, 2024
cfb0851
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Feb 22, 2024
bfa25b5
test: add import alias
devjiwonchoi Feb 22, 2024
86d0201
test: export as default
devjiwonchoi Feb 22, 2024
55dd8ad
test: add import from node modules
devjiwonchoi Feb 22, 2024
dfb8816
fix: add webpack.resolve.extensions
devjiwonchoi Feb 22, 2024
9cc2ac9
refactor: next config options may be nullish
devjiwonchoi Feb 22, 2024
23edb4d
test: config as async function
devjiwonchoi Feb 22, 2024
b6c7888
refactor: add alias for swc helpers
devjiwonchoi Feb 22, 2024
0565dd7
test: config has no export default
devjiwonchoi Feb 22, 2024
a82e7ea
test: nest tests inside next-config-ts dir
devjiwonchoi Feb 22, 2024
1d386b1
test: ensure config recompiled when needed
devjiwonchoi Feb 22, 2024
555806a
refactor: pass nextconfig to bundleconfig as default empty obj
devjiwonchoi Feb 22, 2024
5e7f21d
refactor: re-use inputFileSystem
devjiwonchoi Feb 22, 2024
757108d
test: add dev server
devjiwonchoi Feb 22, 2024
15995b5
refactor: remove unintended changes
devjiwonchoi Feb 22, 2024
25293c9
test: ensure importing relative from root
devjiwonchoi Feb 22, 2024
1f85d1b
fix: remove reusing inputFileSystem
devjiwonchoi Feb 22, 2024
406b4ff
test: remove no default export since not throwing
devjiwonchoi Feb 22, 2024
9e8f5b5
refactor: replace webpack bundle with require hook and swc transform
devjiwonchoi Feb 24, 2024
3b49ca3
test: remove recompile
devjiwonchoi Feb 24, 2024
bf46de4
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Feb 24, 2024
7f16812
Revert "fix: taskfile and bundle5 terser-plugin path"
devjiwonchoi Feb 24, 2024
2e358df
refactor: modify variable names and add TODO
devjiwonchoi Feb 24, 2024
419d1a9
test: add pkg type module esm project
devjiwonchoi Feb 24, 2024
7c97ef5
test: add mts
devjiwonchoi Feb 24, 2024
3b81c7d
test: ensure esm imports correctly
devjiwonchoi Feb 24, 2024
932dd22
refactor: support ESM
devjiwonchoi Feb 24, 2024
4caea8b
refactor: remove unintended fixes
devjiwonchoi Feb 24, 2024
0d02318
refactor: return default
devjiwonchoi Feb 24, 2024
259c08b
test: import .mts and .cts
devjiwonchoi Feb 25, 2024
06c734c
refactor: support importing other ts extensions
devjiwonchoi Feb 25, 2024
91c4f92
test: add esm mjs imports
devjiwonchoi Feb 25, 2024
e4d4870
refactor: handle import ESM
devjiwonchoi Feb 25, 2024
1a3b83a
fix: do not modify require.extensions['.js']
devjiwonchoi Feb 25, 2024
4840acf
test: add import esm from node_modules
devjiwonchoi Feb 26, 2024
a52e610
test: add nested imports
devjiwonchoi Feb 26, 2024
230e44e
refactor: drop .cts, remove experimental log
devjiwonchoi Feb 27, 2024
92065d4
refactor: register by detecting transpile-config not extensions
devjiwonchoi Feb 27, 2024
598bdbc
chore: remove unrelated change
devjiwonchoi Feb 27, 2024
16a2412
refactor: revert handling register via extensions
devjiwonchoi Feb 27, 2024
519df26
chore: save progress before revert
devjiwonchoi Feb 29, 2024
d410013
refactor: transpile only or bundle if necessary
devjiwonchoi Feb 29, 2024
00d2988
refactor: separate bundle method
devjiwonchoi Feb 29, 2024
4f668ab
refactor: remove recompile, no unlinking config file
devjiwonchoi Mar 1, 2024
54d0d3f
test: add cjs, esm, node-api
devjiwonchoi Mar 1, 2024
cd1922b
refactor: handle importing js extensions
devjiwonchoi Mar 1, 2024
abd46e8
fix: update taskfile's terser-webpack-plugin path
devjiwonchoi Mar 1, 2024
e430955
test: add next-config-mts
devjiwonchoi Mar 1, 2024
0b698b2
refactor: webpack mode to production, fix on terser-plugin was needed
devjiwonchoi Mar 1, 2024
c3182c3
fix: allow .mts extension for swc-loader
devjiwonchoi Mar 1, 2024
d4f2abf
chore: remove tsconfig for next-config-mts test
devjiwonchoi Mar 1, 2024
694c3a9
refactor: use nodejs api, add unlink since it breaks when using __dir…
devjiwonchoi Mar 2, 2024
b1ee1db
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Mar 2, 2024
661b2fa
refactor: revert using .next dir, ensure __dirname to point cwd
devjiwonchoi Mar 2, 2024
35c78f5
docs: add next.config.ts, but as an option not default
devjiwonchoi Mar 3, 2024
80e6740
refactor: use next.config.ts for create next app-ts
devjiwonchoi Mar 3, 2024
8800145
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Mar 3, 2024
32fd66e
test: add dev
devjiwonchoi Mar 3, 2024
34af164
refactor: use build cache on production server if exists
devjiwonchoi Mar 3, 2024
9890443
refactor: remove unintended change
devjiwonchoi Mar 3, 2024
baaad07
refactor: try transpile-only first before any other operation
devjiwonchoi Mar 3, 2024
b7f50ab
test: add export default
devjiwonchoi Mar 3, 2024
c7765c8
refactor: join cwd with distDir to dedupe join operation
devjiwonchoi Mar 3, 2024
c1e796f
refactor: let loadConfig handle added default export of SWC transform
devjiwonchoi Mar 3, 2024
8bd8863
test: add cjs syntax for direct migration from .js
devjiwonchoi Mar 3, 2024
79b643d
docs: add we recommend next.config.ts if you are migrating to TS
devjiwonchoi Mar 3, 2024
8e4c38e
fix: do not pass an absolute path to distDir
devjiwonchoi Mar 4, 2024
1a61b97
Revert "fix: do not pass an absolute path to distDir"
devjiwonchoi Mar 4, 2024
874aab6
Merge branch 'canary' of https://github.com/devjiwonchoi/next.js into…
devjiwonchoi Mar 8, 2024
a431c9c
Merge branch 'canary' into next-config-ts-esm
samcx Mar 11, 2024
47742b4
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Mar 15, 2024
ed34515
Merge branch 'canary' of github.com:devjiwonchoi/next.js into next-co…
devjiwonchoi Apr 4, 2024
ec96813
sync bundle5
devjiwonchoi Apr 4, 2024
e0a4da9
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Apr 4, 2024
57006ce
REVERT to require hook
devjiwonchoi Apr 11, 2024
96b0000
wip: get ready for esm loader
devjiwonchoi Apr 15, 2024
a11d2c0
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Apr 23, 2024
2ea9b6e
docs: revert changes
devjiwonchoi Apr 24, 2024
ef984bb
Revert "refactor: use next.config.ts for create next app-ts"
devjiwonchoi Apr 24, 2024
03bb99e
Revert "fix: allow .mts extension for swc-loader"
devjiwonchoi Apr 24, 2024
463d2a2
test: remove webpack related dev test
devjiwonchoi Apr 24, 2024
58ec040
REVERT taskfile, bundle5
devjiwonchoi Apr 24, 2024
30b23d6
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Apr 24, 2024
8ff8b6c
test: commonjs
devjiwonchoi Apr 24, 2024
bb3dacf
test: pkg-commonjs, module
devjiwonchoi Apr 24, 2024
bac1be2
test: node-api import as node:
devjiwonchoi Apr 24, 2024
f8b4295
test: import alias
devjiwonchoi Apr 24, 2024
dee73f8
test: nested-import
devjiwonchoi Apr 24, 2024
bd1dd4d
test: remove cjs syntax
devjiwonchoi Apr 24, 2024
dfde1a8
test: import json
devjiwonchoi Apr 24, 2024
97a4d05
wip: transpile config
devjiwonchoi Apr 24, 2024
c616e05
test: pkg module esm
devjiwonchoi Apr 24, 2024
f14187b
test: fix names
devjiwonchoi Apr 24, 2024
5a078eb
refactor: test pass for esm on js
devjiwonchoi Apr 24, 2024
ef5d1f5
refactor: error handling
devjiwonchoi Apr 25, 2024
724b5ea
Update test/e2e/app-dir/next-config-ts/nested-imports/index.test.ts
devjiwonchoi Apr 25, 2024
5922d0e
Update packages/next/src/server/config.ts
devjiwonchoi Apr 25, 2024
694490e
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Apr 25, 2024
78cefa0
refactor: no writing to disk
devjiwonchoi Apr 25, 2024
9da25d2
test: delete next-config-mts
devjiwonchoi Apr 25, 2024
1a0f402
refactor: split code as hook and transpile-config
devjiwonchoi Apr 25, 2024
ad40f8d
refactor: strip comments on tsconfig
devjiwonchoi Apr 25, 2024
a20d80f
Merge branch 'canary' into next-config-ts-esm
ijjk Apr 25, 2024
0c0d003
refactor: re-use parseJsonFile
devjiwonchoi Apr 27, 2024
1fc6512
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Apr 27, 2024
1ad706e
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Jul 1, 2024
a44d2c2
test: add hmr test
devjiwonchoi Jul 1, 2024
f46fd2a
chore: add experimental warning
devjiwonchoi Jul 1, 2024
4d0bba2
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Jul 1, 2024
d98f094
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Jul 1, 2024
239e519
refactor
devjiwonchoi Jul 1, 2024
4ef5fce
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Jul 2, 2024
89218c7
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Jul 4, 2024
e9203e1
fix: lazy load swc
devjiwonchoi Jul 8, 2024
f52d069
Merge branch 'canary' into next-config-ts-esm
devjiwonchoi Jul 8, 2024
7803601
fix: lazy require not import
devjiwonchoi Jul 8, 2024
797a17d
Revert "chore: add experimental warning"
devjiwonchoi Jul 8, 2024
26cf189
refactor order
devjiwonchoi Jul 8, 2024
ca84399
test: add type error for build
devjiwonchoi Jul 9, 2024
28f9121
test: add explicit turbopack compatibility check
devjiwonchoi Jul 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Add TypeScript to your project by renaming a file to `.ts` / `.tsx`. Run `next d

If you already had a `jsconfig.json` file, copy the `paths` compiler option from the old `jsconfig.json` into the new `tsconfig.json` file, and delete the old `jsconfig.json` file.

We also recommend you to use `next.config.ts` over `next.config.js` for better type inference.

<AppOnly>

## TypeScript Plugin
Expand Down Expand Up @@ -70,6 +72,22 @@ The TypeScript plugin can help with:

It is highly recommended to be on at least `v4.5.2` of TypeScript to get syntax features such as [type modifiers on import names](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#type-on-import-names) and [performance improvements](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#real-path-sync-native).

## Type checking with `next.config.ts`

You can use TypeScript in your Next.js configuration by using `next.config.ts`. If you have a `next.config.js` or `next.config.mjs` file, you can rename it to `next.config.ts`, and will be able to use TypeScript without any change in the configuration.

Although you can use `module.exports` syntax in `next.config.ts`, it is recommended to use the `export default` syntax for better type inference.

```ts filename="next.config.ts"
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
/* config options here */
}

export default nextConfig
```

<AppOnly>

## Statically Typed Links
Expand All @@ -78,15 +96,16 @@ Next.js can statically type links to prevent typos and other errors when using `

To opt-into this feature, `experimental.typedRoutes` need to be enabled and the project needs to be using TypeScript.

```js filename="next.config.js"
/** @type {import('next').NextConfig} */
const nextConfig = {
```js filename="next.config.ts"
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
experimental: {
typedRoutes: true,
},
}

module.exports = nextConfig
export default nextConfig
```

Next.js will generate a link definition in `.next/types` that contains information about all existing routes in your application, which TypeScript can then use to provide feedback in your editor about invalid links.
Expand Down Expand Up @@ -251,23 +270,6 @@ You can learn more about this feature on the [Module Path aliases documentation]

</PagesOnly>

## Type checking next.config.js

The `next.config.js` file must be a JavaScript file as it does not get parsed by Babel or TypeScript, however you can add some type checking in your IDE using JSDoc as below:

```js
// @ts-check

/**
* @type {import('next').NextConfig}
**/
const nextConfig = {
/* config options here */
}

module.exports = nextConfig
```

## Incremental type checking

Since `v10.2.1` Next.js supports [incremental type checking](https://www.typescriptlang.org/tsconfig#incremental) when enabled in your `tsconfig.json`, this can help speed up type checking in larger applications.
Expand All @@ -280,10 +282,10 @@ If you'd like Next.js to dangerously produce production code even when your appl

If disabled, be sure you are running type checks as part of your build or deploy process, otherwise this can be very dangerous.

Open `next.config.js` and enable the `ignoreBuildErrors` option in the `typescript` config:
Open `next.config.ts` and enable the `ignoreBuildErrors` option in the `typescript` config:

```js filename="next.config.js"
module.exports = {
```ts filename="next.config.ts"
export default {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
Expand Down Expand Up @@ -319,6 +321,7 @@ When you need to declare custom types, you might be tempted to modify `next-env.

| Version | Changes |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `v14.2.0` | `next.config.ts` support added for TypeScript projects. |
devjiwonchoi marked this conversation as resolved.
Show resolved Hide resolved
| `v13.2.0` | Statically typed links are available in beta. |
| `v12.0.0` | [SWC](/docs/architecture/nextjs-compiler) is now used by default to compile TypeScript and TSX for faster builds. |
| `v10.2.1` | [Incremental type checking](https://www.typescriptlang.org/tsconfig#incremental) support added when enabled in your `tsconfig.json`. |
36 changes: 33 additions & 3 deletions docs/02-app/02-api-reference/05-next-config-js/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ module.exports = nextConfig

`next.config.js` is a regular Node.js module, not a JSON file. It gets used by the Next.js server and build phases, and it's not included in the browser build.

## TypeScript

If you are using TypeScript in your project, you can use [`next.config.ts`](https://nextjs.org/docs/app/building-your-application/configuring/typescript#type-checking-with-next-config-ts) to use TypeScript in your configuration:

```ts filename="next.config.ts"
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
/* config options here */
}

export default nextConfig
```

## ECMAScript modules

If you need [ECMAScript modules](https://nodejs.org/api/esm.html), you can use `next.config.mjs`:

```js filename="next.config.mjs"
Expand All @@ -35,7 +51,21 @@ const nextConfig = {
export default nextConfig
```

You can also use a function:
Or `next.config.mts` for TypeScript:

```ts filename="next.config.mts"
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
/* config options here */
}

export default nextConfig
```

## Configuration as function

You can use the configuration as a function:

```js filename="next.config.mjs"
// @ts-check
Expand Down Expand Up @@ -69,7 +99,7 @@ module.exports = async (phase, { defaultConfig }) => {

`phase` is the current context in which the configuration is loaded. You can see the [available phases](https://github.com/vercel/next.js/blob/5e6b008b561caf2710ab7be63320a3d549474a5b/packages/next/shared/lib/constants.ts#L19-L23). Phases can be imported from `next/constants`:

```js
```js filename="next.config.js"
// @ts-check

const { PHASE_DEVELOPMENT_SERVER } = require('next/constants')
Expand All @@ -91,6 +121,6 @@ The commented lines are the place where you can put the configs allowed by `next

However, none of the configs are required, and it's not necessary to understand what each config does. Instead, search for the features you need to enable or modify in this section and they will show you what to do.

> Avoid using new JavaScript features not available in your target Node.js version. `next.config.js` will not be parsed by Webpack, Babel or TypeScript.
> Avoid using new JavaScript features not available in your target Node.js version. `next.config.js` will not be parsed by Webpack, Babel or TypeScript. Instead, use `next.config.mjs` for ECMAScript modules or `next.config.ts` for TypeScript.

This page documents all the available configuration options:
6 changes: 3 additions & 3 deletions docs/02-app/02-api-reference/05-next-config-js/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ If you'd like Next.js to dangerously produce production code even when your appl

If disabled, be sure you are running type checks as part of your build or deploy process, otherwise this can be very dangerous.

Open `next.config.js` and enable the `ignoreBuildErrors` option in the `typescript` config:
Open `next.config.ts` and enable the `ignoreBuildErrors` option in the `typescript` config:

```js filename="next.config.js"
module.exports = {
```ts filename="next.config.ts"
export default {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
Expand Down
4 changes: 0 additions & 4 deletions packages/create-next-app/templates/app-tw/ts/next.config.mjs

This file was deleted.

5 changes: 5 additions & 0 deletions packages/create-next-app/templates/app-tw/ts/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {};

export default nextConfig;
4 changes: 0 additions & 4 deletions packages/create-next-app/templates/app/ts/next.config.mjs

This file was deleted.

5 changes: 5 additions & 0 deletions packages/create-next-app/templates/app/ts/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {};

export default nextConfig;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = { reactStrictMode: true };

export default nextConfig;
6 changes: 0 additions & 6 deletions packages/create-next-app/templates/default/ts/next.config.mjs

This file was deleted.

5 changes: 5 additions & 0 deletions packages/create-next-app/templates/default/ts/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = { reactStrictMode: true };

export default nextConfig;
6 changes: 5 additions & 1 deletion packages/next/src/build/swc/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const regeneratorRuntimePath = require.resolve(
)

function isTypeScriptFile(filename: string) {
return filename.endsWith('.ts') || filename.endsWith('.tsx')
return (
filename.endsWith('.ts') ||
filename.endsWith('.mts') ||
devjiwonchoi marked this conversation as resolved.
Show resolved Hide resolved
filename.endsWith('.tsx')
)
}

function isCommonJSFile(filename: string) {
Expand Down
Loading
Loading