Commit 14fdc3b
Bartek Wrona
Fix dbg() to use lazy-initialized node modules for ESM compatibility
The previous fix moved await import() for node:fs and node:util outside
dbg() to module scope. This broke test_dbg because dbg() can be called
from --pre-js before those module-scope imports execute.
Use lazy initialization instead: declare dbg_node_fs/dbg_node_utils
early but leave them undefined. Initialize them in shell.js after fs
and utils are loaded (reusing the same imports). dbg() checks if the
modules are available and falls back to console.warn if not.
This handles all cases:
- dbg() from --pre-js (before init): uses console.warn
- dbg() after init on Node.js with pthreads: uses fs.writeSync
- dbg() in browser/non-node: uses console.warn1 parent 2b964d5 commit 14fdc3b
2 files changed
+12
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
20 | 16 | | |
21 | 17 | | |
22 | 18 | | |
23 | 19 | | |
24 | 20 | | |
25 | 21 | | |
26 | | - | |
| 22 | + | |
27 | 23 | | |
28 | 24 | | |
29 | | - | |
| 25 | + | |
30 | 26 | | |
31 | 27 | | |
32 | 28 | | |
33 | 29 | | |
34 | | - | |
| 30 | + | |
35 | 31 | | |
36 | 32 | | |
37 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
350 | 355 | | |
351 | 356 | | |
352 | 357 | | |
| |||
0 commit comments