@@ -21,12 +21,15 @@ const DEFAULT_CONFIG_FILE = "tsconfig.json";
2121
2222module . exports = class TsconfigPathsPlugin {
2323 /**
24- * @param {"auto" | true | string } configFile tsconfig file path
24+ * @param {true | string } configFile tsconfig file path
2525 */
2626 constructor ( configFile ) {
27- this . configFile = [ "auto" , true ] . includes ( configFile )
28- ? DEFAULT_CONFIG_FILE
29- : /** @type {string } */ ( configFile ) ;
27+ this . configFile =
28+ configFile === true
29+ ? DEFAULT_CONFIG_FILE
30+ : /** @type {string } */ ( configFile ) ;
31+ /** @type {TsconfigPathsData|undefined|null } */
32+ this . tsconfigPathsData = undefined ;
3033 }
3134
3235 /**
@@ -102,26 +105,23 @@ module.exports = class TsconfigPathsPlugin {
102105 * @returns {Promise<TsconfigPathsData | null> } the pre-processed request
103106 */
104107 async loadTsconfigPathsData ( resolver , request , resolveContext ) {
105- if ( typeof request . tsconfigPathsData === "undefined" ) {
106- request . tsconfigPathsData =
107- await TsconfigPathsUtils . loadTsconfigPathsData (
108- resolver . fileSystem ,
109- this . configFile ,
110- request . path || undefined ,
111- ) ;
108+ if ( typeof this . tsconfigPathsData === "undefined" ) {
109+ this . tsconfigPathsData = await TsconfigPathsUtils . loadTsconfigPathsData (
110+ resolver . fileSystem ,
111+ this . configFile ,
112+ request . path || undefined ,
113+ ) ;
112114 }
113115
114- const { tsconfigPathsData } = request ;
115-
116- if ( ! tsconfigPathsData ) {
116+ if ( ! this . tsconfigPathsData ) {
117117 return null ;
118118 }
119119
120- for ( const fileDependency of tsconfigPathsData . fileDependencies ) {
120+ for ( const fileDependency of this . tsconfigPathsData . fileDependencies ) {
121121 if ( resolveContext . fileDependencies ) {
122122 resolveContext . fileDependencies . add ( fileDependency ) ;
123123 }
124124 }
125- return tsconfigPathsData ;
125+ return this . tsconfigPathsData ;
126126 }
127127} ;
0 commit comments