@@ -10,11 +10,12 @@ import { couldNotReadDependency, couldNotResolveRequire } from "./diagnostics";
1010import { BuildMode , CompilerOptions } from "../CompilerOptions" ;
1111import { findLuaRequires , LuaRequire } from "./find-lua-requires" ;
1212import { Plugin } from "./plugins" ;
13+ import * as picomatch from "picomatch" ;
1314
1415const resolver = resolve . ResolverFactory . createResolver ( {
1516 extensions : [ ".lua" ] ,
1617 enforceExtension : true , // Resolved file must be a lua file
17- fileSystem : { ...new resolve . CachedInputFileSystem ( fs ) } ,
18+ fileSystem : { ...new resolve . CachedInputFileSystem ( fs , 0 ) } ,
1819 useSyncFileSystemCalls : true ,
1920 conditionNames : [ "require" , "node" , "tstl" , "default" ] ,
2021 symlinks : false , // Do not resolve symlinks to their original paths (that breaks node_modules detection)
@@ -26,7 +27,7 @@ interface ResolutionResult {
2627}
2728
2829class ResolutionContext {
29- private noResolvePaths : Set < string > ;
30+ private noResolvePaths : picomatch . Matcher [ ] ;
3031
3132 public diagnostics : ts . Diagnostic [ ] = [ ] ;
3233 public resolvedFiles = new Map < string , ProcessedFile > ( ) ;
@@ -37,7 +38,9 @@ class ResolutionContext {
3738 private readonly emitHost : EmitHost ,
3839 private readonly plugins : Plugin [ ]
3940 ) {
40- this . noResolvePaths = new Set ( options . noResolvePaths ) ;
41+ const unique = [ ...new Set ( options . noResolvePaths ) ] ;
42+ const matchers = unique . map ( x => picomatch ( x ) ) ;
43+ this . noResolvePaths = matchers ;
4144 }
4245
4346 public addAndResolveDependencies ( file : ProcessedFile ) : void {
@@ -70,7 +73,7 @@ class ResolutionContext {
7073 return ;
7174 }
7275
73- if ( this . noResolvePaths . has ( required . requirePath ) ) {
76+ if ( this . noResolvePaths . find ( isMatch => isMatch ( required . requirePath ) ) ) {
7477 if ( this . options . tstlVerbose ) {
7578 console . log (
7679 `Skipping module resolution of ${ required . requirePath } as it is in the tsconfig noResolvePaths.`
0 commit comments