webpack 4.20.2 → 4.23.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/LICENSE +20 -20
- package/SECURITY.md +9 -9
- package/buildin/amd-define.js +3 -3
- package/buildin/amd-options.js +2 -2
- package/buildin/global.js +20 -20
- package/buildin/module.js +22 -22
- package/buildin/system.js +7 -7
- package/declarations/WebpackOptions.d.ts +1388 -0
- package/declarations/plugins/BannerPlugin.d.ts +51 -0
- package/declarations/plugins/DllPlugin.d.ts +28 -0
- package/declarations/plugins/DllReferencePlugin.d.ts +126 -0
- package/declarations/plugins/HashedModuleIdsPlugin.d.ts +24 -0
- package/declarations/plugins/IgnorePlugin.d.ts +27 -0
- package/declarations/plugins/LoaderOptionsPlugin.d.ts +27 -0
- package/declarations/plugins/SourceMapDevToolPlugin.d.ts +94 -0
- package/declarations/plugins/WatchIgnorePlugin.d.ts +10 -0
- package/declarations/plugins/debug/ProfilingPlugin.d.ts +12 -0
- package/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts +24 -0
- package/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts +16 -0
- package/declarations/plugins/optimize/MinChunkSizePlugin.d.ts +12 -0
- package/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts +12 -0
- package/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts +12 -0
- package/hot/emitter.js +2 -2
- package/lib/AmdMainTemplatePlugin.js +22 -5
- package/lib/BasicEvaluatedExpression.js +211 -211
- package/lib/Chunk.js +33 -14
- package/lib/Compilation.js +99 -52
- package/lib/Compiler.js +6 -1
- package/lib/ConstPlugin.js +85 -0
- package/lib/Entrypoint.js +10 -0
- package/lib/ExternalModule.js +3 -2
- package/lib/LibraryTemplatePlugin.js +11 -8
- package/lib/MainTemplate.js +13 -0
- package/lib/Parser.js +9 -1
- package/lib/Stats.js +44 -45
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/Watching.js +4 -3
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +3 -1
- package/lib/node/NodeWatchFileSystem.js +16 -6
- package/lib/optimize/LimitChunkCountPlugin.js +11 -5
- package/lib/optimize/OccurrenceModuleOrderPlugin.js +5 -1
- package/lib/wasm/WasmFinalizeExportsPlugin.js +2 -0
- package/lib/wasm/WebAssemblyJavascriptGenerator.js +9 -4
- package/lib/wasm/WebAssemblyParser.js +2 -1
- package/lib/web/JsonpMainTemplate.runtime.js +1 -1
- package/lib/web/JsonpMainTemplatePlugin.js +1 -3
- package/package.json +14 -12
- package/schemas/WebpackOptions.json +1 -0
- package/schemas/ajv.absolutePath.js +55 -55
- package/schemas/plugins/DllReferencePlugin.json +1 -0
package/lib/Watching.js
CHANGED
@@ -50,7 +50,6 @@ class Watching {
|
|
50
50
|
this.compiler.emitAssets(compilation, err => {
|
51
51
|
if (err) return this._done(err);
|
52
52
|
if (this.invalid) return this._done();
|
53
|
-
|
54
53
|
this.compiler.emitRecords(err => {
|
55
54
|
if (err) return this._done(err);
|
56
55
|
|
@@ -95,7 +94,6 @@ class Watching {
|
|
95
94
|
this.handler(err, stats);
|
96
95
|
return;
|
97
96
|
}
|
98
|
-
|
99
97
|
this.compiler.hooks.done.callAsync(stats, () => {
|
100
98
|
this.handler(null, stats);
|
101
99
|
if (!this.closed) {
|
@@ -124,7 +122,8 @@ class Watching {
|
|
124
122
|
contextModified,
|
125
123
|
missingModified,
|
126
124
|
fileTimestamps,
|
127
|
-
contextTimestamps
|
125
|
+
contextTimestamps,
|
126
|
+
removedFiles
|
128
127
|
) => {
|
129
128
|
this.pausedWatcher = this.watcher;
|
130
129
|
this.watcher = null;
|
@@ -133,6 +132,7 @@ class Watching {
|
|
133
132
|
}
|
134
133
|
this.compiler.fileTimestamps = fileTimestamps;
|
135
134
|
this.compiler.contextTimestamps = contextTimestamps;
|
135
|
+
this.compiler.removedFiles = removedFiles;
|
136
136
|
this._invalidate();
|
137
137
|
},
|
138
138
|
(fileName, changeTime) => {
|
@@ -170,6 +170,7 @@ class Watching {
|
|
170
170
|
const finalCallback = () => {
|
171
171
|
this.compiler.hooks.watchClose.call();
|
172
172
|
this.compiler.running = false;
|
173
|
+
this.compiler.watchMode = false;
|
173
174
|
if (callback !== undefined) callback();
|
174
175
|
};
|
175
176
|
|
@@ -8,12 +8,14 @@ const DependencyReference = require("./DependencyReference");
|
|
8
8
|
const ModuleDependency = require("./ModuleDependency");
|
9
9
|
|
10
10
|
class WebAssemblyExportImportedDependency extends ModuleDependency {
|
11
|
-
constructor(exportName, request, name) {
|
11
|
+
constructor(exportName, request, name, valueType) {
|
12
12
|
super(request);
|
13
13
|
/** @type {string} */
|
14
14
|
this.exportName = exportName;
|
15
15
|
/** @type {string} */
|
16
16
|
this.name = name;
|
17
|
+
/** @type {string} */
|
18
|
+
this.valueType = valueType;
|
17
19
|
}
|
18
20
|
|
19
21
|
getReference() {
|
@@ -44,24 +44,34 @@ class NodeWatchFileSystem {
|
|
44
44
|
if (callbackUndelayed) {
|
45
45
|
this.watcher.once("change", callbackUndelayed);
|
46
46
|
}
|
47
|
-
|
47
|
+
const cachedFiles = files;
|
48
|
+
const cachedDirs = dirs;
|
48
49
|
this.watcher.once("aggregated", (changes, removals) => {
|
49
50
|
changes = changes.concat(removals);
|
50
51
|
if (this.inputFileSystem && this.inputFileSystem.purge) {
|
51
52
|
this.inputFileSystem.purge(changes);
|
52
53
|
}
|
53
54
|
const times = objectToMap(this.watcher.getTimes());
|
55
|
+
files = new Set(files);
|
56
|
+
dirs = new Set(dirs);
|
57
|
+
missing = new Set(missing);
|
58
|
+
removals = new Set(removals.filter(file => files.has(file)));
|
54
59
|
callback(
|
55
60
|
null,
|
56
|
-
changes.filter(file => files.
|
57
|
-
changes.filter(file => dirs.
|
58
|
-
changes.filter(file => missing.
|
61
|
+
changes.filter(file => files.has(file)).sort(),
|
62
|
+
changes.filter(file => dirs.has(file)).sort(),
|
63
|
+
changes.filter(file => missing.has(file)).sort(),
|
64
|
+
times,
|
59
65
|
times,
|
60
|
-
|
66
|
+
removals
|
61
67
|
);
|
62
68
|
});
|
63
69
|
|
64
|
-
this.watcher.watch(
|
70
|
+
this.watcher.watch(
|
71
|
+
cachedFiles.concat(missing),
|
72
|
+
cachedDirs.concat(missing),
|
73
|
+
startTime
|
74
|
+
);
|
65
75
|
|
66
76
|
if (oldWatcher) {
|
67
77
|
oldWatcher.close();
|
@@ -30,11 +30,13 @@ class LimitChunkCountPlugin {
|
|
30
30
|
if (maxChunks < 1) return;
|
31
31
|
if (chunks.length <= maxChunks) return;
|
32
32
|
|
33
|
-
const
|
33
|
+
const orderedChunks = chunks.slice().sort((a, b) => a.compareTo(b));
|
34
|
+
|
35
|
+
const sortedExtendedPairCombinations = orderedChunks
|
34
36
|
.reduce((combinations, a, idx) => {
|
35
37
|
// create combination pairs
|
36
38
|
for (let i = 0; i < idx; i++) {
|
37
|
-
const b =
|
39
|
+
const b = orderedChunks[i];
|
38
40
|
combinations.push([b, a]);
|
39
41
|
}
|
40
42
|
return combinations;
|
@@ -54,9 +56,13 @@ class LimitChunkCountPlugin {
|
|
54
56
|
.sort((a, b) => {
|
55
57
|
// sadly javascript does an inplace sort here
|
56
58
|
// sort them by size
|
57
|
-
const
|
58
|
-
if (
|
59
|
-
|
59
|
+
const diff1 = b[0] - a[0];
|
60
|
+
if (diff1 !== 0) return diff1;
|
61
|
+
const diff2 = a[1] - b[1];
|
62
|
+
if (diff2 !== 0) return diff2;
|
63
|
+
const diff3 = a[2].compareTo(b[2]);
|
64
|
+
if (diff3 !== 0) return diff3;
|
65
|
+
return a[3].compareTo(b[3]);
|
60
66
|
});
|
61
67
|
|
62
68
|
const pair = sortedExtendedPairCombinations[0];
|
@@ -46,7 +46,11 @@ class OccurrenceOrderModuleIdsPlugin {
|
|
46
46
|
if (!r.module) {
|
47
47
|
return sum;
|
48
48
|
}
|
49
|
-
|
49
|
+
const count = initialChunkChunkMap.get(r.module);
|
50
|
+
if (!count) {
|
51
|
+
return sum;
|
52
|
+
}
|
53
|
+
return sum + count;
|
50
54
|
};
|
51
55
|
const countOccurs = (sum, r) => {
|
52
56
|
if (!r.module) {
|
@@ -78,10 +78,11 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
78
78
|
importData.names.add(dep.name);
|
79
79
|
const usedName = module.isUsed(dep.exportName);
|
80
80
|
if (usedName) {
|
81
|
+
const exportProp = `${module.exportsArgument}[${JSON.stringify(
|
82
|
+
usedName
|
83
|
+
)}]`;
|
81
84
|
const defineStatement = Template.asString([
|
82
|
-
`${
|
83
|
-
usedName
|
84
|
-
)}] = ${runtimeTemplate.exportFromImport({
|
85
|
+
`${exportProp} = ${runtimeTemplate.exportFromImport({
|
85
86
|
module: dep.module,
|
86
87
|
request: dep.request,
|
87
88
|
importVar: importData.importVar,
|
@@ -90,7 +91,11 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
90
91
|
asiSafe: true,
|
91
92
|
isCall: false,
|
92
93
|
callContext: null
|
93
|
-
})}
|
94
|
+
})};`,
|
95
|
+
`if(WebAssembly.Global) ${exportProp} = ` +
|
96
|
+
`new WebAssembly.Global({ value: ${JSON.stringify(
|
97
|
+
dep.valueType
|
98
|
+
)} }, ${exportProp});`
|
94
99
|
]);
|
95
100
|
importData.reexports.push(defineStatement);
|
96
101
|
needExportsCopy = true;
|
@@ -16,7 +16,7 @@ module.exports = function() {
|
|
16
16
|
var script = document.createElement("script");
|
17
17
|
script.charset = "utf-8";
|
18
18
|
script.src = $require$.p + $hotChunkFilename$;
|
19
|
-
$crossOriginLoading$;
|
19
|
+
if ($crossOriginLoading$) script.crossOrigin = $crossOriginLoading$;
|
20
20
|
head.appendChild(script);
|
21
21
|
}
|
22
22
|
|
@@ -562,9 +562,7 @@ class JsonpMainTemplatePlugin {
|
|
562
562
|
.replace(/\$require\$/g, mainTemplate.requireFn)
|
563
563
|
.replace(
|
564
564
|
/\$crossOriginLoading\$/g,
|
565
|
-
crossOriginLoading
|
566
|
-
? `script.crossOrigin = ${JSON.stringify(crossOriginLoading)}`
|
567
|
-
: ""
|
565
|
+
crossOriginLoading ? JSON.stringify(crossOriginLoading) : "null"
|
568
566
|
)
|
569
567
|
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
|
570
568
|
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
|
package/package.json
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.23.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
|
"license": "MIT",
|
7
7
|
"dependencies": {
|
8
|
-
"@webassemblyjs/ast": "1.7.
|
9
|
-
"@webassemblyjs/helper-module-context": "1.7.
|
10
|
-
"@webassemblyjs/wasm-edit": "1.7.
|
11
|
-
"@webassemblyjs/wasm-parser": "1.7.
|
8
|
+
"@webassemblyjs/ast": "1.7.10",
|
9
|
+
"@webassemblyjs/helper-module-context": "1.7.10",
|
10
|
+
"@webassemblyjs/wasm-edit": "1.7.10",
|
11
|
+
"@webassemblyjs/wasm-parser": "1.7.10",
|
12
12
|
"acorn": "^5.6.2",
|
13
13
|
"acorn-dynamic-import": "^3.0.0",
|
14
14
|
"ajv": "^6.1.0",
|
@@ -39,7 +39,7 @@
|
|
39
39
|
"codacy-coverage": "^2.0.1",
|
40
40
|
"coffee-loader": "^0.9.0",
|
41
41
|
"coffeescript": "^1.10.0",
|
42
|
-
"coveralls": "^
|
42
|
+
"coveralls": "^3.0.2",
|
43
43
|
"css-loader": "^0.28.3",
|
44
44
|
"es6-promise-polyfill": "^1.1.1",
|
45
45
|
"eslint": "^5.2.0",
|
@@ -55,8 +55,7 @@
|
|
55
55
|
"istanbul": "^0.4.5",
|
56
56
|
"jade": "^1.11.0",
|
57
57
|
"jade-loader": "~0.8.0",
|
58
|
-
"jest": "
|
59
|
-
"jest-silent-reporter": "^0.0.5",
|
58
|
+
"jest": "24.0.0-alpha.1",
|
60
59
|
"json-loader": "^0.5.7",
|
61
60
|
"json-schema-to-typescript": "^6.0.1",
|
62
61
|
"less": "^2.5.1",
|
@@ -97,6 +96,7 @@
|
|
97
96
|
"lib/",
|
98
97
|
"bin/",
|
99
98
|
"buildin/",
|
99
|
+
"declarations/",
|
100
100
|
"hot/",
|
101
101
|
"web_modules/",
|
102
102
|
"schemas/",
|
@@ -109,11 +109,11 @@
|
|
109
109
|
"test:integration": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\"",
|
110
110
|
"test:basic": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/{TestCasesNormal,StatsTestCases,ConfigTestCases}.test.js\"",
|
111
111
|
"test:unit": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\"",
|
112
|
-
"travis:integration": "yarn cover:init && yarn cover:integration
|
112
|
+
"travis:integration": "yarn cover:init && yarn cover:integration --ci $JEST",
|
113
113
|
"travis:basic": "yarn test:basic --ci $JEST",
|
114
114
|
"travis:lint-unit": "yarn lint && yarn cover:init && yarn cover:unit --ci $JEST",
|
115
115
|
"travis:benchmark": "yarn benchmark --ci",
|
116
|
-
"appveyor:integration": "yarn cover:init && yarn cover:integration
|
116
|
+
"appveyor:integration": "yarn cover:init && yarn cover:integration --ci %JEST%",
|
117
117
|
"appveyor:unit": "yarn cover:init && yarn cover:unit --ci %JEST%",
|
118
118
|
"appveyor:benchmark": "yarn benchmark --ci",
|
119
119
|
"build:examples": "cd examples && node buildAll.js",
|
@@ -125,7 +125,7 @@
|
|
125
125
|
"special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/compile-to-definitions",
|
126
126
|
"special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/compile-to-definitions --write",
|
127
127
|
"fix": "yarn code-lint --fix && yarn special-lint-fix",
|
128
|
-
"pretty": "prettier --loglevel warn --write \"*.{ts,js,json}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
|
128
|
+
"pretty": "prettier --loglevel warn --write \"*.{ts,js,json,yml,yaml}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
|
129
129
|
"schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
|
130
130
|
"benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
|
131
131
|
"cover": "yarn cover:init && yarn cover:all && yarn cover:report",
|
@@ -147,7 +147,9 @@
|
|
147
147
|
},
|
148
148
|
"jest": {
|
149
149
|
"forceExit": true,
|
150
|
-
"
|
150
|
+
"setupFilesAfterEnv": [
|
151
|
+
"<rootDir>/test/setupTestFramework.js"
|
152
|
+
],
|
151
153
|
"testMatch": [
|
152
154
|
"<rootDir>/test/*.test.js",
|
153
155
|
"<rootDir>/test/*.unittest.js"
|
@@ -1,55 +1,55 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
const errorMessage = (schema, data, message) => ({
|
4
|
-
keyword: "absolutePath",
|
5
|
-
params: { absolutePath: data },
|
6
|
-
message: message,
|
7
|
-
parentSchema: schema
|
8
|
-
});
|
9
|
-
|
10
|
-
const getErrorFor = (shouldBeAbsolute, data, schema) => {
|
11
|
-
const message = shouldBeAbsolute
|
12
|
-
? `The provided value ${JSON.stringify(data)} is not an absolute path!`
|
13
|
-
: `A relative path is expected. However, the provided value ${JSON.stringify(
|
14
|
-
data
|
15
|
-
)} is an absolute path!`;
|
16
|
-
|
17
|
-
return errorMessage(schema, data, message);
|
18
|
-
};
|
19
|
-
|
20
|
-
module.exports = ajv =>
|
21
|
-
ajv.addKeyword("absolutePath", {
|
22
|
-
errors: true,
|
23
|
-
type: "string",
|
24
|
-
compile(expected, schema) {
|
25
|
-
function callback(data) {
|
26
|
-
let passes = true;
|
27
|
-
const isExclamationMarkPresent = data.includes("!");
|
28
|
-
const isCorrectAbsoluteOrRelativePath =
|
29
|
-
expected === /^(?:[A-Za-z]:\\|\/)/.test(data);
|
30
|
-
|
31
|
-
if (isExclamationMarkPresent) {
|
32
|
-
callback.errors = [
|
33
|
-
errorMessage(
|
34
|
-
schema,
|
35
|
-
data,
|
36
|
-
`The provided value ${JSON.stringify(
|
37
|
-
data
|
38
|
-
)}
|
39
|
-
)
|
40
|
-
];
|
41
|
-
passes = false;
|
42
|
-
}
|
43
|
-
|
44
|
-
if (!isCorrectAbsoluteOrRelativePath) {
|
45
|
-
callback.errors = [getErrorFor(expected, data, schema)];
|
46
|
-
passes = false;
|
47
|
-
}
|
48
|
-
|
49
|
-
return passes;
|
50
|
-
}
|
51
|
-
callback.errors = [];
|
52
|
-
|
53
|
-
return callback;
|
54
|
-
}
|
55
|
-
});
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const errorMessage = (schema, data, message) => ({
|
4
|
+
keyword: "absolutePath",
|
5
|
+
params: { absolutePath: data },
|
6
|
+
message: message,
|
7
|
+
parentSchema: schema
|
8
|
+
});
|
9
|
+
|
10
|
+
const getErrorFor = (shouldBeAbsolute, data, schema) => {
|
11
|
+
const message = shouldBeAbsolute
|
12
|
+
? `The provided value ${JSON.stringify(data)} is not an absolute path!`
|
13
|
+
: `A relative path is expected. However, the provided value ${JSON.stringify(
|
14
|
+
data
|
15
|
+
)} is an absolute path!`;
|
16
|
+
|
17
|
+
return errorMessage(schema, data, message);
|
18
|
+
};
|
19
|
+
|
20
|
+
module.exports = ajv =>
|
21
|
+
ajv.addKeyword("absolutePath", {
|
22
|
+
errors: true,
|
23
|
+
type: "string",
|
24
|
+
compile(expected, schema) {
|
25
|
+
function callback(data) {
|
26
|
+
let passes = true;
|
27
|
+
const isExclamationMarkPresent = data.includes("!");
|
28
|
+
const isCorrectAbsoluteOrRelativePath =
|
29
|
+
expected === /^(?:[A-Za-z]:\\|\/)/.test(data);
|
30
|
+
|
31
|
+
if (isExclamationMarkPresent) {
|
32
|
+
callback.errors = [
|
33
|
+
errorMessage(
|
34
|
+
schema,
|
35
|
+
data,
|
36
|
+
`The provided value ${JSON.stringify(
|
37
|
+
data
|
38
|
+
)} contains exclamation mark (!) which is not allowed because it's reserved for loader syntax.`
|
39
|
+
)
|
40
|
+
];
|
41
|
+
passes = false;
|
42
|
+
}
|
43
|
+
|
44
|
+
if (!isCorrectAbsoluteOrRelativePath) {
|
45
|
+
callback.errors = [getErrorFor(expected, data, schema)];
|
46
|
+
passes = false;
|
47
|
+
}
|
48
|
+
|
49
|
+
return passes;
|
50
|
+
}
|
51
|
+
callback.errors = [];
|
52
|
+
|
53
|
+
return callback;
|
54
|
+
}
|
55
|
+
});
|