Skip to content

Commit

Permalink
fix: memory leak (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Apr 4, 2023
1 parent e4212a3 commit 7ab3b59
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/utils.js
Expand Up @@ -34,6 +34,8 @@ function exec(code, loaderContext) {
return module.exports;
}

let tsLoader;

async function loadConfig(loaderContext, config, postcssOptions) {
const searchPath =
typeof config === "string"
Expand Down Expand Up @@ -166,13 +168,16 @@ async function loadConfig(loaderContext, config, postcssOptions) {
};

if (isTsNodeInstalled) {
// eslint-disable-next-line global-require
const { TypeScriptLoader } = require("cosmiconfig-typescript-loader");
const loader = TypeScriptLoader();
if (!tsLoader) {
// eslint-disable-next-line global-require
const { TypeScriptLoader } = require("cosmiconfig-typescript-loader");

tsLoader = TypeScriptLoader();
}

loaders[".cts"] = loader;
loaders[".mts"] = loader;
loaders[".ts"] = loader;
loaders[".cts"] = tsLoader;
loaders[".mts"] = tsLoader;
loaders[".ts"] = tsLoader;
}

const explorer = cosmiconfig(moduleName, {
Expand Down

0 comments on commit 7ab3b59

Please sign in to comment.