File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -630,7 +630,7 @@ function phase4(payload: BootstrapState) {
630
630
if ( executeEntrypoint ) {
631
631
if (
632
632
payload . isInChildProcess &&
633
- versionGteLt ( process . versions . node , '18.6.0' )
633
+ versionGteLt ( process . versions . node , '18.6.0' , '18.7.0' )
634
634
) {
635
635
// HACK workaround node regression
636
636
require ( '../dist-raw/runmain-hack.js' ) . run ( entryPointPath ) ;
Original file line number Diff line number Diff line change 6
6
fileURLToPath ,
7
7
pathToFileURL ,
8
8
} from 'url' ;
9
- import { extname } from 'path' ;
9
+ import { extname , resolve as pathResolve } from 'path' ;
10
10
import * as assert from 'assert' ;
11
11
import { normalizeSlashes , versionGteLt } from './util' ;
12
12
import { createRequire } from 'module' ;
@@ -137,12 +137,19 @@ export function createEsmHooks(tsNodeService: Service) {
137
137
return protocol === null || protocol === 'file:' ;
138
138
}
139
139
140
+ const runMainHackUrl = pathToFileURL (
141
+ pathResolve ( __dirname , '../dist-raw/runmain-hack.js' )
142
+ ) . toString ( ) ;
143
+
140
144
/**
141
145
* Named "probably" as a reminder that this is a guess.
142
146
* node does not explicitly tell us if we're resolving the entrypoint or not.
143
147
*/
144
148
function isProbablyEntrypoint ( specifier : string , parentURL : string ) {
145
- return parentURL === undefined && specifier . startsWith ( 'file://' ) ;
149
+ return (
150
+ ( parentURL === undefined || parentURL === runMainHackUrl ) &&
151
+ specifier . startsWith ( 'file://' )
152
+ ) ;
146
153
}
147
154
// Side-channel between `resolve()` and `load()` hooks
148
155
const rememberIsProbablyEntrypoint = new Set ( ) ;
Original file line number Diff line number Diff line change @@ -336,6 +336,14 @@ test.suite('esm', (test) => {
336
336
} ) ;
337
337
}
338
338
339
+ test ( 'extensionless entrypoint, regression test for #1943' , async ( t ) => {
340
+ const { err, stdout } = await exec (
341
+ `${ BIN_ESM_PATH } ./esm-loader-entrypoint-cjs-fallback/extensionless-entrypoint`
342
+ ) ;
343
+ expect ( err ) . toBe ( null ) ;
344
+ expect ( stdout . trim ( ) ) . toBe ( 'Hello world!' ) ;
345
+ } ) ;
346
+
339
347
test . suite ( 'parent passes signals to child' , ( test ) => {
340
348
signalTest ( 'SIGINT' ) ;
341
349
signalTest ( 'SIGTERM' ) ;
You can’t perform that action at this time.
0 commit comments