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

[code-infra] Use tsx instead of ts-node #40428

Merged
merged 1 commit into from
Jan 4, 2024
Merged

Conversation

michaldudak
Copy link
Member

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.

@michaldudak michaldudak requested a review from a team January 4, 2024 10:56
@michaldudak michaldudak added the scope: code-infra Specific to the core-infra product label Jan 4, 2024
@mui-bot
Copy link

mui-bot commented Jan 4, 2024

Netlify deploy preview

https://deploy-preview-40428--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 00b7843

@michaldudak michaldudak marked this pull request as ready for review January 4, 2024 11:11
Copy link
Member

@Janpot Janpot left a 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

@michaldudak michaldudak merged commit 055975a into mui:master Jan 4, 2024
19 of 20 checks passed
@michaldudak michaldudak deleted the use-tsx branch January 4, 2024 11:46
@oliviertassinari oliviertassinari added the core Infrastructure work going on behind the scenes label Jan 4, 2024
@@ -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",
Copy link
Member

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):

Suggested change
"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",

Copy link
Member Author

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).

mnajdova pushed a commit to mnajdova/material-ui that referenced this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes scope: code-infra Specific to the core-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants