@@ -146,12 +146,13 @@ function withoutExtension(str: string, ext: string): string {
146146/** Returns a map from filename (path relative to `directory`) to the SourceFile we parsed for it. */
147147export function allReferencedFiles (
148148 entryFilenames : ReadonlyArray < string > , fs : FS , packageName : string , baseDirectory : string ,
149- ) : { types : Map < string , ts . SourceFile > , tests : Map < string , ts . SourceFile > } {
149+ ) : { types : Map < string , ts . SourceFile > , tests : Map < string , ts . SourceFile > , hasNonRelativeImport : boolean } {
150150 const seenReferences = new Set < string > ( ) ;
151151 const types = new Map < string , ts . SourceFile > ( ) ;
152152 const tests = new Map < string , ts . SourceFile > ( ) ;
153+ let hasNonRelativeImport = false ;
153154 entryFilenames . forEach ( text => recur ( { text, exact : true } ) ) ;
154- return { types, tests } ;
155+ return { types, tests, hasNonRelativeImport } ;
155156
156157 function recur ( { text, exact } : Reference ) : void {
157158 if ( seenReferences . has ( text ) ) {
@@ -168,13 +169,14 @@ export function allReferencedFiles(
168169 tests . set ( resolvedFilename , src ) ;
169170 }
170171
171- const refs = findReferencedFiles (
172+ const { refs, hasNonRelativeImport : result } = findReferencedFiles (
172173 src ,
173174 packageName ,
174175 path . dirname ( resolvedFilename ) ,
175176 normalizeSlashes ( path . relative ( baseDirectory , fs . debugPath ( ) ) ) ,
176177 ) ;
177178 refs . forEach ( recur ) ;
179+ hasNonRelativeImport = hasNonRelativeImport || result ;
178180 }
179181 }
180182
@@ -210,6 +212,7 @@ interface Reference {
210212 */
211213function findReferencedFiles ( src : ts . SourceFile , packageName : string , subDirectory : string , baseDirectory : string ) {
212214 const refs : Reference [ ] = [ ] ;
215+ let hasNonRelativeImport = false ;
213216
214217 for ( const ref of src . referencedFiles ) {
215218 // Any <reference path="foo"> is assumed to be local
@@ -230,9 +233,10 @@ function findReferencedFiles(src: ts.SourceFile, packageName: string, subDirecto
230233 }
231234 if ( ref . startsWith ( packageName + "/" ) ) {
232235 addReference ( { text : convertToRelativeReference ( ref ) , exact : false } ) ;
236+ hasNonRelativeImport = true ;
233237 }
234238 }
235- return refs ;
239+ return { refs, hasNonRelativeImport } ;
236240
237241 function addReference ( ref : Reference ) : void {
238242 // `path.normalize` may add windows slashes
0 commit comments