[v8] fix: migrate from tsup to tsdown for faster, lower-memory builds#1413
Merged
[v8] fix: migrate from tsup to tsdown for faster, lower-memory builds#1413
Conversation
Contributor
Greptile OverviewGreptile SummaryThis PR migrates from tsup to tsdown to resolve out-of-memory errors during CI builds, leveraging Rolldown's Rust-based bundler and Oxc's memory-efficient TypeScript declaration generation. Key Changes:
Benefits:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant CI as CI Pipeline
participant Node as Node.js Runtime
participant tsdown as tsdown CLI
participant Rolldown as Rolldown Bundler
participant Oxc as Oxc TypeScript Parser
participant FS as File System
CI->>Node: Set NODE_OPTIONS=--max-old-space-size=4096
CI->>tsdown: npm run build
tsdown->>tsdown: Load tsdown.config.ts
Note over tsdown: Config 1: ESM Build
tsdown->>Rolldown: Bundle src/**/*.ts → lib/esm/*.js
Rolldown->>FS: Write 297 ESM files with sourcemaps
Note over tsdown: Config 2: CJS Build
tsdown->>Rolldown: Bundle src/**/*.ts → lib/cjs/*.cjs
Rolldown->>FS: Write 297 CJS files with sourcemaps
Note over tsdown: Config 3: Types Only
tsdown->>Oxc: Generate declarations from src/**/*.ts
Oxc->>Oxc: Parse TypeScript (memory-efficient)
Oxc->>FS: Write 296 .d.ts files to lib/types/
FS->>CI: Build complete
CI->>CI: Run tests against built output
|
Previously, DTS files were generated twice (for ESM and CJS) which
caused out-of-memory errors in CI due to worker memory limits.
Changes:
- Generate types once to lib/types/ using dts: { only: true }
- Remove resolve: true to reduce memory usage (external types are
referenced rather than inlined)
- ESM and CJS builds no longer generate their own types
- Simplify package.json exports to use single types path
- Extract shared entry config to reduce duplication
- Add NODE_OPTIONS to CI for additional memory headroom
This follows the pattern used by Stripe SDK and Hono, where types
are kept in a separate directory and shared between ESM/CJS consumers.
660aba3 to
f9f196f
Compare
Member
Author
dandorman
approved these changes
Dec 4, 2025
nicknisi
added a commit
that referenced
this pull request
Dec 4, 2025
…#1413) ## Description Migrate from tsup to tsdown to fix CI out-of-memory errors during TypeScript declaration generation. ### Problem The build was hitting `ERR_WORKER_OUT_OF_MEMORY` errors in CI on Node 20 and 22. With 297 source files and tsup's worker-based DTS generation, the memory requirements were too high. ### Solution Replace tsup with [tsdown](https://tsdown.dev/), a modern bundler powered by Rolldown (Rust-based) and Oxc. Key benefits: - **Faster builds**: Rolldown is significantly faster than esbuild for bundling - **Lower memory usage**: Oxc-based TypeScript declaration generation is more memory-efficient - **Same output structure**: Maintains the existing `lib/esm`, `lib/cjs`, and `lib/types` directory structure ### Changes - Replaced `tsup` with `tsdown` - Removed `esbuild-fix-imports-plugin` (no longer needed) - Created `tsdown.config.ts` with equivalent configuration - Updated build scripts in `package.json` ### Output - 297 ESM files (`.js`) in `lib/esm/` - 297 CJS files (`.cjs`) in `lib/cjs/` - 296 declaration files (`.d.ts`) in `lib/types/` - All tests pass (427 passed) ## Documentation Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [ ] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.
nicknisi
added a commit
that referenced
this pull request
Dec 16, 2025
…#1413) ## Description Migrate from tsup to tsdown to fix CI out-of-memory errors during TypeScript declaration generation. ### Problem The build was hitting `ERR_WORKER_OUT_OF_MEMORY` errors in CI on Node 20 and 22. With 297 source files and tsup's worker-based DTS generation, the memory requirements were too high. ### Solution Replace tsup with [tsdown](https://tsdown.dev/), a modern bundler powered by Rolldown (Rust-based) and Oxc. Key benefits: - **Faster builds**: Rolldown is significantly faster than esbuild for bundling - **Lower memory usage**: Oxc-based TypeScript declaration generation is more memory-efficient - **Same output structure**: Maintains the existing `lib/esm`, `lib/cjs`, and `lib/types` directory structure ### Changes - Replaced `tsup` with `tsdown` - Removed `esbuild-fix-imports-plugin` (no longer needed) - Created `tsdown.config.ts` with equivalent configuration - Updated build scripts in `package.json` ### Output - 297 ESM files (`.js`) in `lib/esm/` - 297 CJS files (`.cjs`) in `lib/cjs/` - 296 declaration files (`.d.ts`) in `lib/types/` - All tests pass (427 passed) ## Documentation Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [ ] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.
nicknisi
added a commit
that referenced
this pull request
Dec 22, 2025
…#1413) ## Description Migrate from tsup to tsdown to fix CI out-of-memory errors during TypeScript declaration generation. ### Problem The build was hitting `ERR_WORKER_OUT_OF_MEMORY` errors in CI on Node 20 and 22. With 297 source files and tsup's worker-based DTS generation, the memory requirements were too high. ### Solution Replace tsup with [tsdown](https://tsdown.dev/), a modern bundler powered by Rolldown (Rust-based) and Oxc. Key benefits: - **Faster builds**: Rolldown is significantly faster than esbuild for bundling - **Lower memory usage**: Oxc-based TypeScript declaration generation is more memory-efficient - **Same output structure**: Maintains the existing `lib/esm`, `lib/cjs`, and `lib/types` directory structure ### Changes - Replaced `tsup` with `tsdown` - Removed `esbuild-fix-imports-plugin` (no longer needed) - Created `tsdown.config.ts` with equivalent configuration - Updated build scripts in `package.json` ### Output - 297 ESM files (`.js`) in `lib/esm/` - 297 CJS files (`.cjs`) in `lib/cjs/` - 296 declaration files (`.d.ts`) in `lib/types/` - All tests pass (427 passed) ## Documentation Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [ ] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.
nicknisi
added a commit
that referenced
this pull request
Jan 8, 2026
…#1413) Migrate from tsup to tsdown to fix CI out-of-memory errors during TypeScript declaration generation. The build was hitting `ERR_WORKER_OUT_OF_MEMORY` errors in CI on Node 20 and 22. With 297 source files and tsup's worker-based DTS generation, the memory requirements were too high. Replace tsup with [tsdown](https://tsdown.dev/), a modern bundler powered by Rolldown (Rust-based) and Oxc. Key benefits: - **Faster builds**: Rolldown is significantly faster than esbuild for bundling - **Lower memory usage**: Oxc-based TypeScript declaration generation is more memory-efficient - **Same output structure**: Maintains the existing `lib/esm`, `lib/cjs`, and `lib/types` directory structure - Replaced `tsup` with `tsdown` - Removed `esbuild-fix-imports-plugin` (no longer needed) - Created `tsdown.config.ts` with equivalent configuration - Updated build scripts in `package.json` - 297 ESM files (`.js`) in `lib/esm/` - 297 CJS files (`.cjs`) in `lib/cjs/` - 296 declaration files (`.d.ts`) in `lib/types/` - All tests pass (427 passed) Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [ ] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.
nicknisi
added a commit
that referenced
this pull request
Jan 9, 2026
…#1413) Migrate from tsup to tsdown to fix CI out-of-memory errors during TypeScript declaration generation. The build was hitting `ERR_WORKER_OUT_OF_MEMORY` errors in CI on Node 20 and 22. With 297 source files and tsup's worker-based DTS generation, the memory requirements were too high. Replace tsup with [tsdown](https://tsdown.dev/), a modern bundler powered by Rolldown (Rust-based) and Oxc. Key benefits: - **Faster builds**: Rolldown is significantly faster than esbuild for bundling - **Lower memory usage**: Oxc-based TypeScript declaration generation is more memory-efficient - **Same output structure**: Maintains the existing `lib/esm`, `lib/cjs`, and `lib/types` directory structure - Replaced `tsup` with `tsdown` - Removed `esbuild-fix-imports-plugin` (no longer needed) - Created `tsdown.config.ts` with equivalent configuration - Updated build scripts in `package.json` - 297 ESM files (`.js`) in `lib/esm/` - 297 CJS files (`.cjs`) in `lib/cjs/` - 296 declaration files (`.d.ts`) in `lib/types/` - All tests pass (427 passed) Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [ ] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.
nicknisi
added a commit
that referenced
this pull request
Jan 12, 2026
…#1413) Migrate from tsup to tsdown to fix CI out-of-memory errors during TypeScript declaration generation. The build was hitting `ERR_WORKER_OUT_OF_MEMORY` errors in CI on Node 20 and 22. With 297 source files and tsup's worker-based DTS generation, the memory requirements were too high. Replace tsup with [tsdown](https://tsdown.dev/), a modern bundler powered by Rolldown (Rust-based) and Oxc. Key benefits: - **Faster builds**: Rolldown is significantly faster than esbuild for bundling - **Lower memory usage**: Oxc-based TypeScript declaration generation is more memory-efficient - **Same output structure**: Maintains the existing `lib/esm`, `lib/cjs`, and `lib/types` directory structure - Replaced `tsup` with `tsdown` - Removed `esbuild-fix-imports-plugin` (no longer needed) - Created `tsdown.config.ts` with equivalent configuration - Updated build scripts in `package.json` - 297 ESM files (`.js`) in `lib/esm/` - 297 CJS files (`.cjs`) in `lib/cjs/` - 296 declaration files (`.d.ts`) in `lib/types/` - All tests pass (427 passed) Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [ ] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Migrate from tsup to tsdown to fix CI out-of-memory errors during TypeScript declaration generation.
Problem
The build was hitting
ERR_WORKER_OUT_OF_MEMORYerrors in CI on Node 20 and 22. With 297 source files and tsup's worker-based DTS generation, the memory requirements were too high.Solution
Replace tsup with tsdown, a modern bundler powered by Rolldown (Rust-based) and Oxc. Key benefits:
lib/esm,lib/cjs, andlib/typesdirectory structureChanges
tsupwithtsdownesbuild-fix-imports-plugin(no longer needed)tsdown.config.tswith equivalent configurationpackage.jsonOutput
.js) inlib/esm/.cjs) inlib/cjs/.d.ts) inlib/types/Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.