Skip to content

Commit fe5ce2e

Browse files
committed
docs(transpile): record the shared "child node via process.execPath" invariant
Both of the extension's child-Node spawns follow one invariant - launch via process.execPath, never a bare "node" PATH lookup the host may not satisfy - but only esbuild's path (through ensureNodeOnPath) documented it. Name node-runtime.ts as the invariant's home and cross-reference it from the sslc compiler's fork, so the two sites cannot silently diverge and the next reader finds one explanation. A literal shared launcher was considered and rejected as premature abstraction: we own sslc's fork but not esbuild's internal spawn, and the two sites are structurally unalike (a process manager vs a one-line PATH tweak), so only the invariant is unified, not code. Comment-only; no behavior change.
1 parent 8bea7a5 commit fe5ce2e

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

server/src/sslc/ssl_compiler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ export async function ssl_compile(opts: {
6262

6363
let p;
6464
try {
65+
// fork() launches process.execPath - the extension host's own runtime - so, unlike
66+
// esbuild's internal spawn("node"), the built-in compiler needs no PATH shim. Both of
67+
// this extension's child-Node spawns follow one invariant: launch via process.execPath,
68+
// never a bare "node" PATH lookup (esbuild reaches it via ensureNodeOnPath in
69+
// transpilers/common/node-runtime.ts, which is the documented home of that invariant).
6570
p = fork(COMPILER_MODULE, cmdArgs, {
6671
execArgv: [], // Disable Node.js flags like --inspect
6772
cwd: opts.cwd,

transpilers/common/node-runtime.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
* rather than resolving "node". We cannot change esbuild's spawn, but we can make "node"
1111
* resolve to process.execPath by pointing PATH at it - applied ONLY when "node" is not
1212
* already resolvable, so a host that already has Node is left untouched (zero regression).
13+
*
14+
* Extension-wide invariant (this module is its documented home): every child Node process
15+
* launches via process.execPath - the runtime already executing our code - never a bare
16+
* "node" PATH lookup the host may not satisfy. sslc gets this from child_process.fork's
17+
* default (server/src/sslc/ssl_compiler.ts); esbuild's dep-internal spawn gets it from
18+
* ensureNodeOnPath below.
1319
*/
1420

1521
import * as fs from "fs";

0 commit comments

Comments
 (0)