File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -181,15 +181,7 @@ export function createEsmHooks(tsNodeService: Service) {
181
181
rememberResolvedViaCommonjsFallback . add ( resolution ) ;
182
182
return { url : resolution , format : 'commonjs' } ;
183
183
} catch ( commonjsResolverError ) {
184
- throw new Error (
185
- `Resolution via the ECMAScript loader failed.\n` +
186
- `ts-node guessed that this resolution was likely the entrypoint script, so attempted a fallback to the CommonJS resolver.\n` +
187
- `CommonJS resolver threw:\n` +
188
- `${
189
- ( commonjsResolverError as Error ) ?. message ??
190
- commonjsResolverError
191
- } `
192
- ) ;
184
+ throw esmResolverError ;
193
185
}
194
186
}
195
187
}
Original file line number Diff line number Diff line change @@ -292,6 +292,13 @@ test.suite('esm', (test) => {
292
292
expect ( err ) . toBe ( null ) ;
293
293
expect ( stdout . trim ( ) ) . toBe ( 'Hello world!' ) ;
294
294
} ) ;
295
+ test ( 'fails as expected when entrypoint does not exist at all' , async ( t ) => {
296
+ const { err, stderr } = await exec (
297
+ `${ CMD_ESM_LOADER_WITHOUT_PROJECT } ./esm-loader-entrypoint-cjs-fallback/does-not-exist`
298
+ ) ;
299
+ expect ( err ) . toBeDefined ( ) ;
300
+ expect ( stderr ) . toContain ( `Cannot find module ` ) ;
301
+ } ) ;
295
302
}
296
303
) ;
297
304
} ) ;
You can’t perform that action at this time.
0 commit comments