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 = {}
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 (path in tsConfigCache) {
82
+ return tsConfigCache[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[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 = {}
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 (path in tsConfigCache) {
82
+ return tsConfigCache[path]
83
+ }
84
+
79
85
ensureRequire('typescript', ['typescript'])
80
86
const typescript = require('typescript')
81
87
@@ -103,14 +109,17 @@ 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
target: typescript.ScriptTarget.ES5,
111
116
module: typescript.ModuleKind.CommonJS
112
117
}
113
118
}
119
+
120
+ tsConfigCache[path] = transpileConfig
121
+
122
+ return transpileConfig
114
123
}
115
124
116
125
function isValidTransformer(transformer) {
You can’t perform that action at this time.
0 commit comments