chore: replace tsx with plain Node - #10564
Conversation
There was a problem hiding this comment.
bridge-controller and bridge-status-controller didn't have a messenger-action-types:check or messenger-action-types:generate, allowing this file to become out-of-date.
There was a problem hiding this comment.
Still need to add this to yarn.config.cjs. I'll file a ticket.
There was a problem hiding this comment.
This is unfortunately needed for a few reasons:
- Some of our scripts import from
@metamask/utils, which resolves to@metamask/utils/dist/...jswhich doesn't exist in CI. - Some packages run an E2E-style test of a CLI (
messenger-cli,platform-api-docs,wallet-cli) which references source files with.jsimports. - Most packages run the messenger CLI to generate action types, referencing the source files with
.jsimports.
Part of this file should be temporary. Once we update packages to use .ts imports everywhere, we can drop the .js to .ts resolution. Unfortunately I'm not sure if we can get around the @metamask/utils resolution without replacing the functionality in the scripts.
There was a problem hiding this comment.
This seems okay for now. It's pretty small. I wonder if once we split up @metamask/utils into smaller packages we won't need to have separate exports (we'll just say, for instance, in order to use the @metamask/fs-utils package, you'll need to use Node).
| "lint:tsconfigs:fix": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.ts --fix", | ||
| "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --check", | ||
| "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --generate", | ||
| "lint:tsconfigs": "node --import ../../scripts/resolver/register.ts --experimental-transform-types ../../scripts/lint-tsconfigs/lint-tsconfigs.ts", |
There was a problem hiding this comment.
We need --experimental-transform-types because @metamask/utils uses enums. We can remove this if we replace the enums.
There was a problem hiding this comment.
This gives us time to migrate utils so I'm okay with it. It's good that once we don't need this we can quickly remove it via yarn.config.cjs too.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2f0ec41. Configure here.
Matches the direction of #10564, which drops tsx. Reading and writing the suppressions file with node:fs rather than @metamask/utils means these scripts need no resolver hook, so plain node runs them today and after that lands. Also checks for ENOENT structurally, as the errors Node raises are not always instanceof the Error of the realm that catches them.
There was a problem hiding this comment.
This seems okay for now. It's pretty small. I wonder if once we split up @metamask/utils into smaller packages we won't need to have separate exports (we'll just say, for instance, in order to use the @metamask/fs-utils package, you'll need to use Node).
| "lint:tsconfigs:fix": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.ts --fix", | ||
| "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --check", | ||
| "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --generate", | ||
| "lint:tsconfigs": "node --import ../../scripts/resolver/register.ts --experimental-transform-types ../../scripts/lint-tsconfigs/lint-tsconfigs.ts", |
There was a problem hiding this comment.
This gives us time to migrate utils so I'm okay with it. It's good that once we don't need this we can quickly remove it via yarn.config.cjs too.
Matches the direction of #10564, which drops tsx. Reading and writing the suppressions file with node:fs rather than @metamask/utils means these scripts need no resolver hook, so plain node runs them today and after that lands. Also checks for ENOENT structurally, as the errors Node raises are not always instanceof the Error of the realm that catches them.
Matches the direction of #10564, which drops tsx. Reading and writing the suppressions file with node:fs rather than @metamask/utils means these scripts need no resolver hook, so plain node runs them today and after that lands. Also checks for ENOENT structurally, as the errors Node raises are not always instanceof the Error of the realm that catches them.
Matches the direction of #10564, which drops tsx. Reading and writing the suppressions file with node:fs rather than @metamask/utils means these scripts need no resolver hook, so plain node runs them today and after that lands. Also checks for ENOENT structurally, as the errors Node raises are not always instanceof the Error of the realm that catches them.

Explanation
Modern versions of Node.js support running TypeScript files by default, so we can drop the
tsxdependency.This is in preparation for #9937, as
tsxrequests too many permissions by default.References
Checklist
Note
Medium Risk
Wide CI and developer-tooling surface area depends on experimental Node TypeScript flags and the custom resolver; regressions would break lint, type generation, and workflows rather than shipped wallet logic.
Overview
Replaces
tsxacross the monorepo with Node.js running TypeScript directly, using--experimental-transform-typesand a newscripts/resolver/register.tshook so existing.jsimport paths and some package resolutions (e.g.@metamask/utils) still work at runtime.Root and workspace
package.jsonscripts for lint, messenger action types, changelog/codeowners helpers, and similar tooling now invokenode(with the resolver where needed).tsxis removed from devDependencies repo-wide, LavaMoat dropstsx>esbuild, and GitHub Actions call yarn scripts likeget-changed-workspacesandclose-stale-release-prsinstead ofyarn tsx scripts/....messenger-cliandplatform-api-docstests were updated to spawn the CLI the same way CI does;bridge-controller/bridge-status-controlleralign onmessenger-cliscripts (replacing the old generate-method-action-types entry), with a regenerated ordering tweak in bridge-status method action types.Reviewed by Cursor Bugbot for commit 20ac37f. Bugbot is set up for automated code reviews on this repo. Configure here.