microsoft/TypeScript · error · Error
LKG cannot be created when --bundle=false
Error message
LKG cannot be created when --bundle=false
What it means
The `LKG` (Last Known Good) hereby task copies freshly built JS into lib/ so the compiler can self-host. It is gated on the `--bundle` CLI option because the LKG must contain the bundled entrypoints (_tsc.js, _tsserver.js, etc.); without bundling the LKG would be incomplete and break the self-host build.
Source
Thrown at Herebyfile.mjs:903
// path here seems like a bad idea.
export const updateSublime = task({
name: "update-sublime",
description: "Updates the sublime plugin's tsserver",
dependencies: [tsserver],
run: async () => {
for (const file of ["built/local/tsserver.js", "built/local/tsserver.js.map"]) {
await fs.promises.copyFile(file, path.resolve("../TypeScript-Sublime-Plugin/tsserver/", path.basename(file)));
}
},
});
export const produceLKG = task({
name: "LKG",
description: "Makes a new LKG out of the built js files",
dependencies: [local],
run: async () => {
if (!cmdLineOptions.bundle) {
throw new Error("LKG cannot be created when --bundle=false");
}
const expectedFiles = [
"built/local/tsc.js",
"built/local/_tsc.js",
"built/local/tsserver.js",
"built/local/_tsserver.js",
"built/local/tsserverlibrary.js",
"built/local/tsserverlibrary.d.ts",
"built/local/typescript.js",
"built/local/typescript.d.ts",
"built/local/typingsInstaller.js",
"built/local/_typingsInstaller.js",
"built/local/watchGuard.js",
].concat(libs().map(lib => lib.target));
const missingFiles = expectedFiles
.concat(localizationTargets)
.filter(f => !fs.existsSync(f));
View on GitHub (pinned to b465fdbfe1)
Solutions
- Run `hereby LKG --bundle` (pass --bundle explicitly).
- Ensure `hereby local` completed successfully first, then re-run with --bundle.
- If you intentionally never bundle, do not run the LKG task — it is not meaningful without bundling.
Example fix
// before $ hereby LKG // after $ hereby LKG --bundle
Defensive patterns
Strategy: validation
Validate before calling
// Before running LKG, confirm the bundle flag is set.
if (!cmdLineOptions.bundle) {
throw new Error("Refusing to run produceLKG without --bundle; pass --bundle on the hereby CLI.");
} Prevention
- Always invoke `hereby LKG --bundle`.
- Wire CI to fail fast if the LKG task is called without --bundle.
- Document that LKG depends on a bundled `local` build.
When it happens
Trigger: Running `hereby LKG` (or the produce-LKG task) without passing `--bundle` on the hereby command line, so `cmdLineOptions.bundle` is false.
Common situations: Skipping the bundle flag for a faster local cycle; CI that invokes the LKG task directly without forwarding --bundle.
Related errors
- Cannot replace the LKG unless all built targets are present
- Expected ${inputDir} to be a directory
- Expected ${inputFile} to be a file
- tsserverlibrary requires CommonJS; use typescript.js instead
- Diagnostic code ${code} appears more than once.
AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12).
Data as JSON: /api/errors/bedf420675e346f8.
Report an issue: GitHub.