Unverified Commit 4b23c7b0 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

[next] use `tsconfig.build.json` for production build (#76373)

### Why?

The types of unit tests and stories were included in the package.
Exclude them by using `tsconfig.declaration.json` when `pnpm run types`
during production build.

| Before | After |
|--------|--------|
| ![CleanShot 2025-02-22 at 18 53
43@2x](https://github.com/user-attachments/assets/4e926395-4c53-4d82-aaf9-e7aa03124294)
| ![CleanShot 2025-02-22 at 19 09
37@2x](https://github.com/user-attachments/assets/9a4d3fbc-f5b8-421e-9cb5-d8d0aa1d7509)
|

Closes NDX-747

---------
Co-authored-by: 's avatarSebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
parent 58d328a0
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
"release": "taskr release", "release": "taskr release",
"build": "pnpm release", "build": "pnpm release",
"prepublishOnly": "cd ../../ && turbo run build", "prepublishOnly": "cd ../../ && turbo run build",
"types": "tsc --declaration --emitDeclarationOnly --stripInternal --declarationDir dist", "types": "tsc --project tsconfig.build.json --declaration --emitDeclarationOnly --stripInternal --declarationDir dist",
"typescript": "tsec --noEmit", "typescript": "tsec --noEmit",
"ncc-compiled": "taskr ncc", "ncc-compiled": "taskr ncc",
"storybook": "storybook dev -p 6006", "storybook": "storybook dev -p 6006",
......
...@@ -2573,14 +2573,14 @@ export async function nextbuildjest(task, opts) { ...@@ -2573,14 +2573,14 @@ export async function nextbuildjest(task, opts) {
export async function client(task, opts) { export async function client(task, opts) {
await task 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 }) .swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/client') .target('dist/client')
} }
export async function client_esm(task, opts) { export async function client_esm(task, opts) {
await task 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 }) .swc('client', { dev: opts.dev, esm: true })
.target('dist/esm/client') .target('dist/esm/client')
} }
......
{
"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",
// Don't generate types for internal files.
"./**/*.test.ts",
"./**/*.test.tsx",
"./**/*.stories.tsx"
]
}
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
"target": "ES2018", "target": "ES2018",
"moduleResolution": "node" "moduleResolution": "node"
}, },
// When changing `exclude`, also update
// `tsconfig.build.json`.
"exclude": [ "exclude": [
"dist", "dist",
"./*.d.ts", "./*.d.ts",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment