fix(compile): ensure Deno.build.standalone is set in workers (#30335)

Closes https://github.com/denoland/deno/issues/30318
This commit is contained in:
David Sherret 2025-08-06 16:12:57 +02:00 committed by GitHub
parent 038d5a5331
commit ff8bdcd987
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 4 deletions

View file

@ -1025,7 +1025,11 @@ function bootstrapWorkerRuntime(
6: argv0, 6: argv0,
7: nodeDebug, 7: nodeDebug,
13: otelConfig, 13: otelConfig,
15: standalone,
} = runtimeOptions; } = runtimeOptions;
denoNs.build.standalone = standalone;
closeOnIdle = runtimeOptions[14]; closeOnIdle = runtimeOptions[14];
performance.setTimeOrigin(); performance.setTimeOrigin();

View file

@ -3,17 +3,17 @@
"tests": { "tests": {
"compiled": { "compiled": {
"steps": [{ "steps": [{
"args": "compile --output main main.ts", "args": "compile --allow-read --output main --include worker.ts main.ts",
"output": "[WILDCARD]" "output": "[WILDCARD]"
}, { }, {
"commandName": "./main", "commandName": "./main",
"args": [], "args": [],
"output": "true\n" "output": "true\ntrue\n"
}] }]
}, },
"run": { "run": {
"args": "run --quiet --check main.ts", "args": "run --quiet --check --allow-read main.ts",
"output": "false\n" "output": "false\nfalse\n"
} }
} }
} }

View file

@ -1,2 +1,6 @@
const value: boolean = Deno.build.standalone; const value: boolean = Deno.build.standalone;
console.log(value); console.log(value);
new Worker(import.meta.resolve("./worker.ts"), {
"type": "module",
});

View file

@ -0,0 +1,4 @@
// ensure this is properly set in a worker
const value: boolean = Deno.build.standalone;
console.log(value);
self.close();