feat(standalone): bundle a pinned compiler into the single-executable#11299
Draft
timotheeguerin wants to merge 1 commit into
Draft
feat(standalone): bundle a pinned compiler into the single-executable#11299timotheeguerin wants to merge 1 commit into
timotheeguerin wants to merge 1 commit into
Conversation
commit: |
Contributor
|
❌ There is undocummented changes. Run The following packages have changes but are not documented.
The following packages have already been documented:
Show changes
|
|
You can try these changes here
|
… CLI Build the standalone `tsp` executable with Node's `node --build-sea` (Node >= 25.5) instead of postject, dropping the `@yarnpkg/*` and `postject` bundling dependencies. The pinned compiler is bundled as assets and loaded through a createRequire bridge / module-loader workaround for embedder-only-builtins. Adds an internal `runTypeSpecCli` API (`@typespec/compiler/internals/standalone`) that runs the compiler CLI with an injected `internalTemplateSource`, so the standalone CLI serves the bundled `init` templates from an in-memory asset map — running `tsp init` offline without a package manager, network access, or writing files to disk. `tsp compile` is disallowed without a local project. Also wires up macOS/Windows code-signing for the SEA in the CLI pipelines.
timotheeguerin
force-pushed
the
standalone-bundle-compiler
branch
from
July 18, 2026 21:21
f63a8d8 to
01c7a7f
Compare
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.
Summary
The standalone
tspexecutable now embeds a pinned@typespec/compiler— its code, standard library, andtsp inittemplates — as single-executable assets and serves them from memory, instead of installing the latest compiler withyarnat runtime.As a result, commands like
tsp initandtsp compilework fully offline: no package manager, no network access, and nothing written to disk.Compiler resolution precedence
--server <path>/TYPESPEC_COMPILER_PATH@typespec/compilerresolvable from the cwd (always wins over the bundled one)How it works
node --build-sea(Node.js 25.5+); the CLI pipeline now uses Node 26.x. End users need no Node.js installed.await, which a CommonJS single-executable main can't) and loaded from memory viamodule.registerHooks.@typespec/compiler/internals:createBundledCompilerHost(base, assets)returns aCompilerHostthat serves the compiler's own files from an in-memory asset map, delegating everything else to the base host (no mutation of the sharedNodeHost).setCliBaseHost(host)injects that host as the base used by every CLI action.yarn/postjectbuild dependencies are removed.Temporary workarounds (each tagged
WORKAROUND(...)in code, tracked upstream)createRequire(process.execPath).require("esprima")warns under SEA (nodejs/node#50547); it is stripped at bundle time.Validation
pnpm build+ type-checks (compiler, standalone)check.ts: command runs, bundled offline compile, and local-compiler precedencecreateBundledCompilerHostunit tests + existinginternalsguard /inittemplate tests