Skip to content

infra: migrate to tsdown#3558

Open
Shinigami92 wants to merge 1 commit intonextfrom
infra-migrate-to-tsdown
Open

infra: migrate to tsdown#3558
Shinigami92 wants to merge 1 commit intonextfrom
infra-migrate-to-tsdown

Conversation

@Shinigami92
Copy link
Member

@Shinigami92 Shinigami92 commented Jul 4, 2025

tsup got a rewrite in Rust using VoidZero rolldown named tsdown

this PR migrates from tsup to tsdown

performance for a build run on my windows PC is pnpm run build from 11s-12s to 7s


GitHub Actions CI

tsdown size is also a bit smaller than tsup

image

@Shinigami92 Shinigami92 added this to the vAnytime milestone Jul 4, 2025
@Shinigami92 Shinigami92 self-assigned this Jul 4, 2025
@Shinigami92 Shinigami92 added the c: infra Changes to our infrastructure or project setup label Jul 4, 2025
@netlify
Copy link

netlify bot commented Jul 4, 2025

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit 22084c5
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/69b8047a7209530008bf3303
😎 Deploy Preview https://deploy-preview-3558.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Jul 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.88%. Comparing base (67defc8) to head (22084c5).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3558   +/-   ##
=======================================
  Coverage   98.88%   98.88%           
=======================================
  Files         886      886           
  Lines        3062     3062           
  Branches      540      556   +16     
=======================================
  Hits         3028     3028           
  Misses         30       30           
  Partials        4        4           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Shinigami92 Shinigami92 marked this pull request as ready for review July 4, 2025 19:17
@Shinigami92 Shinigami92 requested a review from a team as a code owner July 4, 2025 19:17
ejcheng
ejcheng previously approved these changes Jul 4, 2025
@xDivisionByZerox
Copy link
Member

I'll need to verify that this build works as expected using the playground. Might take some time, as it doesn't have any priority for me right now.

@Shinigami92
Copy link
Member Author

I'll need to verify that this build works as expected using the playground. Might take some time, as it doesn't have any priority for me right now.

Sure, take your time. This is not a breaking change and can theoretically merged any time.

I use it already in unuse and here I checked it in the preview docs console.

@Shinigami92 Shinigami92 force-pushed the infra-migrate-to-tsdown branch from c5533ae to d676f11 Compare July 17, 2025 14:19
@Shinigami92 Shinigami92 requested a review from Copilot July 17, 2025 14:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the build toolchain from tsup to tsdown, a Rust-based rewrite of tsup using VoidZero rolldown. The migration aims to improve build performance (from 11-12s to 7s locally, 8s to 5s in CI) while maintaining equivalent functionality.

  • Replaces tsup configuration with tsdown configuration using simplified entry patterns
  • Updates package.json scripts and dependencies to use tsdown instead of tsup
  • Cleans up package.json exports structure by removing redundant nested "default" objects

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
tsup.config.ts Removes the existing tsup configuration file
tsdown.config.ts Adds new tsdown configuration with simplified glob patterns and publint integration
package.json Updates build scripts, dependencies, and cleans up exports structure
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@xDivisionByZerox
Copy link
Member

It took some time - sorry about that.

Multiple things:

  • the PR needs a rebase or merge of the next branch
  • while testing I saw that tsdown has new versions, maybe we want to directly migrate to those
  • tsdown hashes all files, including the "dist/index.js" and the "dist/index.d.ts" file. Because of that, the exports defined in the package.json do not work (ERROR pkg.exports["."].types is ./dist/index.d.ts but the file does not exist.) - this needs to be addressed

@Shinigami92 are you up to the task?

@Shinigami92
Copy link
Member Author

Yes, can look into that.
However right now I can't reach my PC, and my laptop reached 0% battery 🫣 and the power cable isn't strong enough 🥲

@Shinigami92 Shinigami92 force-pushed the infra-migrate-to-tsdown branch from d676f11 to 18a3919 Compare January 9, 2026 11:19
@Shinigami92 Shinigami92 marked this pull request as draft January 9, 2026 11:19
@Shinigami92
Copy link
Member Author

@xDivisionByZerox updated everything

tsdown hashes all files, including the "dist/index.js" and the "dist/index.d.ts" file. Because of that, the exports defined in the package.json do not work (ERROR pkg.exports["."].types is ./dist/index.d.ts but the file does not exist.) - this needs to be addressed

