Skip to content

Comments

refactor: swap rollup with native rolldown (using tsdown)#6789

Merged
juliusmarminge merged 28 commits intomainfrom
tsdown
Jun 12, 2025
Merged

refactor: swap rollup with native rolldown (using tsdown)#6789
juliusmarminge merged 28 commits intomainfrom
tsdown

Conversation

@juliusmarminge
Copy link
Member

@juliusmarminge juliusmarminge commented May 27, 2025

Closes #6814
Closes #6554

trying out swapping out rollup for rolldown powered tsdown

Preview builds:

pnpm add @trpc/[email protected]
pnpm add @trpc/[email protected]
pnpm add @trpc/[email protected]
pnpm add @trpc/[email protected]
pnpm add @trpc/[email protected]

Summary by CodeRabbit

Summary by CodeRabbit

  • Refactor

    • Migrated build system from Rollup to tsdown across all packages for improved dual ESM/CJS output and explicit type exports.
    • Updated package exports to provide clearer import/require paths and associated type declarations.
    • Simplified and unified build scripts and configuration files for consistency.
    • Enhanced entrypoint generation to produce package.json files per entrypoint directory instead of barrel files.
  • Chores

    • Removed obsolete scripts and configuration files related to Rollup, entrypoint generation scripts, and bundle size analysis.
    • Cleaned up dependencies and updated build-related package metadata.
    • Adjusted internal tooling and configuration to align with the new build process.
    • Updated task names in turbo.json from "codegen-entrypoints" to "build".
  • Style

    • Improved consistency in output file extensions and export structure across packages.

No changes to user-facing APIs or functionality.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 27, 2025

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

📥 Commits

Reviewing files that changed from the base of the PR and between e3f2162 and a7f29fb.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • examples/.test/internal-types-export/package.json (1 hunks)
  • examples/.test/internal-types-export/src/server.ts (1 hunks)
  • examples/.test/internal-types-export/tsconfig.json (1 hunks)
  • examples/.test/internal-types-export/tsdown.config.ts (1 hunks)
  • packages/server/src/@trpc/server/index.ts (3 hunks)
  • packages/server/src/unstable-core-do-not-import/initTRPC.ts (4 hunks)
  • packages/server/src/unstable-core-do-not-import/router.ts (3 hunks)
 __________________________________________________________________
< Series-A funding secured. Now, I can afford to review your code. >
 ------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

Walkthrough

This update migrates the build system from Rollup (and related scripts) to tsdown across multiple packages. All Rollup configuration files, SWC dependencies, and entrypoint scripts are removed. New tsdown.config.ts files are introduced, and package exports are restructured for explicit dual ESM/CJS outputs with corresponding type declarations. Several package.json files and turbo tasks are updated to reflect these changes.

Changes

