Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build): use native typescript compiler #64178

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

stephenliang
Copy link
Member

The default for esbuild/tsup is to use the microsoft api extractor, to generate typescript declarations. However, this appears to result in some memory leaks which ends up causing the build time of declaration files to take very long. This then causes watchers on the webpack side to receive updated javascript but without its associated declarations.

Instead, noting that the official documentation says to use tsc, the tsup onSuccess hook is then used to generate the typescript declarations in the same manner as before, except using tsc. The net result is that the declarations are generated significantly faster, about 2 seconds vs the previous 30-60 seconds.

@stephenliang stephenliang requested a review from a team February 26, 2025 22:56
The default for esbuild/tsup is to use the microsoft api extractor,
to generate typescript declarations. However, this appears to result in
some memory leaks which ends up causing the build time of declaration
files to take very long. This then causes watchers on the webpack side
to receive updated javascript but without its associated declarations.

Instead, noting that the [official documentation](https://tsup.egoist.dev/#generate-declaration-file) says
to use `tsc`, the tsup `onSuccess` hook is then used to generate the
typescript declarations in the same manner as before, except using
`tsc`. The net result is that the declarations are generated
significantly faster, about 2 seconds vs the previous 30-60 seconds.
@stephenliang stephenliang force-pushed the stephen/improve-tsup-devex branch from 6690ff7 to 8074fc3 Compare February 26, 2025 23:01
Copy link

github-actions bot commented Feb 26, 2025

🖼️ Visual Comparison Report

✅ No eyes differences detected!

Copy link
Contributor

@snickell snickell left a comment

Choose a reason for hiding this comment

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

big win!

@@ -24,6 +24,7 @@
"lint": "turbo lint",
"lint:fix": "turbo lint:fix",
"release:dryrun": "turbo release:dryrun",
"start": "yarn dev",
Copy link
Contributor

Choose a reason for hiding this comment

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

Appreciate the operational consistency detail here

"lint": "eslint .",
"lint:fix": "eslint --fix .",
"prepack": "clean-package",
"postpack": "clean-package restore",
"prettier": "prettier --check .",
"prettier:fix": "prettier --write .",
"release": "release-it --preRelease=alpha",
"start": "yarn dev",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"start": "yarn dev",
"start": "cd .. && yarn start --filter @code-dot-org/component-library",

Just an idea, I'm guessing tsup --watch here doesn't end up rolling the build up far enough for apps to see?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants