-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(webpack-cli): add an option for preventing interpret (#3329)
* fix(webpack-cli): add an option for preventing interpret * fix: define the option for built-in flags * docs: add descriptions of the option * refactor: rename `--config-registered` to `--disable-interpret` * fix: change conditional statement * refactor: standalone test * test: use `--disable-interpret` without transpilation * docs: fix the description Co-authored-by: Anshuman Verma <anshu.av97@gmail.com> * refactor: built-in options type Co-authored-by: Nitin Kumar <snitin315@gmail.com> * test: re-update snapshots * fix: add double quote Co-authored-by: Nitin Kumar <snitin315@gmail.com> * test: update snapshots for webpack4 * chore: remove `--require` from `test:coverage` * test: update snapshots Co-authored-by: Anshuman Verma <anshu.av97@gmail.com> Co-authored-by: Nitin Kumar <snitin315@gmail.com>
- Loading branch information
1 parent
4cbb354
commit c737383
Showing
13 changed files
with
165 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test/build/config-format/disable-interpret/disable-interpret.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { run } = require("../../../utils/test-utils"); | ||
const { existsSync, unlinkSync } = require("fs"); | ||
const { resolve } = require("path"); | ||
|
||
// eslint-disable-next-line node/no-unpublished-require | ||
const execa = require("execa"); | ||
const { sync: spawnSync } = execa; | ||
|
||
describe("webpack cli", () => { | ||
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, ["--disable-interpret"]); | ||
unlinkSync(resolve(__dirname, `${configFileName}.js`)); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
expect(exitCode).toBe(0); | ||
expect(existsSync(resolve(__dirname, "dist/foo.bundle.js"))).toBeTruthy(); | ||
}); | ||
|
||
it("should log error without transpilation", async () => { | ||
const { exitCode, stderr, stdout } = await run(__dirname, ["--disable-interpret"]); | ||
|
||
expect(exitCode).toBe(2); | ||
expect(stderr).toContain(`Failed to load '${resolve(__dirname, "webpack.config.ts")}' config`); | ||
expect(stdout).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log("Main typescript file"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
test/build/config-format/disable-interpret/webpack.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable node/no-unsupported-features/es-syntax */ | ||
/** eslint-disable **/ | ||
import * as path from "path"; | ||
|
||
const config = { | ||
mode: "production", | ||
entry: "./main.ts", | ||
output: { | ||
path: path.resolve(__dirname, "dist"), | ||
filename: "foo.bundle.js", | ||
}, | ||
}; | ||
|
||
export = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.