File(s) Change Summary
.vscode/settings.json Commented out the "explorer.excludeGitIgnore": true setting.
package.json; packages/client/package.json; packages/next/package.json; packages/react-query/package.json; packages/server/package.json; packages/tanstack-react-query/package.json; packages/upgrade/package.json Migrated build scripts from Rollup (and bunchee for upgrade) to tsdown. Updated main/module/types fields and restructured exports for dual ESM/CJS outputs with explicit type paths. Updated devDependencies accordingly.
packages/client/rollup.config.ts; packages/next/rollup.config.ts; packages/react-query/rollup.config.ts; packages/server/rollup.config.ts; packages/tanstack-react-query/rollup.config.ts Deleted all Rollup configuration files.
packages/client/tsdown.config.ts; packages/next/tsdown.config.ts; packages/react-query/tsdown.config.ts; packages/server/tsdown.config.ts; packages/tanstack-react-query/tsdown.config.ts; packages/upgrade/tsdown.config.ts Added tsdown configuration files specifying input sources, output formats, custom extensions, and post-build entrypoint generation logic.
packages/client/entrypoints.script.ts; packages/next/entrypoints.script.ts; packages/react-query/entrypoints.script.ts; packages/server/entrypoints.script.ts; packages/tanstack-react-query/entrypoints.script.ts Deleted entrypoint generation scripts.
packages/client/turbo.json; packages/next/turbo.json; packages/react-query/turbo.json; packages/server/turbo.json; packages/tanstack-react-query/turbo.json Renamed turbo task from "codegen-entrypoints" to "build", updating outputs as needed.
scripts/getRollupConfig.ts; scripts/analyzeSizeChange.ts Deleted Rollup and bundle analysis utility scripts.
scripts/entrypoints.ts Updated to support new package.json structure: sets main/module/types, nested exports with import/require, generates per-entrypoint package.json files, and updates turbo.json for the "build" task.
packages/server/src/unstable-core-do-not-import/http/contentType.ts Replaced use of unsetMarker symbol with a unique symbol for memoization cache sentinel.
packages/server/src/unstable-core-do-not-import/utils.ts Removed exported unsetMarker symbol; introduced branded string type alias UnsetMarker.
packages/server/tsconfig.json; tsconfig.build.json Simplified TypeScript configuration: removed explicit module/moduleResolution options and set "module" to "Preserve" in build config.
turbo.json Removed "codegen-entrypoints" task and its dependency from the "build" task.
www/docusaurus.typedoc.js Refined type annotation for package exports and adjusted extraction logic to access nested import.default fields.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Tsdown as tsdown
    participant Entrypoints as entrypoints.ts
    participant Turbo as turbo.json

    Dev->>Tsdown: Run build (tsdown)
    Tsdown->>Entrypoints: onSuccess: generateEntrypoints(inputs)
    Entrypoints->>Entrypoints: Update package.json (main/module/types, exports)
    Entrypoints->>Entrypoints: Generate per-entrypoint package.json
    Entrypoints->>Turbo: Update build task outputs in turbo.json
    Entrypoints-->>Tsdown: Done
    Tsdown-->>Dev: Build complete (dual ESM/CJS outputs)
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure @trpc/server can be properly bundled with tsc + tsdown (issue #6814) Migration to tsdown build and restructuring of exports addresses bundling issues.
Provide dedicated ESM type exports for @trpc/tanstack-react-query to fix type incompatibility (issue #6554) Package.json updated with "type": "module" and dual ESM/CJS exports with explicit typings.

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected related to the linked issues.

Suggested reviewers

  • juliusmarminge

Poem

A hop, a skip, a build anew—
Rollup hops out, tsdown hops through!
Entrypoints pruned, configs refined,
Dual outputs now so well-aligned.
With every leap, the code grows bright,
A rabbit’s cheer for builds done right!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch tsdown
  • Post Copyable Unit Tests in Comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel
Copy link

vercel bot commented May 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-prisma-starter ✅ Ready (Inspect) Visit Preview Jun 12, 2025 10:18am
og-image ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2025 10:18am
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2025 10:18am

@railway-app
Copy link

railway-app bot commented May 27, 2025

🚅 Deployed to the trpc-pr-6789 environment in trpc-sse-and-websockets

Service Status Web Updated (UTC)
next-sse-chat ◻️ Removed (View Logs) Web Jun 12, 2025 at 11:16 am
next-prisma-websockets-starter ◻️ Removed (View Logs) Jun 12, 2025 at 11:16 am

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 27, 2025

Open in StackBlitz

@trpc/client

npm i https://pkg.pr.new/trpc/trpc/@trpc/client@6789

@trpc/next

npm i https://pkg.pr.new/trpc/trpc/@trpc/next@6789

@trpc/react-query

npm i https://pkg.pr.new/trpc/trpc/@trpc/react-query@6789

@trpc/server

npm i https://pkg.pr.new/trpc/trpc/@trpc/server@6789

@trpc/tanstack-react-query

npm i https://pkg.pr.new/trpc/trpc/@trpc/tanstack-react-query@6789

@trpc/upgrade

npm i https://pkg.pr.new/trpc/trpc/@trpc/upgrade@6789

commit: c2e0ec0

@juliusmarminge juliusmarminge merged commit b042613 into main Jun 12, 2025
47 checks passed
@juliusmarminge juliusmarminge deleted the tsdown branch June 12, 2025 11:16
@github-actions
Copy link
Contributor

This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: trpc server cannot be properly bundled with tsc + tsdown bug: Type incompatibility between @trpc/tanstack-react-query and @tanstack/react-query

2 participants