From 81748821c5b7c35e8cacdb87c9d66128c49d3193 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Sat, 22 Feb 2025 19:11:01 +0900 Subject: [PATCH 1/4] [next] use `tsconfig.declaration.json` for production build --- packages/next/package.json | 2 +- packages/next/taskfile.js | 4 ++-- packages/next/tsconfig.declaration.json | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 packages/next/tsconfig.declaration.json diff --git a/packages/next/package.json b/packages/next/package.json index 10cdd22f603c8..cc912c98a7ded 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -84,7 +84,7 @@ "release": "taskr release", "build": "pnpm release", "prepublishOnly": "cd ../../ && turbo run build", - "types": "tsc --declaration --emitDeclarationOnly --stripInternal --declarationDir dist", + "types": "tsc --project tsconfig.declaration.json --declaration --emitDeclarationOnly --stripInternal --declarationDir dist", "typescript": "tsec --noEmit", "ncc-compiled": "taskr ncc", "storybook": "storybook dev -p 6006", diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 83d804615ed3f..8fbbdc157f703 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -2573,14 +2573,14 @@ export async function nextbuildjest(task, opts) { export async function client(task, opts) { await task - .source('src/client/**/!(*.test).+(js|ts|tsx|woff2)') + .source('src/client/**/!(*.test|*.stories).+(js|ts|tsx|woff2)') .swc('client', { dev: opts.dev, interopClientDefaultExport: true }) .target('dist/client') } export async function client_esm(task, opts) { await task - .source('src/client/**/!(*.test).+(js|ts|tsx|woff2)') + .source('src/client/**/!(*.test|*.stories).+(js|ts|tsx|woff2)') .swc('client', { dev: opts.dev, esm: true }) .target('dist/esm/client') } diff --git a/packages/next/tsconfig.declaration.json b/packages/next/tsconfig.declaration.json new file mode 100644 index 0000000000000..c0ae7c2235f67 --- /dev/null +++ b/packages/next/tsconfig.declaration.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + // Copied from tsconfig.json to not overwrite. + "exclude": [ + "dist", + "./*.d.ts", + "future/*.d.ts", + "image-types/global.d.ts", + "compat/*.d.ts", + "legacy/*.d.ts", + "types/compiled.d.ts", + "navigation-types/*.d.ts", + "navigation-types/compat/*.d.ts", + "experimental/**/*.d.ts", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.stories.tsx" + ] +} From b11fe30595af3e5de00d29bd656a000fd2e18fc0 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Sat, 22 Feb 2025 21:52:12 +0900 Subject: [PATCH 2/4] update comments --- packages/next/tsconfig.declaration.json | 7 ++++--- packages/next/tsconfig.json | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/next/tsconfig.declaration.json b/packages/next/tsconfig.declaration.json index c0ae7c2235f67..0190e0c0147a5 100644 --- a/packages/next/tsconfig.declaration.json +++ b/packages/next/tsconfig.declaration.json @@ -12,8 +12,9 @@ "navigation-types/*.d.ts", "navigation-types/compat/*.d.ts", "experimental/**/*.d.ts", - "**/*.test.ts", - "**/*.test.tsx", - "**/*.stories.tsx" + // Don't generate types for internal files. + "./**/*.test.ts", + "./**/*.test.tsx", + "./**/*.stories.tsx" ] } diff --git a/packages/next/tsconfig.json b/packages/next/tsconfig.json index 5484d41954204..6fe0a1a4ea2df 100644 --- a/packages/next/tsconfig.json +++ b/packages/next/tsconfig.json @@ -10,6 +10,8 @@ "target": "ES2018", "moduleResolution": "node" }, + // When changing `exclude`, also update + // `tsconfig.declaration.json`. "exclude": [ "dist", "./*.d.ts", From 83b4c43d7515f0814c43c05e98aebb4409568a94 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Sun, 23 Feb 2025 20:21:13 +0900 Subject: [PATCH 3/4] use `tsconfig.build.json` Co-authored-by: Sebastian Sebbie Silbermann --- .../next/{tsconfig.declaration.json => tsconfig.build.json} | 0 packages/next/tsconfig.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/next/{tsconfig.declaration.json => tsconfig.build.json} (100%) diff --git a/packages/next/tsconfig.declaration.json b/packages/next/tsconfig.build.json similarity index 100% rename from packages/next/tsconfig.declaration.json rename to packages/next/tsconfig.build.json diff --git a/packages/next/tsconfig.json b/packages/next/tsconfig.json index 6fe0a1a4ea2df..fc5a5ebf883ab 100644 --- a/packages/next/tsconfig.json +++ b/packages/next/tsconfig.json @@ -11,7 +11,7 @@ "moduleResolution": "node" }, // When changing `exclude`, also update - // `tsconfig.declaration.json`. + // `tsconfig.build.json`. "exclude": [ "dist", "./*.d.ts", From 75599c4185b0ef3ebd469b80a3e1cd315f15c087 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Sun, 23 Feb 2025 20:22:07 +0900 Subject: [PATCH 4/4] missed pkgjson --- packages/next/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/package.json b/packages/next/package.json index cc912c98a7ded..1d6252799dfc3 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -84,7 +84,7 @@ "release": "taskr release", "build": "pnpm release", "prepublishOnly": "cd ../../ && turbo run build", - "types": "tsc --project tsconfig.declaration.json --declaration --emitDeclarationOnly --stripInternal --declarationDir dist", + "types": "tsc --project tsconfig.build.json --declaration --emitDeclarationOnly --stripInternal --declarationDir dist", "typescript": "tsec --noEmit", "ncc-compiled": "taskr ncc", "storybook": "storybook dev -p 6006",