webpack 3.3.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -11
- package/bin/config-optimist.js +1 -0
- package/bin/config-yargs.js +12 -4
- package/bin/convert-argv.js +28 -8
- package/bin/webpack.js +198 -182
- package/lib/ContextModule.js +87 -13
- package/lib/DelegatedModule.js +10 -4
- package/lib/DelegatedModuleFactoryPlugin.js +5 -4
- package/lib/DelegatedPlugin.js +3 -0
- package/lib/DllReferencePlugin.js +3 -0
- package/lib/ExternalModule.js +6 -1
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/HotModuleReplacement.runtime.js +13 -5
- package/lib/MultiCompiler.js +2 -2
- package/lib/NormalModule.js +32 -9
- package/lib/NormalModuleFactory.js +133 -145
- package/lib/Parser.js +52 -58
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/SourceMapDevToolPlugin.js +57 -41
- package/lib/Stats.js +58 -24
- package/lib/Template.js +1 -1
- package/lib/dependencies/DelegatedExportsDependency.js +33 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +11 -4
- package/lib/dependencies/ImportPlugin.js +8 -0
- package/lib/dependencies/ImportWeakContextDependency.js +22 -0
- package/lib/dependencies/ImportWeakDependency.js +47 -0
- package/lib/dependencies/RequireContextDependency.js +5 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +9 -1
- package/lib/dependencies/RequireResolveDependencyParserPlugin.js +1 -1
- package/lib/optimize/AggressiveMergingPlugin.js +27 -33
- package/lib/optimize/AggressiveSplittingPlugin.js +46 -33
- package/lib/optimize/ChunkModuleIdRangePlugin.js +1 -3
- package/lib/optimize/CommonsChunkPlugin.js +11 -4
- package/lib/optimize/ConcatenatedModule.js +403 -229
- package/lib/optimize/ModuleConcatenationPlugin.js +30 -35
- package/lib/util/identifier.js +23 -1
- package/lib/webpack.js +52 -55
- package/package.json +10 -10
- package/schemas/webpackOptionsSchema.json +27 -12
package/README.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<a href="https://github.com/webpack/webpack">
|
3
|
+
<img width="200" heigth="200" src="https://webpack.js.org/assets/icon-square-big.svg">
|
4
|
+
</a>
|
5
|
+
<br>
|
6
|
+
<br>
|
7
|
+
|
1
8
|
[![npm][npm]][npm-url]
|
9
|
+
|
2
10
|
[![node][node]][node-url]
|
3
11
|
[![deps][deps]][deps-url]
|
4
12
|
[![tests][tests]][tests-url]
|
@@ -6,11 +14,6 @@
|
|
6
14
|
[![coverage][cover]][cover-url]
|
7
15
|
[![licenses][licenses]][licenses-url]
|
8
16
|
|
9
|
-
<div align="center">
|
10
|
-
<a href="https://github.com/webpack/webpack">
|
11
|
-
<img width="200" heigth="200" src="https://webpack.js.org/assets/icon-square-big.svg">
|
12
|
-
</a>
|
13
|
-
<br>
|
14
17
|
<br>
|
15
18
|
<a href="https://npmjs.com/package/webpack">
|
16
19
|
<img src="https://img.shields.io/npm/dm/webpack.svg">
|
@@ -32,10 +35,18 @@
|
|
32
35
|
|
33
36
|
<h2 align="center">Install</h2>
|
34
37
|
|
38
|
+
Install with npm:
|
39
|
+
|
35
40
|
```bash
|
36
41
|
npm install --save-dev webpack
|
37
42
|
```
|
38
43
|
|
44
|
+
Install with yarn:
|
45
|
+
|
46
|
+
```bash
|
47
|
+
yarn add webpack --dev
|
48
|
+
```
|
49
|
+
|
39
50
|
<h2 align="center">Introduction</h2>
|
40
51
|
|
41
52
|
> The README reflects webpack v2.x, webpack v1.x [documentation can be found here](https://webpack.github.io/docs/?utm_source=github&utm_medium=readme&utm_campaign=top).
|
@@ -120,7 +131,7 @@ or are automatically applied via regex from your webpack configuration.
|
|
120
131
|
|Name|Status|Description|
|
121
132
|
|:--:|:----:|:----------|
|
122
133
|
|<a href="https://github.com/webpack/json-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/json.svg"></a>|![json-npm]|Loads a JSON file (included by default)|
|
123
|
-
|<a href="https://github.com/webpack/json5-loader"><img width="48" height="
|
134
|
+
|<a href="https://github.com/webpack/json5-loader"><img width="48" height="10.656" src="https://cdn.rawgit.com/json5/json5-logo/master/json5-logo.svg"></a>|![json5-npm]|Loads and transpiles a JSON 5 file|
|
124
135
|
|<a href="https://github.com/awnist/cson-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a>|![cson-npm]|Loads and transpiles a CSON file|
|
125
136
|
|
126
137
|
|
@@ -183,17 +194,17 @@ or are automatically applied via regex from your webpack configuration.
|
|
183
194
|
[stylus-npm]: https://img.shields.io/npm/v/stylus-loader.svg
|
184
195
|
[postcss-npm]: https://img.shields.io/npm/v/postcss-loader.svg
|
185
196
|
|
186
|
-
#### Linting
|
197
|
+
#### Linting & Testing
|
187
198
|
|
188
199
|
|Name|Status|Description|
|
189
200
|
|:--:|:----:|:----------|
|
190
201
|
|<a href="https://github.com/webpack/mocha-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/mocha.svg"></a>|![mocha-npm]|Tests with mocha (Browser/NodeJS)|
|
191
202
|
|<a href="https://github.com/MoOx/eslint-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/eslint.svg"></a>|![eslint-npm]|PreLoader for linting code using ESLint|
|
192
|
-
|<a href="https://github.com/webpack/
|
203
|
+
|<a href="https://github.com/webpack-contrib/jshint-loader"><img width="48" height="20.64" src="http://jshint.com/res/jshint-dark.png"></a>|![jshint-npm]|PreLoader for linting code using JSHint|
|
193
204
|
|
194
205
|
[mocha-npm]: https://img.shields.io/npm/v/mocha-loader.svg
|
195
206
|
[eslint-npm]: https://img.shields.io/npm/v/eslint-loader.svg
|
196
|
-
[jshint-npm]: https://img.shields.io/npm/v/
|
207
|
+
[jshint-npm]: https://img.shields.io/npm/v/jshint-loader.svg
|
197
208
|
[jscs-npm]: https://img.shields.io/npm/v/jscs-loader.svg
|
198
209
|
|
199
210
|
#### Frameworks
|
@@ -264,7 +275,7 @@ If you create a loader or plugin, we would <3 for you to open source it, and put
|
|
264
275
|
|
265
276
|
<h2 align="center">Support</h2>
|
266
277
|
|
267
|
-
We consider webpack to be a low-level tool used not only
|
278
|
+
We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of it's flexibility, webpack isn't always the _easiest_ entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!
|
268
279
|
|
269
280
|
If you're just getting started, take a look at [our new docs and concepts page](https://webpack.js.org/concepts/). This has a high level overview that is great for beginners!!
|
270
281
|
|
@@ -314,7 +325,7 @@ If you have discovered a 🐜 or have a feature suggestion, feel free to create
|
|
314
325
|
<img width="150" height="150" src="https://github.com/bebraw.png?s=150">
|
315
326
|
<br>
|
316
327
|
<a href="https://github.com/bebraw">Juho Vepsäläinen</a>
|
317
|
-
<p>Documentation
|
328
|
+
<p>Documentation</p>
|
318
329
|
<br>
|
319
330
|
<p>Author</p>
|
320
331
|
<a href="https://leanpub.com/survivejs-webpack">
|
@@ -354,23 +365,33 @@ This is how we use the donations:
|
|
354
365
|
|
355
366
|
<h2 align="center">Premium Partners</h2>
|
356
367
|
|
368
|
+
<div align="center">
|
369
|
+
|
357
370
|
<a href="https://www.ag-grid.com/?utm_source=webpack&utm_medium=banner&utm_campaign=sponsorship" target="_blank"><img align="center" src="https://raw.githubusercontent.com/webpack/media/2b399d58/horiz-banner-ad-ag-grid.png">
|
358
371
|
</a>
|
359
372
|
|
373
|
+
</div>
|
374
|
+
|
360
375
|
<h2 align="center">Other Backers and Sponsors</h2>
|
361
376
|
|
362
377
|
Before we started using OpenCollective, donations were made anonymously. Now that we have made the switch, we would like to acknowledge these sponsors (and the ones who continue to donate using OpenCollective). If we've missed someone, please send us a PR, and we'll add you to this list.
|
363
378
|
|
379
|
+
<div align="center">
|
380
|
+
|
364
381
|
[Google Angular Team](https://angular.io/), [Architects.io](http://architects.io/),
|
365
382
|
<a href="https://moonmail.io" target="_blank" title="Email Marketing Software"><img
|
366
383
|
src="https://static.moonmail.io/moonmail-logo.svg" height="30" alt="MoonMail"></a>
|
367
384
|
<a href="https://monei.net" target="_blank" title="Best payment gateway rates"><img
|
368
385
|
src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
|
369
386
|
|
387
|
+
</div>
|
388
|
+
|
370
389
|
<h2 align="center">Sponsors</h2>
|
371
390
|
|
372
391
|
[Become a sponsor](https://opencollective.com/webpack#sponsor) and get your logo on our README on Github with a link to your site.
|
373
392
|
|
393
|
+
<div align="center">
|
394
|
+
|
374
395
|
<a href="https://opencollective.com/webpack/sponsor/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/0/avatar.svg?requireActive=false"></a>
|
375
396
|
<a href="https://opencollective.com/webpack/sponsor/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/1/avatar.svg?requireActive=false"></a>
|
376
397
|
<a href="https://opencollective.com/webpack/sponsor/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/2/avatar.svg?requireActive=false"></a>
|
@@ -402,6 +423,8 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
|
|
402
423
|
<a href="https://opencollective.com/webpack/sponsor/28/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/28/avatar.svg?requireActive=false"></a>
|
403
424
|
<a href="https://opencollective.com/webpack/sponsor/29/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/29/avatar.svg?requireActive=false"></a>
|
404
425
|
|
426
|
+
</div>
|
427
|
+
|
405
428
|
<h2 align="center">Backers</h2>
|
406
429
|
|
407
430
|
[Become a backer](https://opencollective.com/webpack#backer) and get your image on our README on Github with a link to your site.
|
package/bin/config-optimist.js
CHANGED
@@ -2,6 +2,7 @@ module.exports = function(optimist) {
|
|
2
2
|
optimist
|
3
3
|
.boolean("help").alias("help", "h").alias("help", "?").describe("help")
|
4
4
|
.string("config").describe("config", "Path to the config file")
|
5
|
+
.string("config-name").describe("config-name", "Name of the config to use")
|
5
6
|
.string("env").describe("env", "Environment passed to the config, when it is a function")
|
6
7
|
.string("context").describe("context", "The root directory for resolving entry point and stats")
|
7
8
|
.string("entry").describe("entry", "The entry point")
|
package/bin/config-yargs.js
CHANGED
@@ -9,7 +9,7 @@ var OPTIMIZE_GROUP = "Optimizing options:";
|
|
9
9
|
module.exports = function(yargs) {
|
10
10
|
yargs
|
11
11
|
.help("help")
|
12
|
-
.alias("help", "h"
|
12
|
+
.alias("help", "h")
|
13
13
|
.version()
|
14
14
|
.alias("version", "v")
|
15
15
|
.options({
|
@@ -20,6 +20,12 @@ module.exports = function(yargs) {
|
|
20
20
|
defaultDescription: "webpack.config.js or webpackfile.js",
|
21
21
|
requiresArg: true
|
22
22
|
},
|
23
|
+
"config-name": {
|
24
|
+
type: "string",
|
25
|
+
describe: "Name of the config to use",
|
26
|
+
group: CONFIG_GROUP,
|
27
|
+
requiresArg: true
|
28
|
+
},
|
23
29
|
"env": {
|
24
30
|
describe: "Environment passed to the config, when it is a function",
|
25
31
|
group: CONFIG_GROUP
|
@@ -194,7 +200,7 @@ module.exports = function(yargs) {
|
|
194
200
|
},
|
195
201
|
"resolve-extensions": {
|
196
202
|
"type": "array",
|
197
|
-
describe: "Setup extensions that should be used to resolve modules (Example: --resolve-extensions .es6
|
203
|
+
describe: "Setup extensions that should be used to resolve modules (Example: --resolve-extensions .es6,.js)",
|
198
204
|
group: RESOLVE_GROUP,
|
199
205
|
requiresArg: true
|
200
206
|
},
|
@@ -245,12 +251,14 @@ module.exports = function(yargs) {
|
|
245
251
|
"bail": {
|
246
252
|
type: "boolean",
|
247
253
|
describe: "Abort the compilation on first error",
|
248
|
-
group: ADVANCED_GROUP
|
254
|
+
group: ADVANCED_GROUP,
|
255
|
+
default: null
|
249
256
|
},
|
250
257
|
"profile": {
|
251
258
|
type: "boolean",
|
252
259
|
describe: "Profile the compilation and include information in stats",
|
253
|
-
group: ADVANCED_GROUP
|
260
|
+
group: ADVANCED_GROUP,
|
261
|
+
default: null
|
254
262
|
},
|
255
263
|
"d": {
|
256
264
|
type: "boolean",
|
package/bin/convert-argv.js
CHANGED
@@ -130,6 +130,20 @@ module.exports = function(yargs, argv, convertOptions) {
|
|
130
130
|
return processConfiguredOptions(options.default);
|
131
131
|
}
|
132
132
|
|
133
|
+
// filter multi-config by name
|
134
|
+
if(Array.isArray(options) && argv["config-name"]) {
|
135
|
+
var namedOptions = options.filter(function(opt) {
|
136
|
+
return opt.name === argv["config-name"];
|
137
|
+
});
|
138
|
+
if(namedOptions.length === 0) {
|
139
|
+
console.error("Configuration with name '" + argv["config-name"] + "' was not found.");
|
140
|
+
process.exit(-1); // eslint-disable-line
|
141
|
+
} else if(namedOptions.length === 1) {
|
142
|
+
return processConfiguredOptions(namedOptions[0]);
|
143
|
+
}
|
144
|
+
options = namedOptions;
|
145
|
+
}
|
146
|
+
|
133
147
|
if(Array.isArray(options)) {
|
134
148
|
options.forEach(processOptions);
|
135
149
|
} else {
|
@@ -279,24 +293,30 @@ module.exports = function(yargs, argv, convertOptions) {
|
|
279
293
|
ensureObject(options, "entry");
|
280
294
|
});
|
281
295
|
|
282
|
-
function
|
296
|
+
function bindRules(arg) {
|
283
297
|
ifArgPair(arg, function(name, binding) {
|
284
298
|
if(name === null) {
|
285
299
|
name = binding;
|
286
300
|
binding += "-loader";
|
287
301
|
}
|
288
|
-
|
289
|
-
test: new RegExp("\\." + name.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "$"),
|
302
|
+
var rule = {
|
303
|
+
test: new RegExp("\\." + name.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "$"), // eslint-disable-line no-useless-escape
|
290
304
|
loader: binding
|
291
|
-
}
|
305
|
+
};
|
306
|
+
if(arg === "module-bind-pre") {
|
307
|
+
rule.enforce = "pre";
|
308
|
+
} else if(arg === "module-bind-post") {
|
309
|
+
rule.enforce = "post";
|
310
|
+
}
|
311
|
+
options.module.rules.push(rule);
|
292
312
|
}, function() {
|
293
313
|
ensureObject(options, "module");
|
294
|
-
ensureArray(options.module,
|
314
|
+
ensureArray(options.module, "rules");
|
295
315
|
});
|
296
316
|
}
|
297
|
-
|
298
|
-
|
299
|
-
|
317
|
+
bindRules("module-bind");
|
318
|
+
bindRules("module-bind-pre");
|
319
|
+
bindRules("module-bind-post");
|
300
320
|
|
301
321
|
var defineObject;
|
302
322
|
ifArgPair("define", function(name, value) {
|