File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -630,7 +630,7 @@ function phase4(payload: BootstrapState) {
630630 if ( executeEntrypoint ) {
631631 if (
632632 payload . isInChildProcess &&
633- versionGteLt ( process . versions . node , '18.6.0' )
633+ versionGteLt ( process . versions . node , '18.6.0' , '18.7.0' )
634634 ) {
635635 // HACK workaround node regression
636636 require ( '../dist-raw/runmain-hack.js' ) . run ( entryPointPath ) ;
Original file line number Diff line number Diff line change 66 fileURLToPath ,
77 pathToFileURL ,
88} from 'url' ;
9- import { extname } from 'path' ;
9+ import { extname , resolve as pathResolve } from 'path' ;
1010import * as assert from 'assert' ;
1111import { normalizeSlashes , versionGteLt } from './util' ;
1212import { createRequire } from 'module' ;
@@ -137,12 +137,19 @@ export function createEsmHooks(tsNodeService: Service) {
137137 return protocol === null || protocol === 'file:' ;
138138 }
139139
140+ const runMainHackUrl = pathToFileURL (
141+ pathResolve ( __dirname , '../dist-raw/runmain-hack.js' )
142+ ) . toString ( ) ;
143+
140144 /**
141145 * Named "probably" as a reminder that this is a guess.
142146 * node does not explicitly tell us if we're resolving the entrypoint or not.
143147 */
144148 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+ ) ;
146153 }
147154 // Side-channel between `resolve()` and `load()` hooks
148155 const rememberIsProbablyEntrypoint = new Set ( ) ;
Original file line number Diff line number Diff line change @@ -336,6 +336,14 @@ test.suite('esm', (test) => {
336336 } ) ;
337337 }
338338
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+
339347 test . suite ( 'parent passes signals to child' , ( test ) => {
340348 signalTest ( 'SIGINT' ) ;
341349 signalTest ( 'SIGTERM' ) ;
You can’t perform that action at this time.
0 commit comments