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.
Files changed (50) hide show
  1. package/LICENSE +20 -20
  2. package/SECURITY.md +9 -9
  3. package/buildin/amd-define.js +3 -3
  4. package/buildin/amd-options.js +2 -2
  5. package/buildin/global.js +20 -20
  6. package/buildin/module.js +22 -22
  7. package/buildin/system.js +7 -7
  8. package/declarations/WebpackOptions.d.ts +1388 -0
  9. package/declarations/plugins/BannerPlugin.d.ts +51 -0
  10. package/declarations/plugins/DllPlugin.d.ts +28 -0
  11. package/declarations/plugins/DllReferencePlugin.d.ts +126 -0
  12. package/declarations/plugins/HashedModuleIdsPlugin.d.ts +24 -0
  13. package/declarations/plugins/IgnorePlugin.d.ts +27 -0
  14. package/declarations/plugins/LoaderOptionsPlugin.d.ts +27 -0
  15. package/declarations/plugins/SourceMapDevToolPlugin.d.ts +94 -0
  16. package/declarations/plugins/WatchIgnorePlugin.d.ts +10 -0
  17. package/declarations/plugins/debug/ProfilingPlugin.d.ts +12 -0
  18. package/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts +24 -0
  19. package/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts +16 -0
  20. package/declarations/plugins/optimize/MinChunkSizePlugin.d.ts +12 -0
  21. package/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts +12 -0
  22. package/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts +12 -0
  23. package/hot/emitter.js +2 -2
  24. package/lib/AmdMainTemplatePlugin.js +22 -5
  25. package/lib/BasicEvaluatedExpression.js +211 -211
  26. package/lib/Chunk.js +33 -14
  27. package/lib/Compilation.js +99 -52
  28. package/lib/Compiler.js +6 -1
  29. package/lib/ConstPlugin.js +85 -0
  30. package/lib/Entrypoint.js +10 -0
  31. package/lib/ExternalModule.js +3 -2
  32. package/lib/LibraryTemplatePlugin.js +11 -8
  33. package/lib/MainTemplate.js +13 -0
  34. package/lib/Parser.js +9 -1
  35. package/lib/Stats.js +44 -45
  36. package/lib/WatchIgnorePlugin.js +4 -3
  37. package/lib/Watching.js +4 -3
  38. package/lib/dependencies/WebAssemblyExportImportedDependency.js +3 -1
  39. package/lib/node/NodeWatchFileSystem.js +16 -6
  40. package/lib/optimize/LimitChunkCountPlugin.js +11 -5
  41. package/lib/optimize/OccurrenceModuleOrderPlugin.js +5 -1
  42. package/lib/wasm/WasmFinalizeExportsPlugin.js +2 -0
  43. package/lib/wasm/WebAssemblyJavascriptGenerator.js +9 -4
  44. package/lib/wasm/WebAssemblyParser.js +2 -1
  45. package/lib/web/JsonpMainTemplate.runtime.js +1 -1
  46. package/lib/web/JsonpMainTemplatePlugin.js +1 -3
  47. package/package.json +14 -12
  48. package/schemas/WebpackOptions.json +1 -0
  49. package/schemas/ajv.absolutePath.js +55 -55
  50. 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.includes(file)).sort(),
57
- changes.filter(file => dirs.includes(file)).sort(),
58
- changes.filter(file => missing.includes(file)).sort(),
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
- times
66
+ removals
61
67
  );
62
68
  });
63
69
 
64
- this.watcher.watch(files.concat(missing), dirs.concat(missing), startTime);
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 sortedExtendedPairCombinations = chunks
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 = chunks[i];
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 diff = b[0] - a[0];
58
- if (diff !== 0) return diff;
59
- return a[1] - b[1];
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
- return sum + initialChunkChunkMap.get(r.module);
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) {
@@ -30,6 +30,8 @@ class WasmFinalizeExportsPlugin {
30
30
  reason.dependency
31
31
  );
32
32
 
33
+ if (!ref) continue;
34
+
33
35
  const importedNames = ref.importedNames;
34
36
 
35
37
  if (Array.isArray(importedNames)) {
@@ -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
- `${module.exportsArgument}[${JSON.stringify(
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;
@@ -108,7 +108,8 @@ class WebAssemblyParser extends Tapable {
108
108
  const dep = new WebAssemblyExportImportedDependency(
109
109
  node.name,
110
110
  refNode.module,
111
- refNode.name
111
+ refNode.name,
112
+ refNode.descr.valtype
112
113
  );
113
114
 
114
115
  state.module.addDependency(dep);
@@ -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.20.2",
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.8",
9
- "@webassemblyjs/helper-module-context": "1.7.8",
10
- "@webassemblyjs/wasm-edit": "1.7.8",
11
- "@webassemblyjs/wasm-parser": "1.7.8",
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": "^2.11.2",
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": "^23.4.1",
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 \"test/(?!TestCases)\" --ci $JEST && mv coverage/coverage-final.json coverage/coverage-final-1.json && yarn cover:integration \"test/TestCasesD\" --ci $JEST && mv coverage/coverage-final.json coverage/coverage-final-2.json && yarn cover:integration \"test/TestCases(?!D)\" --ci $JEST && mv coverage/coverage-final.json coverage/coverage-final-3.json",
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 \"test/(?!TestCases)\" --ci %JEST% && move coverage\\coverage-final.json coverage\\coverage-final-1.json&& yarn cover:integration \"test/TestCasesD\" --ci %JEST% && move coverage\\coverage-final.json coverage\\coverage-final-2.json && yarn cover:integration \"test/TestCases(?!D)\" --ci %JEST% && move coverage\\coverage-final.json coverage\\coverage-final-3.json",
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
- "setupTestFrameworkScriptFile": "<rootDir>/test/setupTestFramework.js",
150
+ "setupFilesAfterEnv": [
151
+ "<rootDir>/test/setupTestFramework.js"
152
+ ],
151
153
  "testMatch": [
152
154
  "<rootDir>/test/*.test.js",
153
155
  "<rootDir>/test/*.unittest.js"
@@ -979,6 +979,7 @@
979
979
  "commonjs2",
980
980
  "commonjs-module",
981
981
  "amd",
982
+ "amd-require",
982
983
  "umd",
983
984
  "umd2",
984
985
  "jsonp"
@@ -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
- )} contans 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
- });
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
+ });
@@ -88,6 +88,7 @@
88
88
  "commonjs2",
89
89
  "commonjs-module",
90
90
  "amd",
91
+ "amd-require",
91
92
  "umd",
92
93
  "umd2",
93
94
  "jsonp"