Skip to content

Commit b3536cb

Browse files
committed
refactor(rstack): inline loaded config import
1 parent 6748076 commit b3536cb

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

packages/rstack/src/cli/commands.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { join, resolve } from 'node:path';
22
import { pathToFileURL } from 'node:url';
3-
import { getConfigState, type LoadedRstackConfig } from '../config.ts';
3+
import { getConfigState } from '../config.ts';
44
import { insertConfigArg, parseArgs, parseCliArgs } from './args.ts';
55
import { hasHelpFlag, printCommandHelp } from './help.ts';
66

@@ -156,16 +156,6 @@ async function runRslintCLI(args: string[]): Promise<void> {
156156
await runCLI({ argv });
157157
}
158158

159-
const getLoadedConfig = async (): Promise<LoadedRstackConfig> => {
160-
// Rslint loads its one-shot config through Node's module cache. Import the
161-
// same URL to read the Rstack config exported for the following fmt phase.
162-
const configModule = (await import(
163-
pathToFileURL(RSLINT_CONFIG_PATH).href
164-
)) as typeof import('../rslintConfig.ts');
165-
166-
return configModule.loadedConfig;
167-
};
168-
169159
async function runCheckCLI(args: string[]): Promise<void> {
170160
const { values } = parseArgs({
171161
args,
@@ -186,7 +176,11 @@ async function runCheckCLI(args: string[]): Promise<void> {
186176
return;
187177
}
188178

189-
const loadedConfig = await getLoadedConfig();
179+
// Rslint loads its one-shot config through Node's module cache. Import the
180+
// same URL to read the Rstack config exported for the following fmt phase.
181+
const { loadedConfig } = (await import(
182+
pathToFileURL(RSLINT_CONFIG_PATH).href
183+
)) as typeof import('../rslintConfig.ts');
190184
const { runFmtCLI } = await import(
191185
/* rspackChunkName: 'fmt' */
192186
'../fmt/cli.ts'

0 commit comments

Comments
 (0)