webpack 2.3.1 → 2.4.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 +139 -132
- package/lib/APIPlugin.js +0 -6
- package/lib/AsyncDependenciesBlock.js +1 -1
- package/lib/AutomaticPrefetchPlugin.js +2 -2
- package/lib/CachePlugin.js +2 -2
- package/lib/CaseSensitiveModulesWarning.js +6 -3
- package/lib/ChunkRenderError.js +3 -1
- package/lib/ChunkTemplate.js +2 -2
- package/lib/Compilation.js +3 -3
- package/lib/Compiler.js +1 -1
- package/lib/ContextModule.js +3 -2
- package/lib/ContextModuleFactory.js +5 -5
- package/lib/DelegatedModule.js +67 -63
- package/lib/DependenciesBlock.js +65 -59
- package/lib/Dependency.js +1 -0
- package/lib/EntryModuleNotFoundError.js +16 -10
- package/lib/ExtendedAPIPlugin.js +7 -2
- package/lib/ExternalModuleFactoryPlugin.js +26 -23
- package/lib/FlagDependencyUsagePlugin.js +63 -75
- package/lib/HotModuleReplacement.runtime.js +25 -27
- package/lib/HotModuleReplacementPlugin.js +3 -5
- package/lib/IgnorePlugin.js +48 -17
- package/lib/JsonpChunkTemplatePlugin.js +24 -24
- package/lib/JsonpMainTemplatePlugin.js +182 -182
- package/lib/LibManifestPlugin.js +51 -46
- package/lib/MainTemplate.js +17 -18
- package/lib/Module.js +158 -160
- package/lib/ModuleBuildError.js +4 -2
- package/lib/ModuleDependencyError.js +2 -1
- package/lib/ModuleDependencyWarning.js +2 -1
- package/lib/ModuleError.js +2 -2
- package/lib/ModuleFilenameHelpers.js +27 -27
- package/lib/ModuleNotFoundError.js +3 -1
- package/lib/ModuleParseError.js +6 -4
- package/lib/ModuleWarning.js +2 -2
- package/lib/MultiCompiler.js +3 -4
- package/lib/MultiStats.js +3 -3
- package/lib/MultiWatching.js +2 -2
- package/lib/NamedChunksPlugin.js +30 -0
- package/lib/NodeStuffPlugin.js +80 -79
- package/lib/NormalModule.js +6 -2
- package/lib/NormalModuleFactory.js +244 -240
- package/lib/Parser.js +1256 -1079
- package/lib/ProgressPlugin.js +1 -1
- package/lib/RecordIdsPlugin.js +5 -9
- package/lib/SetVarMainTemplatePlugin.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +153 -157
- package/lib/Stats.js +32 -5
- package/lib/TemplatedPathPlugin.js +1 -0
- package/lib/UnsupportedFeatureWarning.js +2 -1
- package/lib/WebpackError.js +11 -0
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/WebpackOptionsValidationError.js +8 -4
- package/lib/dependencies/AMDDefineDependency.js +10 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -1
- package/lib/dependencies/AMDPlugin.js +3 -3
- package/lib/dependencies/ContextDependencyHelpers.js +19 -16
- package/lib/dependencies/CriticalDependencyWarning.js +4 -1
- package/lib/dependencies/DepBlockHelpers.js +3 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +2 -2
- package/lib/dependencies/ImportContextDependency.js +2 -1
- package/lib/dependencies/ImportDependenciesBlock.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +16 -2
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +11 -3
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +42 -13
- package/lib/dependencies/RequireEnsureDependency.js +9 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -17
- package/lib/optimize/CommonsChunkPlugin.js +1 -1
- package/lib/performance/AssetsOverSizeLimitWarning.js +4 -1
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +5 -1
- package/lib/performance/NoAsyncChunksWarning.js +5 -1
- package/lib/removeAndDo.js +6 -4
- package/lib/util/identifier.js +16 -0
- package/lib/webpack.js +2 -1
- package/package.json +4 -3
- package/schemas/ajv.absolutePath.js +1 -1
- package/schemas/webpackOptionsSchema.json +27 -0
@@ -2,7 +2,9 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const ContextDependencyHelpers = exports;
|
6
8
|
|
7
9
|
/**
|
8
10
|
* Escapes regular expression metacharacters
|
@@ -13,8 +15,15 @@ function quotemeta(str) {
|
|
13
15
|
return str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
14
16
|
}
|
15
17
|
|
16
|
-
ContextDependencyHelpers.create = function(Dep, range, param, expr, options) {
|
17
|
-
|
18
|
+
ContextDependencyHelpers.create = function(Dep, range, param, expr, options, chunkName) {
|
19
|
+
let dep;
|
20
|
+
let prefix;
|
21
|
+
let postfix;
|
22
|
+
let prefixRange;
|
23
|
+
let valueRange;
|
24
|
+
let idx;
|
25
|
+
let context;
|
26
|
+
let regExp;
|
18
27
|
if(param.isTemplateString()) {
|
19
28
|
prefix = param.quasis[0].string;
|
20
29
|
postfix = param.quasis.length > 1 ? param.quasis[param.quasis.length - 1].string : "";
|
@@ -24,14 +33,11 @@ ContextDependencyHelpers.create = function(Dep, range, param, expr, options) {
|
|
24
33
|
context = ".";
|
25
34
|
if(idx >= 0) {
|
26
35
|
context = prefix.substr(0, idx);
|
27
|
-
prefix =
|
36
|
+
prefix = `.${prefix.substr(idx)}`;
|
28
37
|
}
|
29
38
|
// If there are more than two quasis, maybe the generated RegExp can be more precise?
|
30
|
-
regExp = new RegExp(
|
31
|
-
|
32
|
-
options.wrappedContextRegExp.source +
|
33
|
-
quotemeta(postfix) + "$");
|
34
|
-
dep = new Dep(context, options.wrappedContextRecursive, regExp, range, valueRange);
|
39
|
+
regExp = new RegExp(`^${quotemeta(prefix)}${options.wrappedContextRegExp.source}${quotemeta(postfix)}$`);
|
40
|
+
dep = new Dep(context, options.wrappedContextRecursive, regExp, range, valueRange, chunkName);
|
35
41
|
dep.loc = expr.loc;
|
36
42
|
dep.replaces = [{
|
37
43
|
range: prefixRange,
|
@@ -48,19 +54,16 @@ ContextDependencyHelpers.create = function(Dep, range, param, expr, options) {
|
|
48
54
|
context = ".";
|
49
55
|
if(idx >= 0) {
|
50
56
|
context = prefix.substr(0, idx);
|
51
|
-
prefix =
|
57
|
+
prefix = `.${prefix.substr(idx)}`;
|
52
58
|
}
|
53
|
-
regExp = new RegExp(
|
54
|
-
|
55
|
-
options.wrappedContextRegExp.source +
|
56
|
-
quotemeta(postfix) + "$");
|
57
|
-
dep = new Dep(context, options.wrappedContextRecursive, regExp, range, valueRange);
|
59
|
+
regExp = new RegExp(`^${quotemeta(prefix)}${options.wrappedContextRegExp.source}${quotemeta(postfix)}$`);
|
60
|
+
dep = new Dep(context, options.wrappedContextRecursive, regExp, range, valueRange, chunkName);
|
58
61
|
dep.loc = expr.loc;
|
59
62
|
dep.prepend = param.prefix && param.prefix.isString() ? prefix : null;
|
60
63
|
dep.critical = options.wrappedContextCritical && "a part of the request of a dependency is an expression";
|
61
64
|
return dep;
|
62
65
|
} else {
|
63
|
-
dep = new Dep(options.exprContextRequest, options.exprContextRecursive, options.exprContextRegExp, range, param.range);
|
66
|
+
dep = new Dep(options.exprContextRequest, options.exprContextRecursive, options.exprContextRegExp, range, param.range, chunkName);
|
64
67
|
dep.loc = expr.loc;
|
65
68
|
dep.critical = options.exprContextCritical && "the request of a dependency is an expression";
|
66
69
|
return dep;
|
@@ -4,12 +4,15 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
|
7
|
+
const WebpackError = require("../WebpackError");
|
8
8
|
|
9
|
+
class CriticalDependencyWarning extends WebpackError {
|
9
10
|
constructor(message) {
|
10
11
|
super();
|
12
|
+
|
11
13
|
this.name = "CriticalDependencyWarning";
|
12
14
|
this.message = "Critical dependency: " + message;
|
15
|
+
|
13
16
|
Error.captureStackTrace(this, this.constructor);
|
14
17
|
}
|
15
18
|
}
|
@@ -16,11 +16,11 @@ DepBlockHelpers.getLoadDepBlockWrapper = function(depBlock, outputOptions, reque
|
|
16
16
|
DepBlockHelpers.getDepBlockPromise = function(depBlock, outputOptions, requestShortener, name) {
|
17
17
|
if(depBlock.chunks) {
|
18
18
|
var chunks = depBlock.chunks.filter(function(chunk) {
|
19
|
-
return !chunk.hasRuntime() &&
|
19
|
+
return !chunk.hasRuntime() && chunk.id !== null;
|
20
20
|
});
|
21
21
|
if(chunks.length === 1) {
|
22
22
|
var chunk = chunks[0];
|
23
|
-
return "__webpack_require__.e" + asComment(name) + "(" + chunk.id + "" +
|
23
|
+
return "__webpack_require__.e" + asComment(name) + "(" + JSON.stringify(chunk.id) + "" +
|
24
24
|
(outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : "") +
|
25
25
|
asComment(depBlock.chunkReason) + ")";
|
26
26
|
} else if(chunks.length > 0) {
|
@@ -28,7 +28,7 @@ DepBlockHelpers.getDepBlockPromise = function(depBlock, outputOptions, requestSh
|
|
28
28
|
(outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : "") +
|
29
29
|
"[" +
|
30
30
|
chunks.map(function(chunk) {
|
31
|
-
return "__webpack_require__.e(" + chunk.id + ")";
|
31
|
+
return "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")";
|
32
32
|
}).join(", ") +
|
33
33
|
"])";
|
34
34
|
}
|
@@ -25,7 +25,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
25
25
|
dep.loc = Object.create(statement.loc);
|
26
26
|
dep.loc.index = -1;
|
27
27
|
parser.state.current.addDependency(dep);
|
28
|
-
parser.state.
|
28
|
+
parser.state.lastHarmonyImport = dep;
|
29
29
|
return true;
|
30
30
|
});
|
31
31
|
parser.plugin("export expression", (statement, expr) => {
|
@@ -53,7 +53,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
53
53
|
return true;
|
54
54
|
});
|
55
55
|
parser.plugin("export import specifier", (statement, source, id, name, idx) => {
|
56
|
-
const dep = new HarmonyExportImportedSpecifierDependency(parser.state.module, parser.state.
|
56
|
+
const dep = new HarmonyExportImportedSpecifierDependency(parser.state.module, parser.state.lastHarmonyImport, HarmonyModulesHelpers.getModuleVar(parser.state, source), id, name);
|
57
57
|
dep.loc = Object.create(statement.loc);
|
58
58
|
dep.loc.index = idx;
|
59
59
|
parser.state.current.addDependency(dep);
|
@@ -8,11 +8,12 @@ const CriticalDependencyWarning = require("./CriticalDependencyWarning");
|
|
8
8
|
const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
|
9
9
|
|
10
10
|
class ImportContextDependency extends ContextDependency {
|
11
|
-
constructor(request, recursive, regExp, range, valueRange) {
|
11
|
+
constructor(request, recursive, regExp, range, valueRange, chunkName) {
|
12
12
|
super(request, recursive, regExp);
|
13
13
|
this.range = range;
|
14
14
|
this.valueRange = valueRange;
|
15
15
|
this.async = true;
|
16
|
+
this.chunkName = chunkName;
|
16
17
|
}
|
17
18
|
|
18
19
|
get type() {
|
@@ -7,8 +7,8 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
|
|
7
7
|
const ImportDependency = require("./ImportDependency");
|
8
8
|
|
9
9
|
module.exports = class ImportDependenciesBlock extends AsyncDependenciesBlock {
|
10
|
-
constructor(request, range, module, loc) {
|
11
|
-
super(
|
10
|
+
constructor(request, range, chunkName, module, loc) {
|
11
|
+
super(chunkName, module, loc);
|
12
12
|
this.range = range;
|
13
13
|
const dep = new ImportDependency(request, this);
|
14
14
|
dep.loc = loc;
|
@@ -15,16 +15,30 @@ class ImportParserPlugin {
|
|
15
15
|
|
16
16
|
apply(parser) {
|
17
17
|
const options = this.options;
|
18
|
+
|
18
19
|
parser.plugin(["call System.import", "import-call"], (expr) => {
|
19
20
|
if(expr.arguments.length !== 1)
|
20
21
|
throw new Error("Incorrect number of arguments provided to 'import(module: string) -> Promise'.");
|
22
|
+
|
21
23
|
const param = parser.evaluateExpression(expr.arguments[0]);
|
24
|
+
|
25
|
+
let chunkName = null;
|
26
|
+
|
27
|
+
const importOptions = parser.getCommentOptions(expr.range);
|
28
|
+
if(importOptions) {
|
29
|
+
if(typeof importOptions.webpackChunkName !== "undefined") {
|
30
|
+
if(typeof importOptions.webpackChunkName !== "string")
|
31
|
+
throw new Error(`\`webpackChunkName\` expected a string, but received: ${importOptions.webpackChunkName}.`);
|
32
|
+
chunkName = importOptions.webpackChunkName;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
22
36
|
if(param.isString()) {
|
23
|
-
const depBlock = new ImportDependenciesBlock(param.string, expr.range, parser.state.module, expr.loc);
|
37
|
+
const depBlock = new ImportDependenciesBlock(param.string, expr.range, chunkName, parser.state.module, expr.loc);
|
24
38
|
parser.state.current.addBlock(depBlock);
|
25
39
|
return true;
|
26
40
|
} else {
|
27
|
-
const dep = ContextDependencyHelpers.create(ImportContextDependency, expr.range, param, expr, options);
|
41
|
+
const dep = ContextDependencyHelpers.create(ImportContextDependency, expr.range, param, expr, options, chunkName);
|
28
42
|
if(!dep) return;
|
29
43
|
dep.loc = expr.loc;
|
30
44
|
dep.optional = !!parser.scope.inTry;
|
@@ -7,11 +7,19 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
|
|
7
7
|
const RequireEnsureDependency = require("./RequireEnsureDependency");
|
8
8
|
|
9
9
|
module.exports = class RequireEnsureDependenciesBlock extends AsyncDependenciesBlock {
|
10
|
-
constructor(expr,
|
10
|
+
constructor(expr, successExpression, errorExpression, chunkName, chunkNameRange, module, loc) {
|
11
11
|
super(chunkName, module, loc);
|
12
12
|
this.expr = expr;
|
13
|
-
const
|
14
|
-
|
13
|
+
const successBodyRange = successExpression && successExpression.body && successExpression.body.range;
|
14
|
+
const errorBodyRange = errorExpression && errorExpression.body && errorExpression.body.range;
|
15
|
+
this.range = null;
|
16
|
+
if(successBodyRange) {
|
17
|
+
if(errorBodyRange) {
|
18
|
+
this.range = [successBodyRange[0] + 1, errorBodyRange[1] - 1];
|
19
|
+
} else {
|
20
|
+
this.range = [successBodyRange[0] + 1, successBodyRange[1] - 1];
|
21
|
+
}
|
22
|
+
}
|
15
23
|
this.chunkNameRange = chunkNameRange;
|
16
24
|
const dep = new RequireEnsureDependency(this);
|
17
25
|
dep.loc = loc;
|
@@ -13,27 +13,48 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
|
13
13
|
parser.plugin("call require.ensure", expr => {
|
14
14
|
let chunkName = null;
|
15
15
|
let chunkNameRange = null;
|
16
|
+
let errorExpressionArg = null;
|
17
|
+
let errorExpression = null;
|
16
18
|
switch(expr.arguments.length) {
|
17
|
-
case
|
19
|
+
case 4:
|
18
20
|
{
|
19
|
-
const chunkNameExpr = parser.evaluateExpression(expr.arguments[
|
21
|
+
const chunkNameExpr = parser.evaluateExpression(expr.arguments[3]);
|
20
22
|
if(!chunkNameExpr.isString()) return;
|
21
23
|
chunkNameRange = chunkNameExpr.range;
|
22
24
|
chunkName = chunkNameExpr.string;
|
23
25
|
}
|
24
26
|
// falls through
|
27
|
+
case 3:
|
28
|
+
{
|
29
|
+
errorExpressionArg = expr.arguments[2];
|
30
|
+
errorExpression = getFunctionExpression(errorExpressionArg);
|
31
|
+
|
32
|
+
if(!errorExpression && !chunkName) {
|
33
|
+
const chunkNameExpr = parser.evaluateExpression(expr.arguments[2]);
|
34
|
+
if(!chunkNameExpr.isString()) return;
|
35
|
+
chunkNameRange = chunkNameExpr.range;
|
36
|
+
chunkName = chunkNameExpr.string;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
// falls through
|
25
40
|
case 2:
|
26
41
|
{
|
27
42
|
const dependenciesExpr = parser.evaluateExpression(expr.arguments[0]);
|
28
43
|
const dependenciesItems = dependenciesExpr.isArray() ? dependenciesExpr.items : [dependenciesExpr];
|
29
|
-
const
|
30
|
-
const
|
44
|
+
const successExpressionArg = expr.arguments[1];
|
45
|
+
const successExpression = getFunctionExpression(successExpressionArg);
|
31
46
|
|
32
|
-
if(
|
33
|
-
parser.walkExpressions(
|
47
|
+
if(successExpression) {
|
48
|
+
parser.walkExpressions(successExpression.expressions);
|
49
|
+
}
|
50
|
+
if(errorExpression) {
|
51
|
+
parser.walkExpressions(errorExpression.expressions);
|
34
52
|
}
|
35
53
|
|
36
|
-
const dep = new RequireEnsureDependenciesBlock(expr,
|
54
|
+
const dep = new RequireEnsureDependenciesBlock(expr,
|
55
|
+
successExpression ? successExpression.fn : successExpressionArg,
|
56
|
+
errorExpression ? errorExpression.fn : errorExpressionArg,
|
57
|
+
chunkName, chunkNameRange, parser.state.module, expr.loc);
|
37
58
|
const old = parser.state.current;
|
38
59
|
parser.state.current = dep;
|
39
60
|
try {
|
@@ -52,18 +73,26 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
|
52
73
|
if(failed) {
|
53
74
|
return;
|
54
75
|
}
|
55
|
-
if(
|
56
|
-
if(
|
57
|
-
parser.walkStatement(
|
76
|
+
if(successExpression) {
|
77
|
+
if(successExpression.fn.body.type === "BlockStatement")
|
78
|
+
parser.walkStatement(successExpression.fn.body);
|
58
79
|
else
|
59
|
-
parser.walkExpression(
|
80
|
+
parser.walkExpression(successExpression.fn.body);
|
60
81
|
}
|
61
82
|
old.addBlock(dep);
|
62
83
|
} finally {
|
63
84
|
parser.state.current = old;
|
64
85
|
}
|
65
|
-
if(!
|
66
|
-
parser.walkExpression(
|
86
|
+
if(!successExpression) {
|
87
|
+
parser.walkExpression(successExpressionArg);
|
88
|
+
}
|
89
|
+
if(errorExpression) {
|
90
|
+
if(errorExpression.fn.body.type === "BlockStatement")
|
91
|
+
parser.walkStatement(errorExpression.fn.body);
|
92
|
+
else
|
93
|
+
parser.walkExpression(errorExpression.fn.body);
|
94
|
+
} else if(errorExpressionArg) {
|
95
|
+
parser.walkExpression(errorExpressionArg);
|
67
96
|
}
|
68
97
|
return true;
|
69
98
|
}
|
@@ -21,10 +21,17 @@ RequireEnsureDependency.Template = class RequireEnsureDependencyTemplate {
|
|
21
21
|
apply(dep, source, outputOptions, requestShortener) {
|
22
22
|
const depBlock = dep.block;
|
23
23
|
const wrapper = DepBlockHelpers.getLoadDepBlockWrapper(depBlock, outputOptions, requestShortener, "require.ensure");
|
24
|
+
const errorCallbackExists = depBlock.expr.arguments.length === 4 || (!depBlock.chunkName && depBlock.expr.arguments.length === 3);
|
24
25
|
const startBlock = wrapper[0] + "(";
|
25
|
-
const
|
26
|
+
const middleBlock = `).bind(null, __webpack_require__)${wrapper[1]}`;
|
27
|
+
const endBlock = `${middleBlock}__webpack_require__.oe${wrapper[2]}`;
|
26
28
|
source.replace(depBlock.expr.range[0], depBlock.expr.arguments[1].range[0] - 1, startBlock);
|
27
|
-
|
29
|
+
if(errorCallbackExists) {
|
30
|
+
source.replace(depBlock.expr.arguments[1].range[1], depBlock.expr.arguments[2].range[0] - 1, middleBlock);
|
31
|
+
source.replace(depBlock.expr.arguments[2].range[1], depBlock.expr.range[1] - 1, wrapper[2]);
|
32
|
+
} else {
|
33
|
+
source.replace(depBlock.expr.arguments[1].range[1], depBlock.expr.range[1] - 1, endBlock);
|
34
|
+
}
|
28
35
|
}
|
29
36
|
};
|
30
37
|
|
@@ -4,18 +4,7 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
function makeRelative(context) {
|
10
|
-
return function(module) {
|
11
|
-
const identifier = module.identifier();
|
12
|
-
return identifier.split("|").map((str) => {
|
13
|
-
return str.split("!").map((str) => {
|
14
|
-
return path.relative(context, str);
|
15
|
-
}).join("!");
|
16
|
-
}).join("|");
|
17
|
-
};
|
18
|
-
}
|
7
|
+
const identifierUtils = require("../util/identifier");
|
19
8
|
|
20
9
|
function toIndexOf(list) {
|
21
10
|
return function(item) {
|
@@ -73,7 +62,7 @@ class AggressiveSplittingPlugin {
|
|
73
62
|
const splitData = usedSplits[j];
|
74
63
|
for(let i = 0; i < chunks.length; i++) {
|
75
64
|
const chunk = chunks[i];
|
76
|
-
const chunkModuleNames = chunk.modules.map(
|
65
|
+
const chunkModuleNames = chunk.modules.map(m => identifierUtils.makePathsRelative(compiler.context, m.identifier()));
|
77
66
|
|
78
67
|
if(chunkModuleNames.length < splitData.modules.length)
|
79
68
|
continue;
|
@@ -91,7 +80,9 @@ class AggressiveSplittingPlugin {
|
|
91
80
|
newChunk._fromAggressiveSplitting = true;
|
92
81
|
if(j < savedSplits.length)
|
93
82
|
newChunk._fromAggressiveSplittingIndex = j;
|
94
|
-
if(
|
83
|
+
if(splitData.id !== null && splitData.id !== undefined) {
|
84
|
+
newChunk.id = splitData.id;
|
85
|
+
}
|
95
86
|
newChunk.origins = chunk.origins.map(copyWithReason);
|
96
87
|
chunk.origins = chunk.origins.map(copyWithReason);
|
97
88
|
return true;
|
@@ -99,7 +90,9 @@ class AggressiveSplittingPlugin {
|
|
99
90
|
if(j < savedSplits.length)
|
100
91
|
chunk._fromAggressiveSplittingIndex = j;
|
101
92
|
chunk.name = null;
|
102
|
-
if(
|
93
|
+
if(splitData.id !== null && splitData.id !== undefined) {
|
94
|
+
chunk.id = splitData.id;
|
95
|
+
}
|
103
96
|
}
|
104
97
|
}
|
105
98
|
}
|
@@ -144,7 +137,7 @@ class AggressiveSplittingPlugin {
|
|
144
137
|
newChunk.origins = chunk.origins.map(copyWithReason);
|
145
138
|
chunk.origins = chunk.origins.map(copyWithReason);
|
146
139
|
compilation._aggressiveSplittingSplits = (compilation._aggressiveSplittingSplits || []).concat({
|
147
|
-
modules: newChunk.modules.map(
|
140
|
+
modules: newChunk.modules.map(m => identifierUtils.makePathsRelative(compiler.context, m.identifier()))
|
148
141
|
});
|
149
142
|
return true;
|
150
143
|
} else {
|
@@ -161,7 +154,7 @@ class AggressiveSplittingPlugin {
|
|
161
154
|
if(chunk.hasEntryModule()) return;
|
162
155
|
const size = chunk.size(this.options);
|
163
156
|
const incorrectSize = size < minSize;
|
164
|
-
const modules = chunk.modules.map(
|
157
|
+
const modules = chunk.modules.map(m => identifierUtils.makePathsRelative(compiler.context, m.identifier()));
|
165
158
|
if(typeof chunk._fromAggressiveSplittingIndex === "undefined") {
|
166
159
|
if(incorrectSize) return;
|
167
160
|
chunk.recorded = true;
|
@@ -244,7 +244,7 @@ Take a look at the "name"/"names" or async/children option.`);
|
|
244
244
|
return allChunks.filter((chunk) => {
|
245
245
|
const found = targetChunks.indexOf(chunk);
|
246
246
|
if(found >= currentIndex) return false;
|
247
|
-
return chunk.
|
247
|
+
return chunk.hasRuntime();
|
248
248
|
});
|
249
249
|
}
|
250
250
|
|
@@ -3,9 +3,11 @@
|
|
3
3
|
Author Sean Larkin @thelarkinn
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
|
+
|
7
|
+
const WebpackError = require("../WebpackError");
|
6
8
|
const SizeFormatHelpers = require("../SizeFormatHelpers");
|
7
9
|
|
8
|
-
module.exports = class AssetsOverSizeLimitWarning extends
|
10
|
+
module.exports = class AssetsOverSizeLimitWarning extends WebpackError {
|
9
11
|
constructor(assetsOverSizeLimit, assetLimit) {
|
10
12
|
super();
|
11
13
|
|
@@ -15,6 +17,7 @@ module.exports = class AssetsOverSizeLimitWarning extends Error {
|
|
15
17
|
this.message = `asset size limit: The following asset(s) exceed the recommended size limit (${SizeFormatHelpers.formatSize(assetLimit)}).
|
16
18
|
This can impact web performance.
|
17
19
|
Assets: ${assetLists}`;
|
20
|
+
|
18
21
|
Error.captureStackTrace(this, this.constructor);
|
19
22
|
}
|
20
23
|
};
|
@@ -3,11 +3,14 @@
|
|
3
3
|
Author Sean Larkin @thelarkinn
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
|
+
|
7
|
+
const WebpackError = require("../WebpackError");
|
6
8
|
const SizeFormatHelpers = require("../SizeFormatHelpers");
|
7
9
|
|
8
|
-
module.exports = class EntrypointsOverSizeLimitWarning extends
|
10
|
+
module.exports = class EntrypointsOverSizeLimitWarning extends WebpackError {
|
9
11
|
constructor(entrypoints, entrypointLimit) {
|
10
12
|
super();
|
13
|
+
|
11
14
|
this.name = "EntrypointsOverSizeLimitWarning";
|
12
15
|
this.entrypoints = entrypoints;
|
13
16
|
const entrypointList = this.entrypoints.map(entrypoint => `\n ${
|
@@ -19,6 +22,7 @@ module.exports = class EntrypointsOverSizeLimitWarning extends Error {
|
|
19
22
|
}`).join("");
|
20
23
|
this.message = `entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (${SizeFormatHelpers.formatSize(entrypointLimit)}). This can impact web performance.
|
21
24
|
Entrypoints:${entrypointList}\n`;
|
25
|
+
|
22
26
|
Error.captureStackTrace(this, this.constructor);
|
23
27
|
}
|
24
28
|
};
|
@@ -4,13 +4,17 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
|
7
|
+
const WebpackError = require("../WebpackError");
|
8
|
+
|
9
|
+
module.exports = class NoAsyncChunksWarning extends WebpackError {
|
8
10
|
constructor() {
|
9
11
|
super();
|
12
|
+
|
10
13
|
this.name = "NoAsyncChunksWarning";
|
11
14
|
this.message = "webpack performance recommendations: \n" +
|
12
15
|
"You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.\n" +
|
13
16
|
"For more info visit https://webpack.js.org/guides/code-splitting/";
|
17
|
+
|
14
18
|
Error.captureStackTrace(this, this.constructor);
|
15
19
|
}
|
16
20
|
};
|
package/lib/removeAndDo.js
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
+
"use strict";
|
6
|
+
|
5
7
|
module.exports = function removeAndDo(collection, thing, action) {
|
6
|
-
|
7
|
-
|
8
|
+
const idx = this[collection].indexOf(thing);
|
9
|
+
const hasThingInCollection = idx >= 0;
|
10
|
+
if(hasThingInCollection) {
|
8
11
|
this[collection].splice(idx, 1);
|
9
12
|
thing[action](this);
|
10
|
-
return true;
|
11
13
|
}
|
12
|
-
return
|
14
|
+
return hasThingInCollection;
|
13
15
|
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
const path = require("path");
|
3
|
+
|
4
|
+
const looksLikeAbsolutePath = (maybeAbsolutePath) => {
|
5
|
+
return /^(?:[a-z]:\\|\/)/i.test(maybeAbsolutePath);
|
6
|
+
};
|
7
|
+
|
8
|
+
const normalizePathSeparator = (p) => p.replace(/\\/g, "/");
|
9
|
+
|
10
|
+
exports.makePathsRelative = (context, identifier) => {
|
11
|
+
return identifier
|
12
|
+
.split(/([|! ])/)
|
13
|
+
.map(str => looksLikeAbsolutePath(str) ?
|
14
|
+
normalizePathSeparator(path.relative(context, str)) : str)
|
15
|
+
.join("");
|
16
|
+
};
|
package/lib/webpack.js
CHANGED
@@ -40,7 +40,7 @@ function webpack(options, callback) {
|
|
40
40
|
if(callback) {
|
41
41
|
if(typeof callback !== "function") throw new Error("Invalid argument: callback");
|
42
42
|
if(options.watch === true || (Array.isArray(options) && options.some(o => o.watch))) {
|
43
|
-
const watchOptions =
|
43
|
+
const watchOptions = Array.isArray(options) ? options.map(o => o.watchOptions || {}) : (options.watchOptions || {});
|
44
44
|
return compiler.watch(watchOptions, callback);
|
45
45
|
}
|
46
46
|
compiler.run(callback);
|
@@ -102,6 +102,7 @@ exportPlugins(exports, ".", [
|
|
102
102
|
"DllReferencePlugin",
|
103
103
|
"LoaderOptionsPlugin",
|
104
104
|
"NamedModulesPlugin",
|
105
|
+
"NamedChunksPlugin",
|
105
106
|
"HashedModuleIdsPlugin",
|
106
107
|
"ModuleFilenameHelpers"
|
107
108
|
]);
|
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.4.1",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"dependencies": {
|
7
|
-
"acorn": "^
|
7
|
+
"acorn": "^5.0.0",
|
8
8
|
"acorn-dynamic-import": "^2.0.0",
|
9
9
|
"ajv": "^4.7.0",
|
10
10
|
"ajv-keywords": "^1.1.1",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"enhanced-resolve": "^3.0.0",
|
13
13
|
"interpret": "^1.0.0",
|
14
14
|
"json-loader": "^0.5.4",
|
15
|
+
"json5": "^0.5.1",
|
15
16
|
"loader-runner": "^2.3.0",
|
16
17
|
"loader-utils": "^0.2.16",
|
17
18
|
"memory-fs": "~0.4.1",
|
@@ -22,7 +23,7 @@
|
|
22
23
|
"tapable": "~0.2.5",
|
23
24
|
"uglify-js": "^2.8.5",
|
24
25
|
"watchpack": "^1.3.1",
|
25
|
-
"webpack-sources": "^0.2.
|
26
|
+
"webpack-sources": "^0.2.3",
|
26
27
|
"yargs": "^6.0.0"
|
27
28
|
},
|
28
29
|
"license": "MIT",
|
@@ -17,7 +17,7 @@ module.exports = (ajv) => ajv.addKeyword("absolutePath", {
|
|
17
17
|
type: "string",
|
18
18
|
compile(expected, schema) {
|
19
19
|
function callback(data) {
|
20
|
-
const passes = expected === /^(?:[A-
|
20
|
+
const passes = expected === /^(?:[A-Za-z]:\\|\/)/.test(data);
|
21
21
|
if(!passes) {
|
22
22
|
callback.errors = [getErrorFor(expected, data, schema)];
|
23
23
|
}
|
@@ -707,6 +707,19 @@
|
|
707
707
|
"type": "object"
|
708
708
|
}
|
709
709
|
]
|
710
|
+
},
|
711
|
+
"warning-filters-types": {
|
712
|
+
"anyOf": [
|
713
|
+
{
|
714
|
+
"instanceof": "RegExp"
|
715
|
+
},
|
716
|
+
{
|
717
|
+
"type": "string"
|
718
|
+
},
|
719
|
+
{
|
720
|
+
"instanceof": "Function"
|
721
|
+
}
|
722
|
+
]
|
710
723
|
}
|
711
724
|
},
|
712
725
|
"properties": {
|
@@ -950,6 +963,20 @@
|
|
950
963
|
"type": "boolean",
|
951
964
|
"description": "add the source code of modules"
|
952
965
|
},
|
966
|
+
"warningsFilter": {
|
967
|
+
"description": "Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions",
|
968
|
+
"anyOf": [
|
969
|
+
{
|
970
|
+
"type": "array",
|
971
|
+
"items": {
|
972
|
+
"$ref": "#/definitions/warning-filters-types"
|
973
|
+
}
|
974
|
+
},
|
975
|
+
{
|
976
|
+
"$ref": "#/definitions/warning-filters-types"
|
977
|
+
}
|
978
|
+
]
|
979
|
+
},
|
953
980
|
"errorDetails": {
|
954
981
|
"type": "boolean",
|
955
982
|
"description": "add details to errors (like resolving log)"
|