Skip to content

Commit d68b648

Browse files
Bartek Wronavogel76
authored andcommitted
Add dbg_node_fs/dbg_node_utils declarations to shell_minimal.js
runtime_debug.js references dbg_node_fs and dbg_node_utils when ENVIRONMENT_MAY_BE_NODE with PTHREADS or WASM_WORKERS, but these variables were only declared in shell.js, not in shell_minimal.js. This caused Closure compiler to fail with JSC_UNDEFINED_VARIABLE for MINIMAL_RUNTIME builds with threading and --closure=1. Add the declarations for both paths: - PTHREADS: inside the existing if(ENVIRONMENT_IS_NODE) block that already imports fs - WASM_WORKERS without PTHREADS: in a new conditional block
1 parent 2cd89c3 commit d68b648

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/shell_minimal.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ if (ENVIRONMENT_IS_NODE) {
107107
var fs = {{{ makeNodeImport('node:fs', false) }}};
108108
defaultPrint = (...args) => fs.writeSync(1, args.join(' ') + '\n');
109109
defaultPrintErr = (...args) => fs.writeSync(2, args.join(' ') + '\n');
110+
#if (ASSERTIONS || RUNTIME_DEBUG || AUTODEBUG)
111+
var utils = {{{ makeNodeImport('node:util', false) }}};
112+
var dbg_node_fs = fs;
113+
var dbg_node_utils = utils;
114+
#endif
110115
}
111116
var out = defaultPrint;
112117
var err = defaultPrintErr;
@@ -115,6 +120,16 @@ var out = (...args) => console.log(...args);
115120
var err = (...args) => console.error(...args);
116121
#endif
117122

123+
#if !PTHREADS && WASM_WORKERS && ENVIRONMENT_MAY_BE_NODE && (ASSERTIONS || RUNTIME_DEBUG || AUTODEBUG)
124+
// Initialize dbg() node module references for WASM_WORKERS without PTHREADS.
125+
// (With PTHREADS these are set in the print setup block above.)
126+
var dbg_node_fs, dbg_node_utils;
127+
if (ENVIRONMENT_IS_NODE) {
128+
dbg_node_fs = {{{ makeNodeImport('node:fs', false) }}};
129+
dbg_node_utils = {{{ makeNodeImport('node:util', false) }}};
130+
}
131+
#endif
132+
118133
// Override this function in a --pre-js file to get a signal for when
119134
// compilation is ready. In that callback, call the function run() to start
120135
// the program.

0 commit comments

Comments
 (0)