Skip to content

Commit 3fa4f3e

Browse files
authored
feat: add --config-loader CLI option (#9210)
* feat: disable-interpret CLI option * feat: disable-interpret CLI option replaced by config-loader * feat: config-loader behavior fixed
1 parent c1e945f commit 3fa4f3e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Diff for: packages/rspack-cli/src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface RspackCLIOptions {
2424
config?: string;
2525
argv?: Record<string, any>;
2626
configName?: string[];
27+
"config-loader"?: string;
2728
}
2829

2930
export interface RspackBuildCLIOptions extends RspackCLIOptions {

Diff for: packages/rspack-cli/src/utils/loadConfig.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ export async function loadRspackConfig(
6161
if (!fs.existsSync(configPath)) {
6262
throw new Error(`config file "${configPath}" not found.`);
6363
}
64-
if (isTsFile(configPath)) {
64+
if (isTsFile(configPath) && options["config-loader"] === "register") {
6565
await registerLoader(configPath);
6666
}
6767
return crossImport(configPath, cwd);
6868
}
6969

7070
const defaultConfig = findConfig(path.resolve(cwd, DEFAULT_CONFIG_NAME));
7171
if (defaultConfig) {
72-
if (isTsFile(defaultConfig)) {
72+
if (isTsFile(defaultConfig) && options["config-loader"] === "register") {
7373
await registerLoader(defaultConfig);
7474
}
7575
return crossImport(defaultConfig, cwd);

Diff for: packages/rspack-cli/src/utils/options.ts

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ export const commonOptions = (yargs: yargs.Argv) => {
4444
type: "array",
4545
string: true,
4646
describe: "Name of the configuration to use."
47+
},
48+
"config-loader": {
49+
type: "string",
50+
default: "register",
51+
describe:
52+
"Specify the loader to load the config file, can be `native` or `register`."
4753
}
4854
})
4955
.alias({ v: "version", h: "help" });

0 commit comments

Comments
 (0)