webpack 2.4.0 → 2.6.0
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 +9 -1
- package/lib/BannerPlugin.js +30 -8
- package/lib/Compilation.js +14 -14
- package/lib/Compiler.js +29 -24
- package/lib/ContextModule.js +133 -33
- package/lib/DelegatedModule.js +3 -1
- package/lib/ExternalModule.js +1 -1
- package/lib/HotModuleReplacement.runtime.js +3 -1
- package/lib/IgnorePlugin.js +2 -2
- package/lib/JsonpMainTemplatePlugin.js +5 -3
- package/lib/LibManifestPlugin.js +1 -1
- package/lib/NormalModule.js +1 -1
- package/lib/Parser.js +37 -22
- package/lib/ProgressPlugin.js +2 -2
- package/lib/RawModule.js +1 -1
- package/lib/Stats.js +2 -1
- package/lib/Template.js +5 -0
- package/lib/WebpackOptionsApply.js +3 -3
- package/lib/WebpackOptionsDefaulter.js +1 -0
- package/lib/dependencies/DepBlockHelpers.js +1 -1
- package/lib/dependencies/HarmonyCompatibilityDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportContextDependency.js +0 -1
- package/lib/dependencies/ImportDependency.js +1 -1
- package/lib/dependencies/ImportEagerContextDependency.js +22 -0
- package/lib/dependencies/ImportEagerDependency.js +46 -0
- package/lib/dependencies/ImportLazyContextDependency.js +22 -0
- package/lib/dependencies/ImportLazyOnceContextDependency.js +22 -0
- package/lib/dependencies/ImportParserPlugin.js +37 -6
- package/lib/dependencies/ImportPlugin.js +15 -3
- package/lib/formatLocation.js +44 -27
- package/lib/node/NodeSourcePlugin.js +72 -70
- package/lib/optimize/CommonsChunkPlugin.js +1 -1
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +4 -2
- package/package.json +6 -4
- package/schemas/webpackOptionsSchema.json +12 -0
@@ -2,83 +2,85 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
"use strict";
|
6
|
+
const AliasPlugin = require("enhanced-resolve/lib/AliasPlugin");
|
7
|
+
const ParserHelpers = require("../ParserHelpers");
|
8
|
+
const nodeLibsBrowser = require("node-libs-browser");
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
module.exports = NodeSourcePlugin;
|
13
|
-
NodeSourcePlugin.prototype.apply = function(compiler) {
|
14
|
-
var options = this.options;
|
15
|
-
|
16
|
-
function getPathToModule(module, type) {
|
17
|
-
if(type === true || (type === undefined && nodeLibsBrowser[module])) {
|
18
|
-
if(!nodeLibsBrowser[module]) throw new Error("No browser version for node.js core module '" + module + "' available");
|
19
|
-
return nodeLibsBrowser[module];
|
20
|
-
} else if(type === "mock") {
|
21
|
-
return require.resolve("node-libs-browser/mock/" + module);
|
22
|
-
} else if(type === "empty") {
|
23
|
-
return require.resolve("node-libs-browser/mock/empty");
|
24
|
-
} else return module;
|
10
|
+
module.exports = class NodeSourcePlugin {
|
11
|
+
constructor(options) {
|
12
|
+
this.options = options;
|
25
13
|
}
|
14
|
+
apply(compiler) {
|
15
|
+
const options = this.options;
|
26
16
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
17
|
+
function getPathToModule(module, type) {
|
18
|
+
if(type === true || (type === undefined && nodeLibsBrowser[module])) {
|
19
|
+
if(!nodeLibsBrowser[module]) throw new Error(`No browser version for node.js core module ${module} available`);
|
20
|
+
return nodeLibsBrowser[module];
|
21
|
+
} else if(type === "mock") {
|
22
|
+
return require.resolve(`node-libs-browser/mock/${module}`);
|
23
|
+
} else if(type === "empty") {
|
24
|
+
return require.resolve("node-libs-browser/mock/empty");
|
25
|
+
} else return module;
|
26
|
+
}
|
35
27
|
|
36
|
-
|
37
|
-
|
28
|
+
function addExpression(parser, name, module, type, suffix) {
|
29
|
+
suffix = suffix || "";
|
30
|
+
parser.plugin(`expression ${name}`, function() {
|
31
|
+
if(this.state.module && this.state.module.resource === getPathToModule(module, type)) return;
|
32
|
+
const mockModule = ParserHelpers.requireFileAsExpression(this.state.module.context, getPathToModule(module, type));
|
33
|
+
return ParserHelpers.addParsedVariableToModule(this, name, mockModule + suffix);
|
34
|
+
});
|
35
|
+
}
|
38
36
|
|
39
|
-
|
40
|
-
|
37
|
+
compiler.plugin("compilation", function(compilation, params) {
|
38
|
+
params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
localOptions = Object.assign({}, localOptions, parserOptions.node);
|
40
|
+
if(parserOptions.node === false)
|
41
|
+
return;
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
43
|
+
let localOptions = options;
|
44
|
+
if(parserOptions.node)
|
45
|
+
localOptions = Object.assign({}, localOptions, parserOptions.node);
|
46
|
+
|
47
|
+
if(localOptions.global) {
|
48
|
+
parser.plugin("expression global", function() {
|
49
|
+
const retrieveGlobalModule = ParserHelpers.requireFileAsExpression(this.state.module.context, require.resolve("../../buildin/global.js"));
|
50
|
+
return ParserHelpers.addParsedVariableToModule(this, "global", retrieveGlobalModule);
|
51
|
+
});
|
52
|
+
}
|
53
|
+
if(localOptions.process) {
|
54
|
+
const processType = localOptions.process;
|
55
|
+
addExpression(parser, "process", "process", processType);
|
56
|
+
}
|
57
|
+
if(localOptions.console) {
|
58
|
+
const consoleType = localOptions.console;
|
59
|
+
addExpression(parser, "console", "console", consoleType);
|
60
|
+
}
|
61
|
+
const bufferType = localOptions.Buffer;
|
62
|
+
if(bufferType) {
|
63
|
+
addExpression(parser, "Buffer", "buffer", bufferType, ".Buffer");
|
64
|
+
}
|
65
|
+
if(localOptions.setImmediate) {
|
66
|
+
const setImmediateType = localOptions.setImmediate;
|
67
|
+
addExpression(parser, "setImmediate", "timers", setImmediateType, ".setImmediate");
|
68
|
+
addExpression(parser, "clearImmediate", "timers", setImmediateType, ".clearImmediate");
|
69
|
+
}
|
70
|
+
});
|
69
71
|
});
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
72
|
+
compiler.plugin("after-resolvers", (compiler) => {
|
73
|
+
Object.keys(nodeLibsBrowser).forEach((lib) => {
|
74
|
+
if(options[lib] !== false) {
|
75
|
+
compiler.resolvers.normal.apply(
|
76
|
+
new AliasPlugin("described-resolve", {
|
77
|
+
name: lib,
|
78
|
+
onlyModule: true,
|
79
|
+
alias: getPathToModule(lib, options[lib])
|
80
|
+
}, "resolve")
|
81
|
+
);
|
82
|
+
}
|
83
|
+
});
|
82
84
|
});
|
83
|
-
}
|
85
|
+
}
|
84
86
|
};
|
@@ -190,7 +190,7 @@ You can however specify the name of the async chunk by passing the desired strin
|
|
190
190
|
|
191
191
|
// we dont have named chunks specified, so we just take all of them
|
192
192
|
if(asyncOrNoSelectedChunk) {
|
193
|
-
return allChunks;
|
193
|
+
return allChunks.filter(chunk => !chunk.isInitial());
|
194
194
|
}
|
195
195
|
|
196
196
|
/**
|
@@ -21,7 +21,9 @@ class WebWorkerMainTemplatePlugin {
|
|
21
21
|
return id + ": 1";
|
22
22
|
}).join(",\n")
|
23
23
|
),
|
24
|
-
"};"
|
24
|
+
"};",
|
25
|
+
"",
|
26
|
+
"var resolvedPromise = new Promise(function(resolve) { resolve(); });"
|
25
27
|
]);
|
26
28
|
}
|
27
29
|
return source;
|
@@ -44,7 +46,7 @@ class WebWorkerMainTemplatePlugin {
|
|
44
46
|
}) + ");"
|
45
47
|
]),
|
46
48
|
"}",
|
47
|
-
"return
|
49
|
+
"return resolvedPromise;"
|
48
50
|
]);
|
49
51
|
});
|
50
52
|
mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.6.0",
|
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": {
|
@@ -21,7 +21,7 @@
|
|
21
21
|
"source-map": "^0.5.3",
|
22
22
|
"supports-color": "^3.1.0",
|
23
23
|
"tapable": "~0.2.5",
|
24
|
-
"uglify-js": "^2.8.
|
24
|
+
"uglify-js": "^2.8.27",
|
25
25
|
"watchpack": "^1.3.1",
|
26
26
|
"webpack-sources": "^0.2.3",
|
27
27
|
"yargs": "^6.0.0"
|
@@ -94,11 +94,13 @@
|
|
94
94
|
"travis:benchmark": "npm run benchmark",
|
95
95
|
"appveyor:test": "node --max_old_space_size=4096 node_modules\\mocha\\bin\\mocha --harmony test/*.test.js",
|
96
96
|
"appveyor:benchmark": "npm run benchmark",
|
97
|
+
"circleci:test": "node --max_old_space_size=4096 node_modules/mocha/bin/mocha --harmony test/*.test.js",
|
98
|
+
"circleci:lint": "npm run lint-files && npm run nsp",
|
97
99
|
"build:examples": "cd examples && node buildAll.js",
|
98
100
|
"pretest": "npm run lint-files",
|
99
101
|
"lint-files": "npm run lint && npm run beautify-lint",
|
100
|
-
"lint": "eslint lib bin hot buildin test/**/webpack.config.js test/binCases/**/test.js examples/**/webpack.config.js",
|
101
|
-
"beautify-lint": "beautify-lint
|
102
|
+
"lint": "eslint lib bin hot buildin \"test/**/webpack.config.js\" \"test/binCases/**/test.js\" \"examples/**/webpack.config.js\"",
|
103
|
+
"beautify-lint": "beautify-lint \"lib/**/*.js\" \"hot/**/*.js\" \"bin/**/*.js\" \"benchmark/*.js\" \"test/*.js\"",
|
102
104
|
"nsp": "nsp check --output summary",
|
103
105
|
"benchmark": "mocha test/*.benchmark.js --harmony -R spec",
|
104
106
|
"cover": "node --harmony ./node_modules/istanbul/lib/cli.js cover -x '**/*.runtime.js' node_modules/mocha/bin/_mocha -- test/*.test.js",
|
@@ -270,6 +270,10 @@
|
|
270
270
|
"use-credentials"
|
271
271
|
]
|
272
272
|
},
|
273
|
+
"chunkLoadTimeout": {
|
274
|
+
"description": "Number of milliseconds before chunk request expires",
|
275
|
+
"type": "number"
|
276
|
+
},
|
273
277
|
"devtoolFallbackModuleFilenameTemplate": {
|
274
278
|
"description": "Similar to `output.devtoolModuleFilenameTemplate`, but used in the case of duplicate module identifiers.",
|
275
279
|
"anyOf": [
|
@@ -333,6 +337,10 @@
|
|
333
337
|
"minLength": 1,
|
334
338
|
"type": "string"
|
335
339
|
},
|
340
|
+
"hashSalt": {
|
341
|
+
"minLength": 1,
|
342
|
+
"type": "string"
|
343
|
+
},
|
336
344
|
"hotUpdateChunkFilename": {
|
337
345
|
"description": "The filename of the Hot Update Chunks. They are inside the output.path directory.",
|
338
346
|
"type": "string",
|
@@ -989,6 +997,10 @@
|
|
989
997
|
"type": "string",
|
990
998
|
"description": "sort the modules by that field"
|
991
999
|
},
|
1000
|
+
"moduleTrace": {
|
1001
|
+
"type": "boolean",
|
1002
|
+
"description": "add dependencies and origin of warnings/errors"
|
1003
|
+
},
|
992
1004
|
"chunksSort": {
|
993
1005
|
"type": "string",
|
994
1006
|
"description": "sort the chunks by that field"
|