-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[code-infra] Use tsx instead of ts-node #40428
Conversation
Netlify deploy previewhttps://deploy-preview-40428--material-ui.netlify.app/ Bundle size report |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 We've switched to tsx
on Toolpad as well
@@ -34,7 +34,7 @@ | |||
"docs:typescript:formatted": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/formattedTSDemos", | |||
"docs:mdicons:synonyms": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js,.mjs\" ./docs/scripts/updateIconSynonyms && pnpm prettier", | |||
"extract-error-codes": "cross-env MUI_EXTRACT_ERROR_CODES=true lerna run --concurrency 8 build:modern", | |||
"rsc:build": "ts-node ./packages/rsc-builder/buildRsc.ts", | |||
"rsc:build": "tsx ./packages/rsc-builder/buildRsc.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't want to depend on either (ts-node, tsx), this would work as well (has a slower startup time):
"rsc:build": "tsx ./packages/rsc-builder/buildRsc.ts", | |
"rsc:build": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./packages/rsc-builder/buildRsc.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
babel-node is problematic when running ESM scripts. It doesn't read tsconfig, so we're can't set module and resolution strategy (at least not as simply as in tsconfig). I'd rather use tsconfigs for this and slowly phase Babel away (to be able to use SWC in Next JS).
With ts-node having problems with newer versions of Node (TypeStrong/ts-node#2094) and being hard to configure properly with aliases (problems such as https://app.circleci.com/pipelines/github/mui/material-ui/117126/workflows/61940872-34d1-443b-bb13-9b0b87eaa785/jobs/629297, https://app.circleci.com/pipelines/github/mui/material-ui/117126/workflows/61940872-34d1-443b-bb13-9b0b87eaa785/jobs/629298, and numerous others surfaced during the pnpm migration), I decided to replace it with tsx.
It just works, without the need of installing additional path resolvers, no matter if the script is ESM or CJS. With tsx the issues on CI I linked above are gone.
With this change, I also unpinned the Node version on the CI.