Avoid TypeScript 7 startup crash by loading transpilation lazily - #4724
Open
KiritoYG wants to merge 1 commit into
Open
Avoid TypeScript 7 startup crash by loading transpilation lazily#4724KiritoYG wants to merge 1 commit into
KiritoYG wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #4706.
With TypeScript 7 installed, eagerly importing the Rollup TypeScript plugin throws at
ModuleKind.ES2015before any CLI command can run. Defer the compiler and Rollup imports until transpilation is requested, and check for the traditional JavaScript compiler API before initializing the plugins. Circuit builds that do not enable transpilation,--help, and--versioncan run;transpileandbuild --transpileexit with an actionable compatibility message that recommends TypeScript 5.9.3.Add a subprocess regression that reproduces TypeScript 7's version-only main export without changing the compiler used by other tests. It checks successful non-transpiling builds and board/component output, successful help/version commands, and nonzero exits with the compatibility diagnostic for both explicit transpilation commands and
build.typescriptLibrary: trueconfiguration.Validation on Windows x64, Bun 1.4.2:
ModuleKind.ES2015startup error.tests/cli/transpile/transpile.test.tsandtests/cli/build/build-transpile.test.ts: 11 tests, 55 assertions passed, including ESM, CommonJS, declarations and explicit.ts/.tsxextension handling.bun run build,bun x --no-install tsc --noEmit, formatting of both changed files, dependency policy check, andgit diff --checkpassed.dist/cli/main.jswith the actual npm TypeScript 7.0.2 package, not a mock. Eager plugin import reproduced the original error. Help, version and a one-resistor circuit build exited 0; the circuit output contained a board and R1. Both transpilation commands exited 1 with the compatibility/install message. Restored TypeScript 5.9.3 afterward.This protects startup and non-transpiling circuit builds; it does not port transpilation or other compiler-API-dependent features to TypeScript 7. In particular,
tsci devstill has dependency-analysis code that uses the old compiler API and remains outside this fix.build --cienables transpilation on its normal build path (a custombuildCommandcan handle the command earlier), andbuild.typescriptLibrary: trueenables it through configuration; these paths still require a compatible compiler. Full end-to-enddevand--ciruns were not performed. No new dependencies or lockfile changes.Validation caveat: one existing Windows test embeds an unescaped absolute path into generated TSX and does not assert its child exit code. Its test assertions passed although that child circuit build reported an import error. The new compatibility regression asserts exit codes explicitly. The entire repository suite and Linux CI have not been run locally.
AI assistance: implementation and verification were coordinated with Codex, with an independent source review by Claude. The review's suggestions were checked against the repository and verified behavior before finalizing this patch.