Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

perf(build): split DTS from tsup to single tsc pass (#820)

Cindy Zhang9a35f12ae0a7
diff --git a/packages/core/package.json b/packages/core/package.json
index e414707904..e7b54269c7 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -408,7 +408,7 @@
],
"scripts": {
"prepack": "yarn build",
- "build": "NODE_OPTIONS='--max-old-space-size=4096' tsup",
+ "build": "tsup && tsc --project tsconfig.build.json",
"dev": "tsup --watch",
"test": "vitest run --root ../..",
"test:watch": "vitest --root ../..",
diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json
new file mode 100644
index 0000000000..53ea66fbfe
--- /dev/null
+++ b/packages/core/tsconfig.build.json
@@ -0,0 +1,23 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./dist",
+ "rootDir": "./src",
+ "noEmit": false,
+ "declaration": true,
+ "declarationMap": true,
+ "emitDeclarationOnly": true,
+ "sourceMap": false
+ },
+ "include": [
+ "src"
+ ],
+ "exclude": [
+ "src/**/*.test.ts",
+ "src/**/*.test.tsx",
+ "src/**/*.doc.mjs",
+ "src/**/__tests__/**",
+ "src/**/*.perf.test.ts",
+ "src/**/*.perf.test.tsx"
+ ]
+}
diff --git a/packages/core/tsup.config.ts b/packages/core/tsup.config.ts
index f7ad51081e..52fa87714c 100644
--- a/packages/core/tsup.config.ts
+++ b/packages/core/tsup.config.ts
@@ -1,9 +1,13 @@
/**
* @file tsup.config.ts
* @input Uses tsup
- * @output Bundle configuration for CJS/ESM outputs with TypeScript declarations
+ * @output Bundle configuration for CJS/ESM outputs (DTS via separate tsc pass)
* @position Build config; defines entry points and output formats for @xds/core
*
+ * DTS is generated by a separate `tsc --project tsconfig.build.json` step
+ * instead of tsup's built-in `dts: true`. This avoids OOM — tsup instantiates
+ * a full TypeScript program per entry point (60+), while tsc does one pass.
+ *
* SYNC: When modified, update this header and /packages/core/README.md
*/
@@ -13,7 +17,7 @@ import babel from 'esbuild-plugin-babel';
export default defineConfig({
entry: ['src/index.ts', 'src/*/index.ts', 'src/theme/tokens.stylex.ts'],
format: ['cjs', 'esm'],
- dts: true,
+ dts: false,
splitting: false,
clean: true,
external: ['react', 'react-dom'],