Skip to content

Commit fd45e3b

Browse files
committed
Merge branch 'next' into chore
# Conflicts: # test/configCases/plugins/uglifyjs-plugin/index.js # yarn.lock
2 parents 7b9eb0c + 575fc4c commit fd45e3b

File tree

500 files changed

+10321
-6008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

500 files changed

+10321
-6008
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
"env": {
66
"node": true,
77
"es6": true,
8+
"mocha": true,
89
},
910
"parserOptions": { "ecmaVersion": 2017 },
1011
"rules": {

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
<a href="https://opencollective.com/webpack#sponsors">
2525
<img src="https://opencollective.com/webpack/sponsors/badge.svg">
2626
</a>
27+
<a href="https://github.com/webpack/webpack/graphs/contributors">
28+
<img src="https://img.shields.io/github/contributors/webpack/webpack.svg">
29+
</a>
2730
<a href="https://gitter.im/webpack/webpack">
2831
<img src="https://badges.gitter.im/webpack/webpack.svg">
2932
</a>

bin/config-yargs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ module.exports = function(yargs) {
3030
describe: "Environment passed to the config, when it is a function",
3131
group: CONFIG_GROUP
3232
},
33+
"mode": {
34+
type: "string",
35+
describe: "Mode to use (production or development)",
36+
group: CONFIG_GROUP,
37+
requiresArg: true
38+
},
3339
"context": {
3440
type: "string",
3541
describe: "The root directory for resolving entry point and stats",

bin/convert-argv.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ module.exports = function(yargs, argv, convertOptions) {
1515
if(!argv.devtool) {
1616
argv.devtool = "eval-cheap-module-source-map";
1717
}
18+
if(!argv.mode) {
19+
argv.mode = "development";
20+
}
1821
}
1922
if(argv.p) {
2023
argv["optimize-minimize"] = true;
2124
argv["define"] = [].concat(argv["define"] || []).concat("process.env.NODE_ENV=\"production\"");
25+
if(!argv.mode) {
26+
argv.mode = "production";
27+
}
2228
}
2329

2430
var configFileLoaded = false;
@@ -288,6 +294,10 @@ module.exports = function(yargs, argv, convertOptions) {
288294
options.plugins.unshift(plugin);
289295
}
290296

297+
ifArg("mode", function(value) {
298+
options.mode = value;
299+
});
300+
291301
ifArgPair("entry", function(name, entry) {
292302
if(typeof options.entry[name] !== "undefined" && options.entry[name] !== null) {
293303
options.entry[name] = [].concat(options.entry[name]).concat(entry);

bin/webpack.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,19 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
333333
var compiler;
334334
try {
335335
compiler = webpack(options);
336-
} catch(e) {
337-
var WebpackOptionsValidationError = require("../lib/WebpackOptionsValidationError");
338-
if(e instanceof WebpackOptionsValidationError) {
336+
} catch(err) {
337+
if(err.name === "WebpackOptionsValidationError") {
339338
if(argv.color)
340-
console.error("\u001b[1m\u001b[31m" + e.message + "\u001b[39m\u001b[22m");
339+
console.error(
340+
`\u001b[1m\u001b[31m${err.message}\u001b[39m\u001b[22m`
341+
);
341342
else
342-
console.error(e.message);
343-
process.exit(1); // eslint-disable-line no-process-exit
343+
console.error(err.message);
344+
// eslint-disable-next-line no-process-exit
345+
process.exit(1);
344346
}
345-
throw e;
347+
348+
throw err;
346349
}
347350

348351
if(argv.progress) {

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
[multiple-entry-points-commons-chunk-css-bundle](multiple-entry-points-commons-chunk-css-bundle)
2323

24-
[names-chunks](names-chunks) example demonstrating merging of chunks with named chunks
24+
[named-chunks](named-chunks) example demonstrating merging of chunks with named chunks
2525

2626
[two-explicit-vendor-chunks](two-explicit-vendor-chunks)
2727

examples/aggressive-merging/README.md

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ a big file...
3232
var path = require("path");
3333
var AggressiveMergingPlugin = require("../../lib/optimize/AggressiveMergingPlugin");
3434
module.exports = {
35+
mode: "production",
3536
entry: {
3637
pageA: "./pageA",
3738
pageB: "./pageB",
@@ -56,21 +57,21 @@ module.exports = {
5657
## Uncompressed
5758

5859
```
59-
Hash: 75bcce350a8b5f748873
60-
Version: webpack 3.5.1
60+
Hash: 79ab12b0d491f1da79bf
61+
Version: webpack next
6162
Asset Size Chunks Chunk Names
62-
0.chunk.js 5.76 kB 0 [emitted]
63-
1.chunk.js 403 bytes 1 [emitted]
64-
pageB.bundle.js 6.42 kB 2 [emitted] pageB
65-
pageA.bundle.js 6.39 kB 3 [emitted] pageA
66-
pageC.bundle.js 6.18 kB 4 [emitted] pageC
63+
0.chunk.js 5.75 KiB 0 [emitted]
64+
1.chunk.js 595 bytes 1 [emitted]
65+
pageB.bundle.js 7.4 KiB 2 [emitted] pageB
66+
pageA.bundle.js 7.39 KiB 3 [emitted] pageA
67+
pageC.bundle.js 7.1 KiB 4 [emitted] pageC
6768
Entrypoint pageA = pageA.bundle.js
6869
Entrypoint pageB = pageB.bundle.js
6970
Entrypoint pageC = pageC.bundle.js
70-
chunk {0} 0.chunk.js 5.55 kB {2} {3} [rendered]
71+
chunk {0} 0.chunk.js 5.42 KiB {2} {3} [rendered]
7172
> aggressive-merge [3] ./pageA.js 1:0-3:2
7273
> aggressive-merge [4] ./pageB.js 1:0-3:2
73-
[2] ./common.js 5.55 kB {0} [built]
74+
[2] ./common.js 5.42 KiB {0} [built]
7475
amd require ./common [3] ./pageA.js 1:0-3:2
7576
amd require ./common [4] ./pageB.js 1:0-3:2
7677
chunk {1} 1.chunk.js 42 bytes {4} [rendered]
@@ -87,35 +88,38 @@ chunk {2} pageB.bundle.js (pageB) 92 bytes [entry] [rendered]
8788
cjs require ./b [4] ./pageB.js 2:8-22
8889
cjs require ./b [5] ./pageC.js 2:17-31
8990
[4] ./pageB.js 71 bytes {2} [built]
91+
single entry ./pageB pageB
9092
chunk {3} pageA.bundle.js (pageA) 92 bytes [entry] [rendered]
9193
> pageA [3] ./pageA.js
9294
[0] ./a.js 21 bytes {1} {3} [built]
9395
cjs require ./a [3] ./pageA.js 2:8-22
9496
amd require ./a [5] ./pageC.js 1:0-3:2
9597
[3] ./pageA.js 71 bytes {3} [built]
98+
single entry ./pageA pageA
9699
chunk {4} pageC.bundle.js (pageC) 70 bytes [entry] [rendered]
97100
> pageC [5] ./pageC.js
98101
[5] ./pageC.js 70 bytes {4} [built]
102+
single entry ./pageC pageC
99103
```
100104

101105
## Minimized (uglify-js, no zip)
102106

103107
```
104-
Hash: 75bcce350a8b5f748873
105-
Version: webpack 3.5.1
106-
Asset Size Chunks Chunk Names
107-
0.chunk.js 75 bytes 0 [emitted]
108-
1.chunk.js 78 bytes 1 [emitted]
109-
pageB.bundle.js 1.46 kB 2 [emitted] pageB
110-
pageA.bundle.js 1.46 kB 3 [emitted] pageA
111-
pageC.bundle.js 1.44 kB 4 [emitted] pageC
108+
Hash: 79ab12b0d491f1da79bf
109+
Version: webpack next
110+
Asset Size Chunks Chunk Names
111+
0.chunk.js 115 bytes 0 [emitted]
112+
1.chunk.js 118 bytes 1 [emitted]
113+
pageB.bundle.js 1.69 KiB 2 [emitted] pageB
114+
pageA.bundle.js 1.69 KiB 3 [emitted] pageA
115+
pageC.bundle.js 1.67 KiB 4 [emitted] pageC
112116
Entrypoint pageA = pageA.bundle.js
113117
Entrypoint pageB = pageB.bundle.js
114118
Entrypoint pageC = pageC.bundle.js
115-
chunk {0} 0.chunk.js 5.55 kB {2} {3} [rendered]
119+
chunk {0} 0.chunk.js 5.42 KiB {2} {3} [rendered]
116120
> aggressive-merge [3] ./pageA.js 1:0-3:2
117121
> aggressive-merge [4] ./pageB.js 1:0-3:2
118-
[2] ./common.js 5.55 kB {0} [built]
122+
[2] ./common.js 5.42 KiB {0} [built]
119123
amd require ./common [3] ./pageA.js 1:0-3:2
120124
amd require ./common [4] ./pageB.js 1:0-3:2
121125
chunk {1} 1.chunk.js 42 bytes {4} [rendered]
@@ -132,13 +136,16 @@ chunk {2} pageB.bundle.js (pageB) 92 bytes [entry] [rendered]
132136
cjs require ./b [4] ./pageB.js 2:8-22
133137
cjs require ./b [5] ./pageC.js 2:17-31
134138
[4] ./pageB.js 71 bytes {2} [built]
139+
single entry ./pageB pageB
135140
chunk {3} pageA.bundle.js (pageA) 92 bytes [entry] [rendered]
136141
> pageA [3] ./pageA.js
137142
[0] ./a.js 21 bytes {1} {3} [built]
138143
cjs require ./a [3] ./pageA.js 2:8-22
139144
amd require ./a [5] ./pageC.js 1:0-3:2
140145
[3] ./pageA.js 71 bytes {3} [built]
146+
single entry ./pageA pageA
141147
chunk {4} pageC.bundle.js (pageC) 70 bytes [entry] [rendered]
142148
> pageC [5] ./pageC.js
143149
[5] ./pageC.js 70 bytes {4} [built]
150+
single entry ./pageC pageC
144151
```

examples/aggressive-merging/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var path = require("path");
22
var AggressiveMergingPlugin = require("../../lib/optimize/AggressiveMergingPlugin");
33
module.exports = {
4+
mode: "production",
45
entry: {
56
pageA: "./pageA",
67
pageB: "./pageB",

examples/build-common.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ const fs = require("fs");
1111

1212
const extraArgs = "";
1313

14-
const targetArgs = global.NO_TARGET_ARGS ? "" : " ./example.js js/output.js";
14+
const hasConfiguration = fs.existsSync("webpack.config.js");
15+
const targetArgs = global.NO_TARGET_ARGS ? "" : " ./example.js js/output.js ";
1516
const displayReasons = global.NO_REASONS ? "" : " --display-reasons --display-used-exports --display-provided-exports";
16-
cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" -p ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) {
17+
const modeArgs = hasConfiguration ? "" : "--mode production";
18+
cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${modeArgs} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" -p ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) {
1719
if(stderr)
1820
console.log(stderr);
1921
if(error !== null)
@@ -25,7 +27,7 @@ cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${displayReasons}
2527
console.log(stderr);
2628
throw e;
2729
}
28-
cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" --output-pathinfo ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) {
30+
cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${modeArgs} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" --output-pathinfo ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) {
2931
console.log(stdout);
3032
if(stderr)
3133
console.log(stderr);

0 commit comments

Comments
 (0)