File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -294,9 +294,7 @@ declare module "nitropack/types" {
294294 . catch ( ( ) => null /* file does not exist */ ) ;
295295 return relativeWithDot (
296296 tsconfigDir ,
297- stats ?. isFile ( )
298- ? path . replace ( / (?< = \w ) \. \w + $ / g, "" ) /* remove extension */
299- : path
297+ stats ?. isFile ( ) ? stripPathsExt ( path ) : path
300298 ) ;
301299 } )
302300 ) ;
@@ -346,3 +344,11 @@ export function relativeWithDot(from: string, to: string) {
346344 const rel = relative ( from , to ) ;
347345 return RELATIVE_RE . test ( rel ) ? rel : "./" + rel ;
348346}
347+
348+ // Strip only the extensions TS retries from a bare `paths` candidate.
349+ // https://github.com/microsoft/TypeScript/blob/main/src/compiler/moduleNameResolver.ts
350+ const PATHS_STRIPPABLE_EXT_RE = / \. (?: t s x ? | j s x ? | [ c m ] j s ) $ / ;
351+
352+ export function stripPathsExt ( path : string ) {
353+ return path . replace ( PATHS_STRIPPABLE_EXT_RE , "" ) ;
354+ }
You can’t perform that action at this time.
0 commit comments