webpack 4.1.0 → 4.4.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 +719 -721
- package/bin/webpack.js +69 -10
- package/lib/APIPlugin.js +84 -84
- package/lib/AmdMainTemplatePlugin.js +75 -77
- package/lib/AsyncDependencyToInitialChunkError.js +21 -23
- package/lib/BannerPlugin.js +101 -101
- package/lib/Chunk.js +477 -469
- package/lib/ChunkTemplate.js +51 -53
- package/lib/Compilation.js +1858 -1851
- package/lib/Compiler.js +493 -478
- package/lib/ConcurrentCompilationError.js +19 -0
- package/lib/ContextModule.js +696 -685
- package/lib/ContextModuleFactory.js +245 -243
- package/lib/DefinePlugin.js +197 -197
- package/lib/DelegatedModule.js +101 -101
- package/lib/DependenciesBlockVariable.js +51 -52
- package/lib/Dependency.js +53 -52
- package/lib/DllModule.js +54 -54
- package/lib/DllModuleFactory.js +29 -29
- package/lib/EnvironmentPlugin.js +65 -67
- package/lib/EvalDevToolModuleTemplatePlugin.js +60 -60
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +105 -105
- package/lib/ExportPropertyMainTemplatePlugin.js +40 -40
- package/lib/ExternalModule.js +159 -159
- package/lib/FunctionModuleTemplatePlugin.js +98 -98
- package/lib/HotModuleReplacement.runtime.js +631 -631
- package/lib/HotModuleReplacementPlugin.js +407 -406
- package/lib/HotUpdateChunkTemplate.js +78 -80
- package/lib/JavascriptGenerator.js +228 -229
- package/lib/JavascriptModulesPlugin.js +184 -158
- package/lib/JsonGenerator.js +42 -42
- package/lib/MainTemplate.js +406 -402
- package/lib/Module.js +343 -340
- package/lib/ModuleBuildError.js +42 -42
- package/lib/ModuleError.js +28 -28
- package/lib/ModuleFilenameHelpers.js +166 -166
- package/lib/ModuleTemplate.js +77 -79
- package/lib/ModuleWarning.js +30 -30
- package/lib/MultiCompiler.js +271 -259
- package/lib/MultiModule.js +78 -75
- package/lib/MultiModuleFactory.js +23 -23
- package/lib/MultiWatching.js +38 -37
- package/lib/NoModeWarning.js +23 -21
- package/lib/NormalModule.js +478 -470
- package/lib/NormalModuleFactory.js +483 -481
- package/lib/OptionsDefaulter.js +80 -86
- package/lib/Parser.js +2074 -2071
- package/lib/ProgressPlugin.js +231 -231
- package/lib/RawModule.js +54 -55
- package/lib/RecordIdsPlugin.js +160 -160
- package/lib/RemovedPluginError.js +13 -13
- package/lib/ResolverFactory.js +64 -67
- package/lib/RuntimeTemplate.js +267 -297
- package/lib/SetVarMainTemplatePlugin.js +57 -57
- package/lib/SourceMapDevToolPlugin.js +302 -308
- package/lib/Stats.js +1234 -1212
- package/lib/Template.js +205 -205
- package/lib/TemplatedPathPlugin.js +170 -143
- package/lib/UmdMainTemplatePlugin.js +264 -269
- package/lib/Watching.js +193 -193
- package/lib/WebAssemblyParser.js +50 -54
- package/lib/WebpackOptionsApply.js +401 -401
- package/lib/WebpackOptionsDefaulter.js +337 -317
- package/lib/WebpackOptionsValidationError.js +316 -319
- package/lib/debug/ProfilingPlugin.js +409 -405
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +328 -311
- package/lib/dependencies/AMDRequireContextDependency.js +20 -20
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +270 -241
- package/lib/dependencies/HarmonyAcceptImportDependency.js +23 -23
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +620 -606
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +53 -53
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +214 -214
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +154 -156
- package/lib/dependencies/ImportDependenciesBlock.js +17 -17
- package/lib/dependencies/ImportDependency.js +34 -34
- package/lib/dependencies/ImportEagerDependency.js +32 -32
- package/lib/dependencies/ImportParserPlugin.js +175 -179
- package/lib/dependencies/ImportWeakDependency.js +34 -34
- package/lib/dependencies/JsonExportsDependency.js +25 -25
- package/lib/dependencies/ModuleDependency.js +20 -20
- package/lib/dependencies/NullDependency.js +20 -20
- package/lib/dependencies/RequireContextDependency.js +22 -22
- package/lib/dependencies/RequireIncludeDependency.js +40 -40
- package/lib/dependencies/WebpackMissingModule.js +20 -22
- package/lib/node/NodeChunkTemplatePlugin.js +31 -31
- package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +36 -36
- package/lib/node/NodeMainTemplatePlugin.js +320 -273
- package/lib/node/ReadFileCompileWasmMainTemplatePlugin.js +113 -115
- package/lib/optimize/AggressiveSplittingPlugin.js +281 -281
- package/lib/optimize/ConcatenatedModule.js +1364 -1366
- package/lib/optimize/RemoveParentModulesPlugin.js +114 -114
- package/lib/optimize/SplitChunksPlugin.js +519 -491
- package/lib/performance/SizeLimitsPlugin.js +105 -105
- package/lib/util/TrackingSet.js +35 -35
- package/lib/util/objectToMap.js +10 -10
- package/lib/wasm/WasmModuleTemplatePlugin.js +106 -106
- package/lib/web/JsonpChunkTemplatePlugin.js +47 -47
- package/lib/web/JsonpExportMainTemplatePlugin.js +47 -47
- package/lib/web/JsonpHotUpdateChunkTemplatePlugin.js +39 -39
- package/lib/web/JsonpMainTemplatePlugin.js +425 -403
- package/lib/webpack.js +182 -179
- package/lib/webworker/WebWorkerChunkTemplatePlugin.js +35 -35
- package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +40 -40
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +177 -154
- package/package.json +9 -8
- package/schemas/WebpackOptions.json +1973 -1951
- package/schemas/ajv.absolutePath.js +55 -29
- package/schemas/plugins/BannerPlugin.json +85 -85
- package/schemas/plugins/DllPlugin.json +28 -28
- package/schemas/plugins/DllReferencePlugin.json +99 -99
- package/schemas/plugins/HashedModuleIdsPlugin.json +24 -24
- package/schemas/plugins/LoaderOptionsPlugin.json +26 -26
- package/schemas/plugins/SourceMapDevToolPlugin.json +187 -187
- package/schemas/plugins/WatchIgnorePlugin.json +16 -16
- package/schemas/plugins/debug/ProfilingPlugin.json +12 -12
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +22 -22
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +15 -15
- package/schemas/plugins/optimize/MinChunkSizePlugin.json +13 -13
@@ -1,154 +1,177 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
const Template = require("../Template");
|
8
|
-
|
9
|
-
class WebWorkerMainTemplatePlugin {
|
10
|
-
apply(mainTemplate) {
|
11
|
-
const needChunkOnDemandLoadingCode = chunk => {
|
12
|
-
for (const chunkGroup of chunk.groupsIterable) {
|
13
|
-
if (chunkGroup.getNumberOfChildren() > 0) return true;
|
14
|
-
}
|
15
|
-
return false;
|
16
|
-
};
|
17
|
-
mainTemplate.hooks.localVars.tap(
|
18
|
-
"WebWorkerMainTemplatePlugin",
|
19
|
-
(source, chunk) => {
|
20
|
-
if (needChunkOnDemandLoadingCode(chunk)) {
|
21
|
-
return Template.asString([
|
22
|
-
source,
|
23
|
-
"",
|
24
|
-
"// object to store loaded chunks",
|
25
|
-
'// "1" means "already loaded"',
|
26
|
-
"var installedChunks = {",
|
27
|
-
Template.indent(chunk.ids.map(id => `${id}: 1`).join(",\n")),
|
28
|
-
"};"
|
29
|
-
]);
|
30
|
-
}
|
31
|
-
return source;
|
32
|
-
}
|
33
|
-
);
|
34
|
-
mainTemplate.hooks.requireEnsure.tap(
|
35
|
-
"WebWorkerMainTemplatePlugin",
|
36
|
-
(_, chunk, hash) => {
|
37
|
-
const chunkFilename = mainTemplate.outputOptions.chunkFilename;
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
"
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
}
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
}
|
154
|
-
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const Template = require("../Template");
|
8
|
+
|
9
|
+
class WebWorkerMainTemplatePlugin {
|
10
|
+
apply(mainTemplate) {
|
11
|
+
const needChunkOnDemandLoadingCode = chunk => {
|
12
|
+
for (const chunkGroup of chunk.groupsIterable) {
|
13
|
+
if (chunkGroup.getNumberOfChildren() > 0) return true;
|
14
|
+
}
|
15
|
+
return false;
|
16
|
+
};
|
17
|
+
mainTemplate.hooks.localVars.tap(
|
18
|
+
"WebWorkerMainTemplatePlugin",
|
19
|
+
(source, chunk) => {
|
20
|
+
if (needChunkOnDemandLoadingCode(chunk)) {
|
21
|
+
return Template.asString([
|
22
|
+
source,
|
23
|
+
"",
|
24
|
+
"// object to store loaded chunks",
|
25
|
+
'// "1" means "already loaded"',
|
26
|
+
"var installedChunks = {",
|
27
|
+
Template.indent(chunk.ids.map(id => `${id}: 1`).join(",\n")),
|
28
|
+
"};"
|
29
|
+
]);
|
30
|
+
}
|
31
|
+
return source;
|
32
|
+
}
|
33
|
+
);
|
34
|
+
mainTemplate.hooks.requireEnsure.tap(
|
35
|
+
"WebWorkerMainTemplatePlugin",
|
36
|
+
(_, chunk, hash) => {
|
37
|
+
const chunkFilename = mainTemplate.outputOptions.chunkFilename;
|
38
|
+
const chunkMaps = chunk.getChunkMaps();
|
39
|
+
return Template.asString([
|
40
|
+
"promises.push(Promise.resolve().then(function() {",
|
41
|
+
Template.indent([
|
42
|
+
'// "1" is the signal for "already loaded"',
|
43
|
+
"if(!installedChunks[chunkId]) {",
|
44
|
+
Template.indent([
|
45
|
+
"importScripts(" +
|
46
|
+
mainTemplate.getAssetPath(JSON.stringify(chunkFilename), {
|
47
|
+
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
48
|
+
hashWithLength: length =>
|
49
|
+
`" + ${mainTemplate.renderCurrentHashCode(
|
50
|
+
hash,
|
51
|
+
length
|
52
|
+
)} + "`,
|
53
|
+
chunk: {
|
54
|
+
id: '" + chunkId + "',
|
55
|
+
contentHash: {
|
56
|
+
javascript: `" + ${JSON.stringify(
|
57
|
+
chunkMaps.contentHash.javascript
|
58
|
+
)}[chunkId] + "`
|
59
|
+
},
|
60
|
+
contentHashWithLength: {
|
61
|
+
javascript: length => {
|
62
|
+
const shortContentHashMap = {};
|
63
|
+
const contentHash = chunkMaps.contentHash.javascript;
|
64
|
+
for (const chunkId of Object.keys(contentHash)) {
|
65
|
+
if (typeof contentHash[chunkId] === "string") {
|
66
|
+
shortContentHashMap[chunkId] = contentHash[
|
67
|
+
chunkId
|
68
|
+
].substr(0, length);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
return `" + ${JSON.stringify(
|
72
|
+
shortContentHashMap
|
73
|
+
)}[chunkId] + "`;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
},
|
77
|
+
contentHashType: "javascript"
|
78
|
+
}) +
|
79
|
+
");"
|
80
|
+
]),
|
81
|
+
"}"
|
82
|
+
]),
|
83
|
+
"}));"
|
84
|
+
]);
|
85
|
+
}
|
86
|
+
);
|
87
|
+
mainTemplate.hooks.bootstrap.tap(
|
88
|
+
"WebWorkerMainTemplatePlugin",
|
89
|
+
(source, chunk, hash) => {
|
90
|
+
if (needChunkOnDemandLoadingCode(chunk)) {
|
91
|
+
const chunkCallbackName =
|
92
|
+
mainTemplate.outputOptions.chunkCallbackName;
|
93
|
+
const globalObject = mainTemplate.outputOptions.globalObject;
|
94
|
+
return Template.asString([
|
95
|
+
source,
|
96
|
+
`${globalObject}[${JSON.stringify(
|
97
|
+
chunkCallbackName
|
98
|
+
)}] = function webpackChunkCallback(chunkIds, moreModules) {`,
|
99
|
+
Template.indent([
|
100
|
+
"for(var moduleId in moreModules) {",
|
101
|
+
Template.indent(
|
102
|
+
mainTemplate.renderAddModule(
|
103
|
+
hash,
|
104
|
+
chunk,
|
105
|
+
"moduleId",
|
106
|
+
"moreModules[moduleId]"
|
107
|
+
)
|
108
|
+
),
|
109
|
+
"}",
|
110
|
+
"while(chunkIds.length)",
|
111
|
+
Template.indent("installedChunks[chunkIds.pop()] = 1;")
|
112
|
+
]),
|
113
|
+
"};"
|
114
|
+
]);
|
115
|
+
}
|
116
|
+
return source;
|
117
|
+
}
|
118
|
+
);
|
119
|
+
mainTemplate.hooks.hotBootstrap.tap(
|
120
|
+
"WebWorkerMainTemplatePlugin",
|
121
|
+
(source, chunk, hash) => {
|
122
|
+
const hotUpdateChunkFilename =
|
123
|
+
mainTemplate.outputOptions.hotUpdateChunkFilename;
|
124
|
+
const hotUpdateMainFilename =
|
125
|
+
mainTemplate.outputOptions.hotUpdateMainFilename;
|
126
|
+
const hotUpdateFunction = mainTemplate.outputOptions.hotUpdateFunction;
|
127
|
+
const globalObject = mainTemplate.outputOptions.globalObject;
|
128
|
+
const currentHotUpdateChunkFilename = mainTemplate.getAssetPath(
|
129
|
+
JSON.stringify(hotUpdateChunkFilename),
|
130
|
+
{
|
131
|
+
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
132
|
+
hashWithLength: length =>
|
133
|
+
`" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
|
134
|
+
chunk: {
|
135
|
+
id: '" + chunkId + "'
|
136
|
+
}
|
137
|
+
}
|
138
|
+
);
|
139
|
+
const currentHotUpdateMainFilename = mainTemplate.getAssetPath(
|
140
|
+
JSON.stringify(hotUpdateMainFilename),
|
141
|
+
{
|
142
|
+
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
143
|
+
hashWithLength: length =>
|
144
|
+
`" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`
|
145
|
+
}
|
146
|
+
);
|
147
|
+
|
148
|
+
return (
|
149
|
+
source +
|
150
|
+
"\n" +
|
151
|
+
`var parentHotUpdateCallback = ${globalObject}[${JSON.stringify(
|
152
|
+
hotUpdateFunction
|
153
|
+
)}];\n` +
|
154
|
+
`${globalObject}[${JSON.stringify(hotUpdateFunction)}] = ` +
|
155
|
+
Template.getFunctionContent(
|
156
|
+
require("./WebWorkerMainTemplate.runtime.js")
|
157
|
+
)
|
158
|
+
.replace(/\/\/\$semicolon/g, ";")
|
159
|
+
.replace(/\$require\$/g, mainTemplate.requireFn)
|
160
|
+
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
|
161
|
+
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
|
162
|
+
.replace(/\$hash\$/g, JSON.stringify(hash))
|
163
|
+
);
|
164
|
+
}
|
165
|
+
);
|
166
|
+
mainTemplate.hooks.hash.tap("WebWorkerMainTemplatePlugin", hash => {
|
167
|
+
hash.update("webworker");
|
168
|
+
hash.update("3");
|
169
|
+
hash.update(`${mainTemplate.outputOptions.publicPath}`);
|
170
|
+
hash.update(`${mainTemplate.outputOptions.filename}`);
|
171
|
+
hash.update(`${mainTemplate.outputOptions.chunkFilename}`);
|
172
|
+
hash.update(`${mainTemplate.outputOptions.chunkCallbackName}`);
|
173
|
+
hash.update(`${mainTemplate.outputOptions.globalObject}`);
|
174
|
+
});
|
175
|
+
}
|
176
|
+
}
|
177
|
+
module.exports = WebWorkerMainTemplatePlugin;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.4.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
|
"license": "MIT",
|
@@ -21,7 +21,7 @@
|
|
21
21
|
"node-libs-browser": "^2.0.0",
|
22
22
|
"schema-utils": "^0.4.2",
|
23
23
|
"tapable": "^1.0.0",
|
24
|
-
"uglifyjs-webpack-plugin": "^1.
|
24
|
+
"uglifyjs-webpack-plugin": "^1.2.4",
|
25
25
|
"watchpack": "^1.5.0",
|
26
26
|
"webpack-sources": "^1.0.1"
|
27
27
|
},
|
@@ -34,9 +34,10 @@
|
|
34
34
|
"coveralls": "^2.11.2",
|
35
35
|
"css-loader": "^0.28.3",
|
36
36
|
"es6-promise-polyfill": "^1.1.1",
|
37
|
-
"eslint": "^4.
|
38
|
-
"eslint-
|
39
|
-
"eslint-plugin-
|
37
|
+
"eslint": "^4.19.1",
|
38
|
+
"eslint-config-prettier": "^2.9.0",
|
39
|
+
"eslint-plugin-node": "^6.0.1",
|
40
|
+
"eslint-plugin-prettier": "^2.6.0",
|
40
41
|
"express": "~4.13.1",
|
41
42
|
"file-loader": "^1.1.6",
|
42
43
|
"glob": "^7.1.2",
|
@@ -50,7 +51,7 @@
|
|
50
51
|
"lodash": "^4.17.4",
|
51
52
|
"mocha": "^3.2.0",
|
52
53
|
"mocha-lcov-reporter": "^1.0.0",
|
53
|
-
"prettier": "^1.
|
54
|
+
"prettier": "^1.11.1",
|
54
55
|
"raw-loader": "~0.5.0",
|
55
56
|
"react": "^15.2.1",
|
56
57
|
"react-dom": "^15.2.1",
|
@@ -102,9 +103,9 @@
|
|
102
103
|
"build:examples": "cd examples && node buildAll.js",
|
103
104
|
"pretest": "npm run lint-files",
|
104
105
|
"lint-files": "npm run lint && npm run schema-lint",
|
105
|
-
"lint": "eslint lib bin hot buildin \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
|
106
|
+
"lint": "eslint lib bin hot buildin \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\"",
|
106
107
|
"fix": "npm run lint -- --fix",
|
107
|
-
"pretty-files": "prettier \"lib
|
108
|
+
"pretty-files": "prettier \"lib/**/*.js\" \"bin/*.js\" \"hot/*.js\" \"buildin/*.js\" \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\" --write",
|
108
109
|
"schema-lint": "mocha test/*.lint.js --opts test/lint-mocha.opts",
|
109
110
|
"benchmark": "mocha --max-old-space-size=4096 --harmony --trace-deprecation test/*.benchmark.js -R spec",
|
110
111
|
"cover": "npm run cover:init && npm run cover:all && npm run cover:report",
|