@@ -21,12 +21,15 @@ const DEFAULT_CONFIG_FILE = "tsconfig.json";
21
21
22
22
module . exports = class TsconfigPathsPlugin {
23
23
/**
24
- * @param {"auto" | true | string } configFile tsconfig file path
24
+ * @param {true | string } configFile tsconfig file path
25
25
*/
26
26
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 ;
30
33
}
31
34
32
35
/**
@@ -102,26 +105,23 @@ module.exports = class TsconfigPathsPlugin {
102
105
* @returns {Promise<TsconfigPathsData | null> } the pre-processed request
103
106
*/
104
107
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
+ ) ;
112
114
}
113
115
114
- const { tsconfigPathsData } = request ;
115
-
116
- if ( ! tsconfigPathsData ) {
116
+ if ( ! this . tsconfigPathsData ) {
117
117
return null ;
118
118
}
119
119
120
- for ( const fileDependency of tsconfigPathsData . fileDependencies ) {
120
+ for ( const fileDependency of this . tsconfigPathsData . fileDependencies ) {
121
121
if ( resolveContext . fileDependencies ) {
122
122
resolveContext . fileDependencies . add ( fileDependency ) ;
123
123
}
124
124
}
125
- return tsconfigPathsData ;
125
+ return this . tsconfigPathsData ;
126
126
}
127
127
} ;
0 commit comments