I'm not sure if you e.g. forget to clean something or not, however, tsdown is checking the exports field with publint and on my machine everything looks fine 🤔

@Shinigami92 Shinigami92 marked this pull request as ready for review January 9, 2026 11:26
@xDivisionByZerox
Copy link
Member

I'm not sure if you e.g. forget to clean something or not, however, tsdown is checking the exports field with publint and on my machine everything looks fine 🤔

You are right. I honestly can't tell you what the problem was (invalid dependency cache, legacy artifacts or whatever) - i can now get the project to build on my machine as well.

I'm running into the next problem, tho. I cannot get the CJS (Jest) playground to run probably with a locally linked dependency. You might want to give it a try, because I'm currently at my limit with this jest configuration nonsense...

@Shinigami92 Shinigami92 marked this pull request as draft February 5, 2026 16:32
@Shinigami92 Shinigami92 added the s: needs decision Needs team/maintainer decision label Feb 5, 2026
Comment on lines +74 to +75
"types": "./dist/locale/*.d.ts",
"default": "./dist/locale/*.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this change originates from the removed CJS support?

@ST-DDT
Copy link
Member

ST-DDT commented Mar 7, 2026

I played a bit with the bundler options for #3748 . And it looks like adding @PURE to simpleFaker helps reducing the final bundle size by 5 kB gzipped (since it no longer shows up uselessly). However, tsup removes the annotations during the minification step. tsdown has options to keep it.
I haven't tested tsdown yet, but that might actually help with cutting down final bundle sizes (both for faker as a lib and the user's final bundle).

https://rolldown.rs/reference/OutputOptions.comments

Also if I interpret the OP correctly, then tsdown produces smaller bundle sizes either way, so I will refrain from analysing too deeply why a particular import ended up in the final bundle or not.

We probably should add a tsdown project to our playground to help comparing final vite/tsup/tsdown builds with each other. We might be able to put them all in one project and just call them with different aliases e.g. build:tsdown ...
This should help with finding which exports/consts we need to annotate or not.
Maybe we can even reduce the bundle size for everyone by marking Faker module fields/methods with pure, so they may get stripped if unused.

@ST-DDT
Copy link
Member

ST-DDT commented Mar 14, 2026

@Shinigami92 Can you estimate, when you have time to tackle the remaining tests?

@Shinigami92
Copy link
Member Author

@Shinigami92 Can you estimate, when you have time to tackle the remaining tests?

It's a bit hard for me to make promises, because I just landed in my new job, am a bit ill the last 4 days, managing hobbies like gaming and series.
I didn't have much time left this week and today I'm also away outside with friends...
So sorry that I couldn't fulfill my promise that I come to this this week.
Hopefully next week, I might need to claim dedicated time for this task.

@Shinigami92 Shinigami92 force-pushed the infra-migrate-to-tsdown branch from 18a3919 to 22084c5 Compare March 16, 2026 13:24
@Shinigami92
Copy link
Member Author

I'm running into the next problem, tho. I cannot get the CJS (Jest) playground to run probably with a locally linked dependency. You might want to give it a try, because I'm currently at my limit with this jest configuration nonsense...

Hey @xDivisionByZerox & @ST-DDT, I updated this PR and tried it locally with faker-playground.
It does not work out of the box, but the terminal is telling me that I need to set "allowJs": true in https://github.com/faker-js/playground/blob/main/playgrounds/jest-cjs/tsconfig.json, and when I do so, everything runs green (when switching overrides-for-dev to overrides against this locally build PR).

@Shinigami92 Shinigami92 marked this pull request as ready for review March 16, 2026 13:30
@ST-DDT
Copy link
Member

ST-DDT commented Mar 16, 2026

Does it need the allowJs always or just with the tsdown build?

@Shinigami92
Copy link
Member Author

Does it need the allowJs always or just with the tsdown build?

I just wanted to respond with obviously tsdown only..., but then checked out everything manually and you are right 😲 our jest-cjs playground is just "broken"/miss-configured and fixed by adding this "allowJs": true

without it, it fails in both cases, with it it works green with both cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: infra Changes to our infrastructure or project setup s: needs decision Needs team/maintainer decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants