File tree 2 files changed +22
-3
lines changed 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -70,12 +70,18 @@ const getBabelOptions = function loadBabelOptions(filename, options = {}) {
70
70
return loadPartialConfig ( opts ) . options
71
71
}
72
72
73
+ const tsConfigCache = new Map ( )
74
+
73
75
/**
74
76
* Load TypeScript config from tsconfig.json.
75
77
* @param {string | undefined } path tsconfig.json file path (default: root)
76
78
* @returns {import('typescript').TranspileOptions | null } TypeScript compilerOptions or null
77
79
*/
78
80
const getTypeScriptConfig = function getTypeScriptConfig ( path ) {
81
+ if ( tsConfigCache . has ( path ) ) {
82
+ return tsConfigCache . get ( path )
83
+ }
84
+
79
85
ensureRequire ( 'typescript' , [ 'typescript' ] )
80
86
const typescript = require ( 'typescript' )
81
87
@@ -103,12 +109,16 @@ const getTypeScriptConfig = function getTypeScriptConfig(path) {
103
109
104
110
const compilerOptions = parsedConfig ? parsedConfig . options : { }
105
111
106
- return {
112
+ const transpileConfig = {
107
113
compilerOptions : {
108
114
...compilerOptions ,
109
115
module : typescript . ModuleKind . CommonJS
110
116
}
111
117
}
118
+
119
+ tsConfigCache . set ( path , transpileConfig )
120
+
121
+ return transpileConfig
112
122
}
113
123
114
124
function isValidTransformer ( transformer ) {
Original file line number Diff line number Diff line change @@ -70,12 +70,18 @@ const getBabelOptions = function loadBabelOptions(filename, options = {}) {
70
70
return loadPartialConfig ( opts ) . options
71
71
}
72
72
73
+ const tsConfigCache = new Map ( )
74
+
73
75
/**
74
76
* Load TypeScript config from tsconfig.json.
75
77
* @param {string | undefined } path tsconfig.json file path (default: root)
76
78
* @returns {import('typescript').TranspileOptions | null } TypeScript compilerOptions or null
77
79
*/
78
80
const getTypeScriptConfig = function getTypeScriptConfig ( path ) {
81
+ if ( tsConfigCache . has ( path ) ) {
82
+ return tsConfigCache . get ( path )
83
+ }
84
+
79
85
ensureRequire ( 'typescript' , [ 'typescript' ] )
80
86
const typescript = require ( 'typescript' )
81
87
@@ -103,15 +109,18 @@ const getTypeScriptConfig = function getTypeScriptConfig(path) {
103
109
104
110
const compilerOptions = parsedConfig ? parsedConfig . options : { }
105
111
106
- // Force es5 to prevent const vue_1 = require('vue') from conflicting
107
- return {
112
+ const transpileConfig = {
108
113
compilerOptions : {
109
114
...compilerOptions ,
110
115
// Force es5 to prevent const vue_1 = require('vue') from conflicting
111
116
target : typescript . ScriptTarget . ES5 ,
112
117
module : typescript . ModuleKind . CommonJS
113
118
}
114
119
}
120
+
121
+ tsConfigCache . set ( path , transpileConfig )
122
+
123
+ return transpileConfig
115
124
}
116
125
117
126
function isValidTransformer ( transformer ) {
You can’t perform that action at this time.
0 commit comments