@@ -96,38 +96,31 @@ class ResolutionContext {
9696 }
9797
9898 private resolveDependencyPathsWithPlugins ( required : ProcessedFile , dependency : string ) {
99- if ( this . plugins != null ) {
100- const requiredFromLuaFile = required . fileName . endsWith ( ".lua" ) ;
101- const dependencyPath = requiredFromLuaFile ? luaRequireToPath ( dependency ) : dependency ;
102-
103- for ( const p of this . plugins ) {
104- try {
105- if ( p . moduleResolution != null ) {
106- const pluginResolvedPath = p . moduleResolution ( dependency , dependencyPath )
107- if ( pluginResolvedPath !== undefined ) {
108-
109- // If lua file is in node_module
110- if ( requiredFromLuaFile && isNodeModulesFile ( required . fileName ) ) {
111- // If requiring file is in lua module, try to resolve sibling in that file first
112- const resolvedNodeModulesFile = this . resolveLuaDependencyPathFromNodeModules ( required , pluginResolvedPath ) ;
113- if ( resolvedNodeModulesFile ) {
114- if ( this . options . tstlVerbose ) {
115- console . log ( `Resolved file path for module ${ dependency } to path ${ dependencyPath } using plugin.` )
116- }
117- return resolvedNodeModulesFile
118- }
119- }
120-
121- if ( this . getFileFromPath ( pluginResolvedPath ) ) {
99+ const requiredFromLuaFile = required . fileName . endsWith ( ".lua" ) ;
100+ const dependencyPath = requiredFromLuaFile ? luaRequireToPath ( dependency ) : dependency ;
101+
102+ for ( const p of this . plugins ) {
103+ if ( p . moduleResolution != null ) {
104+ const pluginResolvedPath = p . moduleResolution ( dependency , dependencyPath , this . options , this . emitHost )
105+ if ( pluginResolvedPath !== undefined ) {
106+
107+ // If lua file is in node_module
108+ if ( requiredFromLuaFile && isNodeModulesFile ( required . fileName ) ) {
109+ // If requiring file is in lua module, try to resolve sibling in that file first
110+ const resolvedNodeModulesFile = this . resolveLuaDependencyPathFromNodeModules ( required , pluginResolvedPath ) ;
111+ if ( resolvedNodeModulesFile ) {
112+ if ( this . options . tstlVerbose ) {
122113 console . log ( `Resolved file path for module ${ dependency } to path ${ dependencyPath } using plugin.` )
123- return pluginResolvedPath ;
124114 }
115+ return resolvedNodeModulesFile
125116 }
126117 }
127- } catch ( e : any ) {
128- // if plugin throws an error
129- if ( this . options . tstlVerbose ) {
130- console . log ( e . details ?? e ) ;
118+
119+ if ( this . getFileFromPath ( pluginResolvedPath ) ) {
120+ if ( this . options . tstlVerbose ) {
121+ console . log ( `Resolved file path for module ${ dependency } to path ${ dependencyPath } using plugin.` )
122+ }
123+ return pluginResolvedPath ;
131124 }
132125 }
133126 }
0 commit comments