@@ -112,11 +112,23 @@ class Transpilation {
112112 return { error : error . message } ;
113113 }
114114
115- this . handleProcessedFile ( {
116- fileName : resolvedPath ,
117- code : cast ( this . emitHost . readFile ( resolvedPath ) , isNonNull ) ,
118- // TODO: Load source map files
119- } ) ;
115+ if ( ! this . seenFiles . has ( resolvedPath ) ) {
116+ if (
117+ this . scriptExtensions . some ( extension => resolvedPath . endsWith ( extension ) ) ||
118+ resolvedPath . endsWith ( ".json" )
119+ ) {
120+ const message = `Resolved source file '${ resolvedPath } ' is not a part of the project.` ;
121+ this . diagnostics . push ( createResolutionErrorDiagnostic ( message , request , file . fileName ) ) ;
122+ return { error : message } ;
123+ } else {
124+ this . seenFiles . add ( resolvedPath ) ;
125+ this . handleProcessedFile ( {
126+ fileName : resolvedPath ,
127+ code : cast ( this . emitHost . readFile ( resolvedPath ) , isNonNull ) ,
128+ // TODO: Load source map files
129+ } ) ;
130+ }
131+ }
120132
121133 return this . toRequireParameter ( this . toGeneratedFileName ( resolvedPath ) ) ;
122134 } ;
@@ -133,8 +145,9 @@ class Transpilation {
133145 this . files . push ( file ) ;
134146 }
135147
148+ private readonly scriptExtensions = [ ".ts" , ".tsx" , ".js" , ".jsx" ] ;
136149 protected resolver = ResolverFactory . createResolver ( {
137- extensions : [ ".lua" , ".ts" , ".tsx" , ".js" , ".jsx" ] ,
150+ extensions : [ ".lua" , ... this . scriptExtensions ] ,
138151 conditionNames : [ "lua" , `lua:${ this . options . luaTarget ?? LuaTarget . Universal } ` ] ,
139152 fileSystem : this . emitHost . resolutionFileSystem ?? fs ,
140153 useSyncFileSystemCalls : true ,
0 commit comments