Skip to content

Commit 6a3fa23

Browse files
committed
Merge branch 'next' into chore
# Conflicts: # package.json # yarn.lock
2 parents 6a050ee + bfa4b49 commit 6a3fa23

File tree

156 files changed

+2699
-1242
lines changed

Some content is hidden

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

156 files changed

+2699
-1242
lines changed

bin/convert-argv.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ module.exports = function(yargs, argv, convertOptions) {
100100
};
101101

102102
var requireConfig = function requireConfig(configPath) {
103-
var options = require(configPath);
103+
var options = (function WEBPACK_OPTIONS() {
104+
return require(configPath);
105+
})();
104106
options = prepareOptions(options, argv);
105107
return options;
106108
};

bin/webpack.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
var path = require("path");
88

9+
var ErrorHelpers = require("../lib/ErrorHelpers");
10+
911
// Local version replace global one
1012
try {
1113
var localWebpack = require.resolve(path.join(process.cwd(), "node_modules", "webpack", "bin", "webpack.js"));
@@ -150,6 +152,7 @@ yargs.options({
150152
// This causes large help outputs to be cut short (https://github.com/nodejs/node/wiki/API-changes-between-v0.10-and-v4#process).
151153
// To prevent this we use the yargs.parse API and exit the process normally
152154
yargs.parse(process.argv.slice(2), (err, argv, output) => {
155+
Error.stackTraceLimit = 30;
153156

154157
// arguments validation failed
155158
if(err && output) {
@@ -168,7 +171,27 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
168171
argv["display"] = "verbose";
169172
}
170173

171-
var options = require("./convert-argv")(yargs, argv);
174+
try {
175+
var options = require("./convert-argv")(yargs, argv);
176+
} catch(err) {
177+
if(err.name !== "ValidationError") {
178+
throw err;
179+
}
180+
181+
var stack = ErrorHelpers.cleanUpWebpackOptions(err.stack, err.message);
182+
var message = err.message + "\n" + stack;
183+
184+
if(argv.color) {
185+
console.error(
186+
`\u001b[1m\u001b[31m${message}\u001b[39m\u001b[22m`
187+
);
188+
} else {
189+
console.error(message);
190+
}
191+
192+
process.exitCode = 1;
193+
return;
194+
}
172195

173196
function ifArg(name, fn, init) {
174197
if(Array.isArray(argv[name])) {
@@ -328,7 +351,6 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
328351

329352
var webpack = require("../lib/webpack.js");
330353

331-
Error.stackTraceLimit = 30;
332354
var lastHash = null;
333355
var compiler;
334356
try {

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106
## Scope Hoisting
107107
[scope-hoisting](scope-hoisting)
108108

109-
## Pure Module
110-
[pure-module](pure-module)
109+
## Side Effects
110+
[side-effects](side-effects)
111111

112112
## Source Map
113113
[source-map](source-map)

examples/chunkhash/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ __webpack_require__.r(__webpack_exports__);
131131
/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */0);
132132

133133
// some module
134-
__webpack_require__.e/* import() */(1).then(__webpack_require__.bind(null, /*! ./async1 */3));
135-
__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./async2 */4));
134+
__webpack_require__.e/* import() */(1).then(function() { var m = __webpack_require__(/*! ./async1 */3); return m && typeof m === "object" && m.__esModule ? m : /* fake namespace object */ { "default": m }; });
135+
__webpack_require__.e/* import() */(0).then(function() { var m = __webpack_require__(/*! ./async2 */4); return m && typeof m === "object" && m.__esModule ? m : /* fake namespace object */ { "default": m }; });
136136

137137

138138
/***/ })
@@ -150,7 +150,7 @@ Version: webpack next
150150
d384ba1bbf385fcafc99.js 359 bytes 0 [emitted]
151151
13604ac9ffd7d870f88b.js 359 bytes 1 [emitted]
152152
common.[chunkhash].js 975 bytes 2 [emitted] common
153-
main.[chunkhash].js 741 bytes 3 [emitted] main
153+
main.[chunkhash].js 971 bytes 3 [emitted] main
154154
manifest.[chunkhash].js 7.14 KiB 4 [emitted] manifest
155155
Entrypoint main = manifest.[chunkhash].js common.[chunkhash].js main.[chunkhash].js
156156
Entrypoint common = manifest.[chunkhash].js common.[chunkhash].js
@@ -187,7 +187,7 @@ Version: webpack next
187187
d384ba1bbf385fcafc99.js 78 bytes 0 [emitted]
188188
13604ac9ffd7d870f88b.js 78 bytes 1 [emitted]
189189
common.[chunkhash].js 154 bytes 2 [emitted] common
190-
main.[chunkhash].js 171 bytes 3 [emitted] main
190+
main.[chunkhash].js 301 bytes 3 [emitted] main
191191
manifest.[chunkhash].js 1.81 KiB 4 [emitted] manifest
192192
Entrypoint main = manifest.[chunkhash].js common.[chunkhash].js main.[chunkhash].js
193193
Entrypoint common = manifest.[chunkhash].js common.[chunkhash].js

examples/code-splitted-css-bundle/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ body {
7272
## Uncompressed
7373

7474
```
75-
Hash: eb83e18f883b3782ac4e
75+
Hash: 07cd62e8204ce12e5e90
7676
Version: webpack next
7777
Asset Size Chunks Chunk Names
7878
ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted]
@@ -112,7 +112,7 @@ Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin
112112
## Minimized (uglify-js, no zip)
113113

114114
```
115-
Hash: 3d67c808fc684d446a10
115+
Hash: 875c8c7227c51a7a972d
116116
Version: webpack next
117117
Asset Size Chunks Chunk Names
118118
ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted]

examples/code-splitted-require.context-amd/README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ getTemplate("b", function(b) {
203203
/***/ (function(module, exports, __webpack_require__) {
204204

205205
function getTemplate(templateName, callback) {
206-
__webpack_require__.e/* require */(0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__( 1)("./"+templateName)]; ((function(tmpl) {
206+
__webpack_require__.e/* require */(0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ../require.context/templates */ 1)("./"+templateName)]; ((function(tmpl) {
207207
callback(tmpl());
208208
}).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe);
209209
}
@@ -240,15 +240,19 @@ var map = {
240240
"./c": 4,
241241
"./c.js": 4
242242
};
243+
244+
243245
function webpackContext(req) {
244-
return __webpack_require__(webpackContextResolve(req));
245-
};
246+
var id = webpackContextResolve(req);
247+
var module = __webpack_require__(id);
248+
return module;
249+
}
246250
function webpackContextResolve(req) {
247251
var id = map[req];
248252
if(!(id + 1)) // check for number or string
249253
throw new Error("Cannot find module '" + req + "'.");
250254
return id;
251-
};
255+
}
252256
webpackContext.keys = function webpackContextKeys() {
253257
return Object.keys(map);
254258
};
@@ -310,8 +314,8 @@ module.exports = function() {
310314
Hash: 3742c378c8642182b6b1
311315
Version: webpack next
312316
Asset Size Chunks Chunk Names
313-
0.output.js 2.15 KiB 0 [emitted]
314-
output.js 7.24 KiB 1 [emitted] main
317+
0.output.js 2.19 KiB 0 [emitted]
318+
output.js 7.28 KiB 1 [emitted] main
315319
Entrypoint main = output.js
316320
chunk {0} 0.output.js 463 bytes {1} [rendered]
317321
> [0] ./example.js 2:1-4:3
@@ -338,7 +342,7 @@ chunk {1} output.js (main) 261 bytes [entry] [rendered]
338342
Hash: 3742c378c8642182b6b1
339343
Version: webpack next
340344
Asset Size Chunks Chunk Names
341-
0.output.js 584 bytes 0 [emitted]
345+
0.output.js 592 bytes 0 [emitted]
342346
output.js 1.75 KiB 1 [emitted] main
343347
Entrypoint main = output.js
344348
chunk {0} 0.output.js 463 bytes {1} [rendered]

examples/code-splitted-require.context/README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ getTemplate("b", function(b) {
204204

205205
function getTemplate(templateName, callback) {
206206
__webpack_require__.e/* require.ensure */(0).then((function(require) {
207-
callback(__webpack_require__( 1)("./"+templateName)());
207+
callback(__webpack_require__(/*! ../require.context/templates */ 1)("./"+templateName)());
208208
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
209209
}
210210
getTemplate("a", function(a) {
@@ -240,15 +240,19 @@ var map = {
240240
"./c": 4,
241241
"./c.js": 4
242242
};
243+
244+
243245
function webpackContext(req) {
244-
return __webpack_require__(webpackContextResolve(req));
245-
};
246+
var id = webpackContextResolve(req);
247+
var module = __webpack_require__(id);
248+
return module;
249+
}
246250
function webpackContextResolve(req) {
247251
var id = map[req];
248252
if(!(id + 1)) // check for number or string
249253
throw new Error("Cannot find module '" + req + "'.");
250254
return id;
251-
};
255+
}
252256
webpackContext.keys = function webpackContextKeys() {
253257
return Object.keys(map);
254258
};
@@ -310,8 +314,8 @@ module.exports = function() {
310314
Hash: 71a61aeef010cd2fd50d
311315
Version: webpack next
312316
Asset Size Chunks Chunk Names
313-
0.output.js 2.15 KiB 0 [emitted]
314-
output.js 7.18 KiB 1 [emitted] main
317+
0.output.js 2.19 KiB 0 [emitted]
318+
output.js 7.22 KiB 1 [emitted] main
315319
Entrypoint main = output.js
316320
chunk {0} 0.output.js 463 bytes {1} [rendered]
317321
> [0] ./example.js 2:1-4:3
@@ -338,7 +342,7 @@ chunk {1} output.js (main) 276 bytes [entry] [rendered]
338342
Hash: 71a61aeef010cd2fd50d
339343
Version: webpack next
340344
Asset Size Chunks Chunk Names
341-
0.output.js 584 bytes 0 [emitted]
345+
0.output.js 592 bytes 0 [emitted]
342346
output.js 1.73 KiB 1 [emitted] main
343347
Entrypoint main = output.js
344348
chunk {0} 0.output.js 463 bytes {1} [rendered]

examples/code-splitting-harmony/README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ __webpack_require__.r(__webpack_exports__);
221221
/* harmony import */ var a__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(a__WEBPACK_IMPORTED_MODULE_0__);
222222

223223

224-
__webpack_require__.e/* import() */(2).then(__webpack_require__.bind(null, /*! b */5)).then(function(b) {
224+
__webpack_require__.e/* import() */(2).then(function() { var m = __webpack_require__(/*! b */5); return m && typeof m === "object" && m.__esModule ? m : /* fake namespace object */ { "default": m }; }).then(function(b) {
225225
console.log("b loaded", b);
226226
})
227227

228228
function loadC(name) {
229-
return __webpack_require__( 4)("./" + name);
229+
return __webpack_require__(/*! c */ 4)("./" + name);
230230
}
231231

232232
Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
@@ -247,9 +247,9 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
247247

248248
/***/ }),
249249
/* 4 */
250-
/*!**************************************!*\
251-
!*** ./node_modules/c lazy ^\.\/.*$ ***!
252-
\**************************************/
250+
/*!*******************************************************!*\
251+
!*** ./node_modules/c lazy ^\.\/.*$ namespace object ***!
252+
\*******************************************************/
253253
/*! no static exports found */
254254
/*! all exports used */
255255
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
@@ -276,11 +276,12 @@ var map = {
276276
function webpackAsyncContext(req) {
277277
var ids = map[req];
278278
if(!ids)
279-
return Promise.reject(new Error("Cannot find module '" + req + "'."));
279+
return Promise.resolve().then(function() { throw new Error("Cannot find module '" + req + "'."); });
280280
return __webpack_require__.e(ids[1]).then(function() {
281-
return __webpack_require__(ids[0]);
281+
var module = __webpack_require__(ids[0]);
282+
return typeof module !== "object" || !module.__esModule ? /* fake namespace object */ { "default": module } : module;;
282283
});
283-
};
284+
}
284285
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
285286
return Object.keys(map);
286287
};
@@ -303,7 +304,7 @@ Version: webpack next
303304
0.output.js 379 bytes 0 [emitted]
304305
1.output.js 370 bytes 1 [emitted]
305306
2.output.js 365 bytes 2 [emitted]
306-
output.js 8.53 KiB 3 [emitted] main
307+
output.js 8.85 KiB 3 [emitted] main
307308
Entrypoint main = output.js
308309
chunk {0} 0.output.js 13 bytes {3} [rendered]
309310
1 module
@@ -317,7 +318,7 @@ chunk {3} output.js (main) 427 bytes [entry] [rendered]
317318
[2] ./example.js 256 bytes {3} [built]
318319
[no exports]
319320
single entry .\example.js main
320-
[4] ./node_modules/c lazy ^\.\/.*$ 160 bytes {3} [built]
321+
[4] ./node_modules/c lazy ^\.\/.*$ namespace object 160 bytes {3} [built]
321322
import() context lazy c [2] ./example.js 8:8-27
322323
+ 1 hidden module
323324
```
@@ -331,7 +332,7 @@ Version: webpack next
331332
0.output.js 77 bytes 0 [emitted]
332333
1.output.js 76 bytes 1 [emitted]
333334
2.output.js 78 bytes 2 [emitted]
334-
output.js 2.07 KiB 3 [emitted] main
335+
output.js 2.21 KiB 3 [emitted] main
335336
Entrypoint main = output.js
336337
chunk {0} 0.output.js 13 bytes {3} [rendered]
337338
1 module
@@ -345,7 +346,7 @@ chunk {3} output.js (main) 427 bytes [entry] [rendered]
345346
[2] ./example.js 256 bytes {3} [built]
346347
[no exports]
347348
single entry .\example.js main
348-
[4] ./node_modules/c lazy ^\.\/.*$ 160 bytes {3} [built]
349+
[4] ./node_modules/c lazy ^\.\/.*$ namespace object 160 bytes {3} [built]
349350
import() context lazy c [2] ./example.js 8:8-27
350351
+ 1 hidden module
351352
```

0 commit comments

Comments
 (0)