-
-
Notifications
You must be signed in to change notification settings - Fork 258
chore(dev): Replace ts-node with tsx #6481
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
Conversation
`tsx` has a couple of advantages over `ts-node`: - Running a script with `tsx` is about 20% faster than with `ts-node`. - `tsx` is also easier to use. I've had problems where `ts-node` doesn't seem to honor the TypeScript config like `tsc` does, but `tsx` "just works".
|
All alerts resolved. Learn more about Socket for GitHub. This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. Ignoring alerts on: |
|
@SocketSecurity ignore npm/[email protected] We have disabled the |
|
@SocketSecurity ignore npm/[email protected] I reviewed this and I don't think this is an issue. I believe |
## Explanation ### What is the current state of things and why does it need to change? The `publish-preview.yml` GitHub Actions workflow is still using `ts-node` to execute the `generate-preview-build-message.ts` script. However, the project has recently migrated from `ts-node` to `tsx` [PR](#6481) ## References - N/A ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - No test changes needed for this workflow update - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - No documentation changes needed - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - No changelog needed as this is an internal workflow change - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes - No breaking changes - internal workflow update only <!-- CURSOR_SUMMARY --> --- > [!NOTE] > <sup>[Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) is generating a summary for commit 8aea010. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
) ## **Description** This change mirrors the successful optimization implemented in [MetaMask/core#6481](https://github.com/MetaMask/core/pull/6481/files) and provides significant performance improvements for TypeScript script execution in large monorepos. ## **Related issues** Fixes: N/A ## **Manual testing steps** - [x] Run `yarn lint` and verify it completes successfully without hanging - [x] Run `yarn lint:eslint` individually to confirm ESLint processing works - [x] Test `yarn create-component:react` to ensure component generation still works - [x] Test `yarn update-readme-content` to verify documentation scripts work - [x] Verify all other scripts using TypeScript execution continue to function ## **Screenshots/Recordings** Not applicable - this is a build/tooling performance optimization without visual changes. ## **Pre-merge author checklist** - [x] I have reviewed the Files changed tab - [x] All CI checks pass (yarn lint now works without hanging) - [x] The same scripts work in all workspace packages - [x] All TypeScript script executions use the faster `tsx` instead of `ts-node` - [x] LavaMoat configuration updated to allow `tsx>esbuild` instead of `ts-node>@swc/core` - [x] Dependency configuration updated in depcheck to ignore `tsx` instead of `ts-node` - [x] Script shebang lines updated in all affected files - [x] I have tested this PR on my local machine ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. ## **Technical Details** **Files Changed:** - **Root package.json**: Updated 3 scripts (`create-package`, `lint:eslint`, `update-readme-content`) - **Dependency updates**: Replaced `ts-node` with `tsx` in devDependencies - **LavaMoat config**: Updated to allow `tsx>esbuild` instead of `ts-node>@swc/core` - **Package scripts**: Updated React and React Native packages to use `tsx` - **Build scripts**: Updated shebang lines and direct script calls - **Depcheck config**: Updated to ignore `tsx` instead of `ts-node` **Performance Impact:** - **Before**: `yarn lint` would hang indefinitely - **After**: `yarn lint` completes successfully in reasonable time - **Benefit**: Enables faster development cycles and unblocks CI/CD pipelines **References:** - Inspired by MetaMask/core optimization: https://github.com/MetaMask/core/pull/6481/files - `tsx` documentation: https://github.com/esbuild-kit/tsx <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Replace ts-node with tsx for TypeScript scripts, updating scripts, configs, shebangs, and dependencies. > > - **Tooling**: > - Migrate TypeScript script runner from `ts-node` to `tsx` across repo. > - Update script invocations in root `package.json` (`create-package`, `lint:eslint`, `update-readme-content`). > - Switch package scripts in `packages/design-system-react` and `packages/design-system-react-native` (`create-component`, `generate-icons`, `generate-icons:index`). > - Update build step in `packages/design-system-react-native/scripts/build.js` to call `tsx`. > - Change shebangs in `scripts/generate-preview-build-message.ts` and `scripts/update-readme-content.ts` to `#!yarn tsx`. > - **Config**: > - Update LavaMoat `allowScripts` from `ts-node>@swc/core` to `tsx>esbuild`. > - Adjust `.depcheckrc.yml` ignores to `tsx`. > - **Dependencies**: > - Remove `ts-node`; add `tsx` and related `esbuild` entries; refresh `yarn.lock`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit d403f8d. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Explanation
tsxhas a couple of advantages overts-node:tsxis about 20% faster than withts-node.tsxis also easier to use. I've run into problems in the past wherets-nodedoesn't seem to honor the TypeScript config liketscdoes, buttsx"just works".References
(N/A)
Checklist
Note
Switches TypeScript script runner from ts-node to tsx and updates scripts, shebangs, and dependencies accordingly.
ts-nodewithtsxacross script runners inpackage.json(create-package,generate-method-action-types,lint:eslint,lint:teams,update-readme-content).scripts/generate-method-action-types.ts,scripts/generate-preview-build-message.ts, andscripts/update-readme-content.tsto#!yarn tsx.ts-node→tsx; updatelavamoat.allowScriptsto includetsx>esbuild.yarn.lock: removets-node(and related packages) and addtsxwithesbuildplatform binaries and related entries.Written by Cursor Bugbot for commit 2076008. This will update automatically on new commits. Configure here.