Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
234 changes: 119 additions & 115 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@ exports[`--target flag should reset the \`target\` option when the \`--target-re

exports[`--target flag should reset the \`target\` option when the \`--target-reset\` is used: stderr 1`] = `""`;

exports[`--target flag should throw an error for incompatible multiple targets: stderr 1`] = `
"[webpack-cli] ✖ Error: For the selected environment is no default script chunk format available:

JSONP Array push ('array-push') can be chosen when 'document' or 'importScripts' is available.
CommonJs exports ('commonjs') can be chosen when 'require' or node builtins are available.
Select an appropriate 'target' to allow selecting one by default, or specify the 'output.chunkFormat' directly.
at stack"
`;

exports[`--target flag should throw an error for incompatible multiple targets: stdout 1`] = `""`;

exports[`--target flag should throw an error for invalid target in multiple syntax: stderr 1`] = `
"[webpack-cli] ✖ Error: Unknown target 'invalid'. The following targets are supported:
* browserslist / browserslist:env / browserslist:query / browserslist:path-to-config / browserslist:path-to-config:env: Resolve features from browserslist. Will resolve browserslist config automatically. Only browser or node queries are supported (electron is not supported). Examples: 'browserslist:modern' to use 'modern' environment from browserslist config
* web: Web browser.
* webworker: Web Worker, SharedWorker or Service Worker.
* universal: Universal target running in browser, web worker, Node.js, Electron and NW.js. Output is always ECMAScript modules.
* [async-]node[X[.Y]]: Node.js in version X.Y. The 'async-' prefix will load chunks asynchronously via 'fs' and 'vm' instead of 'require()'. Examples: node14.5, async-node10.
* deno[X[.Y]]: Deno in version X.Y. Emits ESM output; node.js built-ins are available via the required 'node:' specifier and web APIs (fetch, WebAssembly, ...) are available too. Examples: deno2, deno1.40.
* bun[X[.Y]]: Bun in version X.Y. Output is always ECMAScript modules. Examples: bun, bun1.1.
* electron[X[.Y]]-main/preload/renderer: Electron in version X.Y. Script is running in main, preload resp. renderer context.
* nwjs[X[.Y]] / node-webkit[X[.Y]]: NW.js in version X.Y.
* esX: EcmaScript in this version. Examples: es2020, es5.
Expand All @@ -41,7 +33,10 @@ exports[`--target flag should throw error with invalid value for --target: stder
* browserslist / browserslist:env / browserslist:query / browserslist:path-to-config / browserslist:path-to-config:env: Resolve features from browserslist. Will resolve browserslist config automatically. Only browser or node queries are supported (electron is not supported). Examples: 'browserslist:modern' to use 'modern' environment from browserslist config
* web: Web browser.
* webworker: Web Worker, SharedWorker or Service Worker.
* universal: Universal target running in browser, web worker, Node.js, Electron and NW.js. Output is always ECMAScript modules.
* [async-]node[X[.Y]]: Node.js in version X.Y. The 'async-' prefix will load chunks asynchronously via 'fs' and 'vm' instead of 'require()'. Examples: node14.5, async-node10.
* deno[X[.Y]]: Deno in version X.Y. Emits ESM output; node.js built-ins are available via the required 'node:' specifier and web APIs (fetch, WebAssembly, ...) are available too. Examples: deno2, deno1.40.
* bun[X[.Y]]: Bun in version X.Y. Output is always ECMAScript modules. Examples: bun, bun1.1.
* electron[X[.Y]]-main/preload/renderer: Electron in version X.Y. Script is running in main, preload resp. renderer context.
* nwjs[X[.Y]] / node-webkit[X[.Y]]: NW.js in version X.Y.
* esX: EcmaScript in this version. Examples: es2020, es5.
Expand Down
8 changes: 4 additions & 4 deletions test/build/target/flag-test/target-flag.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ describe("--target flag", () => {
expect(normalizeStdout(stdout)).toMatchSnapshot("stdout");
});

it("should throw an error for incompatible multiple targets", async () => {
it("should allow multiple different targets", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"--target",
"node",
"--target",
"web",
]);

expect(exitCode).toBe(2);
expect(normalizeStderr(stderr)).toMatchSnapshot("stderr");
expect(normalizeStdout(stdout)).toMatchSnapshot("stdout");
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("target: [ 'node', 'web' ]");
});

it("should reset the `target` option when the `--target-reset` is used", async () => {
Expand Down
Loading