Skip to content

Commit b058c7c

Browse files
authored
feat: lazy load cosmiconfig-typescript-loader (#3694)
1 parent 0281f55 commit b058c7c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

@commitlint/load/src/utils/load-config.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {cosmiconfig} from 'cosmiconfig';
1+
import {cosmiconfig, type Loader} from 'cosmiconfig';
22
import {TypeScriptLoader} from 'cosmiconfig-typescript-loader';
33
import path from 'path';
44

@@ -13,7 +13,15 @@ export async function loadConfig(
1313
configPath?: string
1414
): Promise<LoadConfigResult | null> {
1515
const moduleName = 'commitlint';
16-
const tsLoader = TypeScriptLoader();
16+
17+
let tsLoaderInstance: Loader | undefined;
18+
const tsLoader: Loader = (...args) => {
19+
if (!tsLoaderInstance) {
20+
tsLoaderInstance = TypeScriptLoader();
21+
}
22+
return tsLoaderInstance(...args);
23+
};
24+
1725
const explorer = cosmiconfig(moduleName, {
1826
searchPlaces: [
1927
// cosmiconfig overrides default searchPlaces if any new search place is added (For e.g. `*.ts` files),

0 commit comments

Comments
 (0)