Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: rename --config-registered to --disable-interpret
  • Loading branch information
shuta13 committed Jul 13, 2022
commit 79f61c99e75c4742666c5512c2bc467bdefb7ca1
2 changes: 1 addition & 1 deletion OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Options:
-c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
--config-name <value...> Name of the configuration to use.
-m, --merge Merge two or more configurations using 'webpack-merge'.
--config-registered Disable interpret a config file.
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
-h, --hot [value] Enables Hot Module Replacement
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-cli/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ type WebpackDevServerOptions = DevServerConfig &
merge?: boolean;
config: string[];
configName?: string[];
configRegistered?: boolean;
disableInterpret?: boolean;
argv: Argv;
};

Expand Down
12 changes: 6 additions & 6 deletions packages/webpack-cli/src/webpack-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ class WebpackCLI implements IWebpackCLI {
"config",
"config-name",
"merge",
"config-registered",
"disable-interpret",
"env",
"mode",
"watch",
Expand Down Expand Up @@ -751,7 +751,7 @@ class WebpackCLI implements IWebpackCLI {
description: "Merge two or more configurations using 'webpack-merge'.",
},
{
name: "config-registered",
name: "disable-interpret",
configs: [
{
type: "boolean",
Expand Down Expand Up @@ -1817,15 +1817,15 @@ class WebpackCLI implements IWebpackCLI {
}

async loadConfig(options: Partial<WebpackDevServerOptions>) {
const configRegistered =
typeof options.configRegistered !== undefined && options.configRegistered;
const disableInterpret =
typeof options.disableInterpret !== undefined && options.disableInterpret;

const interpret = require("interpret");
const loadConfigByPath = async (configPath: string, argv: Argv = {}) => {
const ext = path.extname(configPath);
const interpreted = Object.keys(interpret.jsVariants).find((variant) => variant === ext);

if (interpreted && !configRegistered) {
if (interpreted && !disableInterpret) {
const rechoir: Rechoir = require("rechoir");

try {
Expand Down Expand Up @@ -1917,7 +1917,7 @@ class WebpackCLI implements IWebpackCLI {
path: new WeakMap(),
};

if (options.config && options.config.length > 0 && configRegistered) {
if (options.config && options.config.length > 0 && disableInterpret) {
const loadedConfigs = await Promise.all(
options.config.map((configPath: string) =>
loadConfigByPath(path.resolve(configPath), options.argv),
Expand Down
4 changes: 2 additions & 2 deletions test/build/config-format/typescript/typescript.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ describe("webpack cli", () => {
expect(existsSync(resolve(__dirname, "dist/foo.bundle.js"))).toBeTruthy();
});

it('should work with the "config-registered" option from flags', async () => {
it('should work with the "disable-interpret" option from flags', async () => {
const configFileName = "webpack.config";
const configFilePath = resolve(__dirname, `${configFileName}.ts`);
const buildScripts = spawnSync("yarn", ["tsc", configFilePath]);
expect(buildScripts.stdout).toBeTruthy();

const { exitCode, stderr, stdout } = await run(__dirname, ["--config-registered"]);
const { exitCode, stderr, stdout } = await run(__dirname, ["--disable-interpret"]);
unlinkSync(resolve(__dirname, `${configFileName}.js`));

expect(stderr).toBeFalsy();
Expand Down