Skip to content

Commit 93bd35f

Browse files
authored
fix: duplicate init typescriptLoader
1 parent e4212a3 commit 93bd35f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/utils.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ function exec(code, loaderContext) {
3434
return module.exports;
3535
}
3636

37+
let tsloader;
38+
3739
async function loadConfig(loaderContext, config, postcssOptions) {
3840
const searchPath =
3941
typeof config === "string"
@@ -166,13 +168,15 @@ async function loadConfig(loaderContext, config, postcssOptions) {
166168
};
167169

168170
if (isTsNodeInstalled) {
169-
// eslint-disable-next-line global-require
170-
const { TypeScriptLoader } = require("cosmiconfig-typescript-loader");
171-
const loader = TypeScriptLoader();
171+
if(!tsLoader) {
172+
// eslint-disable-next-line global-require
173+
const { TypeScriptLoader } = require("cosmiconfig-typescript-loader");
174+
tsLoader = TypeScriptLoader();
175+
}
172176

173-
loaders[".cts"] = loader;
174-
loaders[".mts"] = loader;
175-
loaders[".ts"] = loader;
177+
loaders[".cts"] = tsLoader;
178+
loaders[".mts"] = tsLoader;
179+
loaders[".ts"] = tsLoader;
176180
}
177181

178182
const explorer = cosmiconfig(moduleName, {

0 commit comments

Comments
 (0)