File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change
1
+ const { pathToFileURL} = require ( 'url' ) ;
2
+
3
+ // Hack to avoid Module.runMain on node 18.6.0
4
+ // Keeping it simple for now, isolated in this file.
5
+ // Could theoretically probe `getFormat` impl to determine if `import()` or `Module._load()` is best
6
+ // Note that I attempted a try-catch around `Module._load`, but it poisons some sort of cache such that subsequent `import()` is impossible.
7
+ exports . run = function ( entryPointPath ) {
8
+ import ( pathToFileURL ( entryPointPath ) ) ;
9
+ }
Original file line number Diff line number Diff line change @@ -639,7 +639,15 @@ function phase4(payload: BootstrapState) {
639
639
640
640
// Execute the main contents (either eval, script or piped).
641
641
if ( executeEntrypoint ) {
642
- Module . runMain ( ) ;
642
+ if (
643
+ payload . isInChildProcess &&
644
+ versionGteLt ( process . versions . node , '18.6.0' )
645
+ ) {
646
+ // HACK workaround node regression
647
+ require ( '../dist-raw/runmain-hack.js' ) . run ( entryPointPath ) ;
648
+ } else {
649
+ Module . runMain ( ) ;
650
+ }
643
651
} else {
644
652
// Note: eval and repl may both run, but never with stdin.
645
653
// If stdin runs, eval and repl will not.
You can’t perform that action at this time.
0 commit comments