webpack 4.18.1 → 4.19.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/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright JS Foundation and other contributors
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- 'Software'), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright JS Foundation and other contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -221,7 +221,7 @@ or are automatically applied via regex from your webpack configuration.
221
221
  |<a href="https://github.com/webpack/style-loader">`<style>`</a>|![style-npm]|![style-size]|Add exports of a module as style to DOM|
222
222
  |<a href="https://github.com/webpack/css-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/css-3.svg"></a>|![css-npm]|![css-size]|Loads CSS file with resolved imports and returns CSS code|
223
223
  |<a href="https://github.com/webpack/less-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/less-63.svg"></a>|![less-npm]|![less-size]|Loads and compiles a LESS file|
224
- |<a href="https://github.com/jtangelder/sass-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/sass-1.svg"></a>|![sass-npm]|![sass-size]|Loads and compiles a SASS/SCSS file|
224
+ |<a href="https://github.com/jtangelder/sass-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/sass-1.svg"></a>|![sass-npm]|![sass-size]|Loads and compiles a Sass/SCSS file|
225
225
  |<a href="https://github.com/shama/stylus-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/stylus.svg"></a>|![stylus-npm]|![stylus-size]|Loads and compiles a Stylus file|
226
226
  |<a href="https://github.com/postcss/postcss-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/postcss.svg"></a>|![postcss-npm]|![postcss-size]|Loads and transforms a CSS/SSS file using [PostCSS](http://postcss.org)|
227
227
 
package/SECURITY.md CHANGED
@@ -1,9 +1,9 @@
1
- # Reporting Security Issues
2
-
3
- If you discover a security issue in webpack, please report it by sending an
4
- email to [webpack@opencollective.com](mailto:webpack@opencollective.com).
5
-
6
- This will allow us to assess the risk, and make a fix available before we add a
7
- bug report to the GitHub repository.
8
-
9
- Thanks for helping make webpack safe for everyone.
1
+ # Reporting Security Issues
2
+
3
+ If you discover a security issue in webpack, please report it by sending an
4
+ email to [webpack@opencollective.com](mailto:webpack@opencollective.com).
5
+
6
+ This will allow us to assess the risk, and make a fix available before we add a
7
+ bug report to the GitHub repository.
8
+
9
+ Thanks for helping make webpack safe for everyone.
@@ -1,3 +1,3 @@
1
- module.exports = function() {
2
- throw new Error("define cannot be used indirect");
3
- };
1
+ module.exports = function() {
2
+ throw new Error("define cannot be used indirect");
3
+ };
@@ -1,2 +1,2 @@
1
- /* globals __webpack_amd_options__ */
2
- module.exports = __webpack_amd_options__;
1
+ /* globals __webpack_amd_options__ */
2
+ module.exports = __webpack_amd_options__;
package/buildin/global.js CHANGED
@@ -1,20 +1,20 @@
1
- var g;
2
-
3
- // This works in non-strict mode
4
- g = (function() {
5
- return this;
6
- })();
7
-
8
- try {
9
- // This works if eval is allowed (see CSP)
10
- g = g || Function("return this")() || (1, eval)("this");
11
- } catch (e) {
12
- // This works if the window reference is available
13
- if (typeof window === "object") g = window;
14
- }
15
-
16
- // g can still be undefined, but nothing to do about it...
17
- // We return undefined, instead of nothing here, so it's
18
- // easier to handle this case. if(!global) { ...}
19
-
20
- module.exports = g;
1
+ var g;
2
+
3
+ // This works in non-strict mode
4
+ g = (function() {
5
+ return this;
6
+ })();
7
+
8
+ try {
9
+ // This works if eval is allowed (see CSP)
10
+ g = g || Function("return this")() || (1, eval)("this");
11
+ } catch (e) {
12
+ // This works if the window reference is available
13
+ if (typeof window === "object") g = window;
14
+ }
15
+
16
+ // g can still be undefined, but nothing to do about it...
17
+ // We return undefined, instead of nothing here, so it's
18
+ // easier to handle this case. if(!global) { ...}
19
+
20
+ module.exports = g;
package/buildin/module.js CHANGED
@@ -1,22 +1,22 @@
1
- module.exports = function(module) {
2
- if (!module.webpackPolyfill) {
3
- module.deprecate = function() {};
4
- module.paths = [];
5
- // module.parent = undefined by default
6
- if (!module.children) module.children = [];
7
- Object.defineProperty(module, "loaded", {
8
- enumerable: true,
9
- get: function() {
10
- return module.l;
11
- }
12
- });
13
- Object.defineProperty(module, "id", {
14
- enumerable: true,
15
- get: function() {
16
- return module.i;
17
- }
18
- });
19
- module.webpackPolyfill = 1;
20
- }
21
- return module;
22
- };
1
+ module.exports = function(module) {
2
+ if (!module.webpackPolyfill) {
3
+ module.deprecate = function() {};
4
+ module.paths = [];
5
+ // module.parent = undefined by default
6
+ if (!module.children) module.children = [];
7
+ Object.defineProperty(module, "loaded", {
8
+ enumerable: true,
9
+ get: function() {
10
+ return module.l;
11
+ }
12
+ });
13
+ Object.defineProperty(module, "id", {
14
+ enumerable: true,
15
+ get: function() {
16
+ return module.i;
17
+ }
18
+ });
19
+ module.webpackPolyfill = 1;
20
+ }
21
+ return module;
22
+ };
package/buildin/system.js CHANGED
@@ -1,7 +1,7 @@
1
- // Provide a "System" global.
2
- module.exports = {
3
- // Make sure import is only used as "System.import"
4
- import: function() {
5
- throw new Error("System.import cannot be used indirectly");
6
- }
7
- };
1
+ // Provide a "System" global.
2
+ module.exports = {
3
+ // Make sure import is only used as "System.import"
4
+ import: function() {
5
+ throw new Error("System.import cannot be used indirectly");
6
+ }
7
+ };
package/hot/emitter.js CHANGED
@@ -1,2 +1,2 @@
1
- var EventEmitter = require("events");
2
- module.exports = new EventEmitter();
1
+ var EventEmitter = require("events");
2
+ module.exports = new EventEmitter();
@@ -1,211 +1,211 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
-
6
- "use strict";
7
-
8
- const TypeUnknown = 0;
9
- const TypeNull = 1;
10
- const TypeString = 2;
11
- const TypeNumber = 3;
12
- const TypeBoolean = 4;
13
- const TypeRegExp = 5;
14
- const TypeConditional = 6;
15
- const TypeArray = 7;
16
- const TypeConstArray = 8;
17
- const TypeIdentifier = 9;
18
- const TypeWrapped = 10;
19
- const TypeTemplateString = 11;
20
-
21
- class BasicEvaluatedExpression {
22
- constructor() {
23
- this.type = TypeUnknown;
24
- this.range = null;
25
- this.falsy = false;
26
- this.truthy = false;
27
- this.bool = null;
28
- this.number = null;
29
- this.regExp = null;
30
- this.string = null;
31
- this.quasis = null;
32
- this.array = null;
33
- this.items = null;
34
- this.options = null;
35
- this.prefix = null;
36
- this.postfix = null;
37
- }
38
-
39
- isNull() {
40
- return this.type === TypeNull;
41
- }
42
-
43
- isString() {
44
- return this.type === TypeString;
45
- }
46
-
47
- isNumber() {
48
- return this.type === TypeNumber;
49
- }
50
-
51
- isBoolean() {
52
- return this.type === TypeBoolean;
53
- }
54
-
55
- isRegExp() {
56
- return this.type === TypeRegExp;
57
- }
58
-
59
- isConditional() {
60
- return this.type === TypeConditional;
61
- }
62
-
63
- isArray() {
64
- return this.type === TypeArray;
65
- }
66
-
67
- isConstArray() {
68
- return this.type === TypeConstArray;
69
- }
70
-
71
- isIdentifier() {
72
- return this.type === TypeIdentifier;
73
- }
74
-
75
- isWrapped() {
76
- return this.type === TypeWrapped;
77
- }
78
-
79
- isTemplateString() {
80
- return this.type === TypeTemplateString;
81
- }
82
-
83
- isTruthy() {
84
- return this.truthy;
85
- }
86
-
87
- isFalsy() {
88
- return this.falsy;
89
- }
90
-
91
- asBool() {
92
- if (this.truthy) return true;
93
- if (this.falsy) return false;
94
- if (this.isBoolean()) return this.bool;
95
- if (this.isNull()) return false;
96
- if (this.isString()) return this.string !== "";
97
- if (this.isNumber()) return this.number !== 0;
98
- if (this.isRegExp()) return true;
99
- if (this.isArray()) return true;
100
- if (this.isConstArray()) return true;
101
- if (this.isWrapped()) {
102
- return (this.prefix && this.prefix.asBool()) ||
103
- (this.postfix && this.postfix.asBool())
104
- ? true
105
- : undefined;
106
- }
107
- if (this.isTemplateString()) {
108
- for (const quasi of this.quasis) {
109
- if (quasi.asBool()) return true;
110
- }
111
- // can't tell if string will be empty without executing
112
- }
113
- return undefined;
114
- }
115
-
116
- setString(string) {
117
- this.type = TypeString;
118
- this.string = string;
119
- return this;
120
- }
121
-
122
- setNull() {
123
- this.type = TypeNull;
124
- return this;
125
- }
126
-
127
- setNumber(number) {
128
- this.type = TypeNumber;
129
- this.number = number;
130
- return this;
131
- }
132
-
133
- setBoolean(bool) {
134
- this.type = TypeBoolean;
135
- this.bool = bool;
136
- return this;
137
- }
138
-
139
- setRegExp(regExp) {
140
- this.type = TypeRegExp;
141
- this.regExp = regExp;
142
- return this;
143
- }
144
-
145
- setIdentifier(identifier) {
146
- this.type = TypeIdentifier;
147
- this.identifier = identifier;
148
- return this;
149
- }
150
-
151
- setWrapped(prefix, postfix) {
152
- this.type = TypeWrapped;
153
- this.prefix = prefix;
154
- this.postfix = postfix;
155
- return this;
156
- }
157
-
158
- setOptions(options) {
159
- this.type = TypeConditional;
160
- this.options = options;
161
- return this;
162
- }
163
-
164
- addOptions(options) {
165
- if (!this.options) {
166
- this.type = TypeConditional;
167
- this.options = [];
168
- }
169
- for (const item of options) {
170
- this.options.push(item);
171
- }
172
- return this;
173
- }
174
-
175
- setItems(items) {
176
- this.type = TypeArray;
177
- this.items = items;
178
- return this;
179
- }
180
-
181
- setArray(array) {
182
- this.type = TypeConstArray;
183
- this.array = array;
184
- return this;
185
- }
186
-
187
- setTemplateString(quasis) {
188
- this.type = TypeTemplateString;
189
- this.quasis = quasis;
190
- return this;
191
- }
192
-
193
- setTruthy() {
194
- this.falsy = false;
195
- this.truthy = true;
196
- return this;
197
- }
198
-
199
- setFalsy() {
200
- this.falsy = true;
201
- this.truthy = false;
202
- return this;
203
- }
204
-
205
- setRange(range) {
206
- this.range = range;
207
- return this;
208
- }
209
- }
210
-
211
- module.exports = BasicEvaluatedExpression;
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const TypeUnknown = 0;
9
+ const TypeNull = 1;
10
+ const TypeString = 2;
11
+ const TypeNumber = 3;
12
+ const TypeBoolean = 4;
13
+ const TypeRegExp = 5;
14
+ const TypeConditional = 6;
15
+ const TypeArray = 7;
16
+ const TypeConstArray = 8;
17
+ const TypeIdentifier = 9;
18
+ const TypeWrapped = 10;
19
+ const TypeTemplateString = 11;
20
+
21
+ class BasicEvaluatedExpression {
22
+ constructor() {
23
+ this.type = TypeUnknown;
24
+ this.range = null;
25
+ this.falsy = false;
26
+ this.truthy = false;
27
+ this.bool = null;
28
+ this.number = null;
29
+ this.regExp = null;
30
+ this.string = null;
31
+ this.quasis = null;
32
+ this.array = null;
33
+ this.items = null;
34
+ this.options = null;
35
+ this.prefix = null;
36
+ this.postfix = null;
37
+ }
38
+
39
+ isNull() {
40
+ return this.type === TypeNull;
41
+ }
42
+
43
+ isString() {
44
+ return this.type === TypeString;
45
+ }
46
+
47
+ isNumber() {
48
+ return this.type === TypeNumber;
49
+ }
50
+
51
+ isBoolean() {
52
+ return this.type === TypeBoolean;
53
+ }
54
+
55
+ isRegExp() {
56
+ return this.type === TypeRegExp;
57
+ }
58
+
59
+ isConditional() {
60
+ return this.type === TypeConditional;
61
+ }
62
+
63
+ isArray() {
64
+ return this.type === TypeArray;
65
+ }
66
+
67
+ isConstArray() {
68
+ return this.type === TypeConstArray;
69
+ }
70
+
71
+ isIdentifier() {
72
+ return this.type === TypeIdentifier;
73
+ }
74
+
75
+ isWrapped() {
76
+ return this.type === TypeWrapped;
77
+ }
78
+
79
+ isTemplateString() {
80
+ return this.type === TypeTemplateString;
81
+ }
82
+
83
+ isTruthy() {
84
+ return this.truthy;
85
+ }
86
+
87
+ isFalsy() {
88
+ return this.falsy;
89
+ }
90
+
91
+ asBool() {
92
+ if (this.truthy) return true;
93
+ if (this.falsy) return false;
94
+ if (this.isBoolean()) return this.bool;
95
+ if (this.isNull()) return false;
96
+ if (this.isString()) return this.string !== "";
97
+ if (this.isNumber()) return this.number !== 0;
98
+ if (this.isRegExp()) return true;
99
+ if (this.isArray()) return true;
100
+ if (this.isConstArray()) return true;
101
+ if (this.isWrapped()) {
102
+ return (this.prefix && this.prefix.asBool()) ||
103
+ (this.postfix && this.postfix.asBool())
104
+ ? true
105
+ : undefined;
106
+ }
107
+ if (this.isTemplateString()) {
108
+ for (const quasi of this.quasis) {
109
+ if (quasi.asBool()) return true;
110
+ }
111
+ // can't tell if string will be empty without executing
112
+ }
113
+ return undefined;
114
+ }
115
+
116
+ setString(string) {
117
+ this.type = TypeString;
118
+ this.string = string;
119
+ return this;
120
+ }
121
+
122
+ setNull() {
123
+ this.type = TypeNull;
124
+ return this;
125
+ }
126
+
127
+ setNumber(number) {
128
+ this.type = TypeNumber;
129
+ this.number = number;
130
+ return this;
131
+ }
132
+
133
+ setBoolean(bool) {
134
+ this.type = TypeBoolean;
135
+ this.bool = bool;
136
+ return this;
137
+ }
138
+
139
+ setRegExp(regExp) {
140
+ this.type = TypeRegExp;
141
+ this.regExp = regExp;
142
+ return this;
143
+ }
144
+
145
+ setIdentifier(identifier) {
146
+ this.type = TypeIdentifier;
147
+ this.identifier = identifier;
148
+ return this;
149
+ }
150
+
151
+ setWrapped(prefix, postfix) {
152
+ this.type = TypeWrapped;
153
+ this.prefix = prefix;
154
+ this.postfix = postfix;
155
+ return this;
156
+ }
157
+
158
+ setOptions(options) {
159
+ this.type = TypeConditional;
160
+ this.options = options;
161
+ return this;
162
+ }
163
+
164
+ addOptions(options) {
165
+ if (!this.options) {
166
+ this.type = TypeConditional;
167
+ this.options = [];
168
+ }
169
+ for (const item of options) {
170
+ this.options.push(item);
171
+ }
172
+ return this;
173
+ }
174
+
175
+ setItems(items) {
176
+ this.type = TypeArray;
177
+ this.items = items;
178
+ return this;
179
+ }
180
+
181
+ setArray(array) {
182
+ this.type = TypeConstArray;
183
+ this.array = array;
184
+ return this;
185
+ }
186
+
187
+ setTemplateString(quasis) {
188
+ this.type = TypeTemplateString;
189
+ this.quasis = quasis;
190
+ return this;
191
+ }
192
+
193
+ setTruthy() {
194
+ this.falsy = false;
195
+ this.truthy = true;
196
+ return this;
197
+ }
198
+
199
+ setFalsy() {
200
+ this.falsy = true;
201
+ this.truthy = false;
202
+ return this;
203
+ }
204
+
205
+ setRange(range) {
206
+ this.range = range;
207
+ return this;
208
+ }
209
+ }
210
+
211
+ module.exports = BasicEvaluatedExpression;
@@ -9,6 +9,7 @@ const { Tapable, SyncWaterfallHook, SyncHook } = require("tapable");
9
9
  /** @typedef {import("./ModuleTemplate")} ModuleTemplate */
10
10
  /** @typedef {import("./Chunk")} Chunk */
11
11
  /** @typedef {import("./Module")} Module} */
12
+ /** @typedef {import("./Dependency").DependencyTemplate} DependencyTemplate} */
12
13
  /** @typedef {import("./util/createHash").Hash} Hash} */
13
14
 
14
15
  /**
@@ -71,12 +72,15 @@ module.exports = class ChunkTemplate extends Tapable {
71
72
  }
72
73
 
73
74
  /**
75
+ * TODO webpack 5: remove moduleTemplate and dependencyTemplates
74
76
  * Updates hash with chunk-specific information from this template
75
77
  * @param {Hash} hash the hash to update
76
78
  * @param {Chunk} chunk the chunk
79
+ * @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render
80
+ * @param {Map<Function, DependencyTemplate>} dependencyTemplates dependency templates
77
81
  * @returns {void}
78
82
  */
79
- updateHashForChunk(hash, chunk) {
83
+ updateHashForChunk(hash, chunk, moduleTemplate, dependencyTemplates) {
80
84
  this.updateHash(hash);
81
85
  this.hooks.hashForChunk.call(hash, chunk);
82
86
  }
@@ -455,9 +455,10 @@ class Compilation extends Tapable {
455
455
  this.children = [];
456
456
  /** @type {Map<DepConstructor, ModuleFactory>} */
457
457
  this.dependencyFactories = new Map();
458
- /** @type {Map<DepConstructor|string, DependencyTemplate|string>} */
458
+ /** @type {Map<DepConstructor, DependencyTemplate>} */
459
459
  this.dependencyTemplates = new Map();
460
460
  // TODO refactor this in webpack 5 to a custom DependencyTemplates class with a hash property
461
+ // @ts-ignore
461
462
  this.dependencyTemplates.set("hash", "");
462
463
  this.childrenCounters = {};
463
464
  /** @type {Set<number|string>} */
@@ -2259,7 +2260,12 @@ class Compilation extends Tapable {
2259
2260
  const template = chunk.hasRuntime()
2260
2261
  ? this.mainTemplate
2261
2262
  : this.chunkTemplate;
2262
- template.updateHashForChunk(chunkHash, chunk);
2263
+ template.updateHashForChunk(
2264
+ chunkHash,
2265
+ chunk,
2266
+ this.moduleTemplates.javascript,
2267
+ this.dependencyTemplates
2268
+ );
2263
2269
  this.hooks.chunkHash.call(chunk, chunkHash);
2264
2270
  chunk.hash = chunkHash.digest(hashDigest);
2265
2271
  hash.update(chunk.hash);
@@ -137,7 +137,12 @@ class JavascriptModulesPlugin {
137
137
  : compilation.chunkTemplate;
138
138
  hash.update(`${chunk.id} `);
139
139
  hash.update(chunk.ids ? chunk.ids.join(",") : "");
140
- template.updateHashForChunk(hash, chunk);
140
+ template.updateHashForChunk(
141
+ hash,
142
+ chunk,
143
+ compilation.moduleTemplates.javascript,
144
+ compilation.dependencyTemplates
145
+ );
141
146
  for (const m of chunk.modulesIterable) {
142
147
  if (typeof m.source === "function") {
143
148
  hash.update(m.hash);
@@ -361,14 +361,14 @@ module.exports = class MainTemplate extends Tapable {
361
361
  }
362
362
 
363
363
  /**
364
- *
364
+ * TODO webpack 5: remove moduleTemplate and dependencyTemplates
365
365
  * @param {string} hash hash to be used for render call
366
366
  * @param {Chunk} chunk Chunk instance
367
367
  * @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render
368
368
  * @param {Map<Function, DependencyTemplate>} dependencyTemplates dependency templates
369
- * @returns {ConcatSource} the newly generated source from rendering
369
+ * @returns {string[]} the generated source of the bootstrap code
370
370
  */
371
- render(hash, chunk, moduleTemplate, dependencyTemplates) {
371
+ renderBootstrap(hash, chunk, moduleTemplate, dependencyTemplates) {
372
372
  const buf = [];
373
373
  buf.push(
374
374
  this.hooks.bootstrap.call(
@@ -392,6 +392,23 @@ module.exports = class MainTemplate extends Tapable {
392
392
  buf.push("");
393
393
  buf.push(Template.asString(this.hooks.beforeStartup.call("", chunk, hash)));
394
394
  buf.push(Template.asString(this.hooks.startup.call("", chunk, hash)));
395
+ return buf;
396
+ }
397
+
398
+ /**
399
+ * @param {string} hash hash to be used for render call
400
+ * @param {Chunk} chunk Chunk instance
401
+ * @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render
402
+ * @param {Map<Function, DependencyTemplate>} dependencyTemplates dependency templates
403
+ * @returns {ConcatSource} the newly generated source from rendering
404
+ */
405
+ render(hash, chunk, moduleTemplate, dependencyTemplates) {
406
+ const buf = this.renderBootstrap(
407
+ hash,
408
+ chunk,
409
+ moduleTemplate,
410
+ dependencyTemplates
411
+ );
395
412
  let source = this.hooks.render.call(
396
413
  new OriginalSource(
397
414
  Template.prefix(buf, " \t") + "\n",
@@ -486,19 +503,29 @@ module.exports = class MainTemplate extends Tapable {
486
503
  updateHash(hash) {
487
504
  hash.update("maintemplate");
488
505
  hash.update("3");
489
- hash.update(this.outputOptions.publicPath + "");
490
506
  this.hooks.hash.call(hash);
491
507
  }
492
508
 
493
509
  /**
510
+ * TODO webpack 5: remove moduleTemplate and dependencyTemplates
494
511
  * Updates hash with chunk-specific information from this template
495
512
  * @param {Hash} hash the hash to update
496
513
  * @param {Chunk} chunk the chunk
514
+ * @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render
515
+ * @param {Map<Function, DependencyTemplate>} dependencyTemplates dependency templates
497
516
  * @returns {void}
498
517
  */
499
- updateHashForChunk(hash, chunk) {
518
+ updateHashForChunk(hash, chunk, moduleTemplate, dependencyTemplates) {
500
519
  this.updateHash(hash);
501
520
  this.hooks.hashForChunk.call(hash, chunk);
521
+ for (const line of this.renderBootstrap(
522
+ "0000",
523
+ chunk,
524
+ moduleTemplate,
525
+ dependencyTemplates
526
+ )) {
527
+ hash.update(line);
528
+ }
502
529
  }
503
530
 
504
531
  useChunkHash(chunk) {
@@ -315,9 +315,7 @@ module.exports = class NodeMainTemplatePlugin {
315
315
  );
316
316
  mainTemplate.hooks.hash.tap("NodeMainTemplatePlugin", hash => {
317
317
  hash.update("node");
318
- hash.update("3");
319
- hash.update(mainTemplate.outputOptions.filename + "");
320
- hash.update(mainTemplate.outputOptions.chunkFilename + "");
318
+ hash.update("4");
321
319
  });
322
320
  }
323
321
  };
@@ -335,23 +335,8 @@ class WasmMainTemplatePlugin {
335
335
  );
336
336
  mainTemplate.hooks.hash.tap("WasmMainTemplatePlugin", hash => {
337
337
  hash.update("WasmMainTemplatePlugin");
338
- hash.update("1");
339
- hash.update(`${mainTemplate.outputOptions.webassemblyModuleFilename}`);
340
- hash.update(`${this.mangleImports}`);
338
+ hash.update("2");
341
339
  });
342
- mainTemplate.hooks.hashForChunk.tap(
343
- "WasmMainTemplatePlugin",
344
- (hash, chunk) => {
345
- const chunkModuleMaps = chunk.getChunkModuleMaps(m =>
346
- m.type.startsWith("webassembly")
347
- );
348
- hash.update(JSON.stringify(chunkModuleMaps.id));
349
- const wasmModules = getAllWasmModules(chunk);
350
- for (const module of wasmModules) {
351
- hash.update(module.hash);
352
- }
353
- }
354
- );
355
340
  }
356
341
  }
357
342
 
@@ -581,11 +581,7 @@ ${globalObject}[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`;
581
581
  );
582
582
  mainTemplate.hooks.hash.tap("JsonpMainTemplatePlugin", hash => {
583
583
  hash.update("jsonp");
584
- hash.update("5");
585
- hash.update(`${mainTemplate.outputOptions.globalObject}`);
586
- hash.update(`${mainTemplate.outputOptions.chunkFilename}`);
587
- hash.update(`${mainTemplate.outputOptions.jsonpFunction}`);
588
- hash.update(`${mainTemplate.outputOptions.hotUpdateFunction}`);
584
+ hash.update("6");
589
585
  });
590
586
  }
591
587
  }
@@ -184,12 +184,7 @@ class WebWorkerMainTemplatePlugin {
184
184
  );
185
185
  mainTemplate.hooks.hash.tap("WebWorkerMainTemplatePlugin", hash => {
186
186
  hash.update("webworker");
187
- hash.update("3");
188
- hash.update(`${mainTemplate.outputOptions.publicPath}`);
189
- hash.update(`${mainTemplate.outputOptions.filename}`);
190
- hash.update(`${mainTemplate.outputOptions.chunkFilename}`);
191
- hash.update(`${mainTemplate.outputOptions.chunkCallbackName}`);
192
- hash.update(`${mainTemplate.outputOptions.globalObject}`);
187
+ hash.update("4");
193
188
  });
194
189
  }
195
190
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "4.18.1",
3
+ "version": "4.19.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",
@@ -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
+ )} 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,26 +1,26 @@
1
- {
2
- "type": "object",
3
- "additionalProperties": true,
4
- "properties": {
5
- "debug": {
6
- "description": "Whether loaders should be in debug mode or not. debug will be removed as of webpack 3",
7
- "type": "boolean"
8
- },
9
- "minimize": {
10
- "description": "Where loaders can be switched to minimize mode",
11
- "type": "boolean"
12
- },
13
- "options": {
14
- "description": "A configuration object that can be used to configure older loaders",
15
- "type": "object",
16
- "additionalProperties": true,
17
- "properties": {
18
- "context": {
19
- "description": "The context that can be used to configure older loaders",
20
- "type": "string",
21
- "absolutePath": true
22
- }
23
- }
24
- }
25
- }
26
- }
1
+ {
2
+ "type": "object",
3
+ "additionalProperties": true,
4
+ "properties": {
5
+ "debug": {
6
+ "description": "Whether loaders should be in debug mode or not. debug will be removed as of webpack 3",
7
+ "type": "boolean"
8
+ },
9
+ "minimize": {
10
+ "description": "Where loaders can be switched to minimize mode",
11
+ "type": "boolean"
12
+ },
13
+ "options": {
14
+ "description": "A configuration object that can be used to configure older loaders",
15
+ "type": "object",
16
+ "additionalProperties": true,
17
+ "properties": {
18
+ "context": {
19
+ "description": "The context that can be used to configure older loaders",
20
+ "type": "string",
21
+ "absolutePath": true
22
+ }
23
+ }
24
+ }
25
+ }
26
+ }
@@ -1,16 +1,16 @@
1
- {
2
- "description": "A list of RegExps or absolute paths to directories or files that should be ignored",
3
- "type": "array",
4
- "items": {
5
- "description": "RegExp or absolute path to directories or files that should be ignored",
6
- "oneOf": [
7
- {
8
- "type": "string"
9
- },
10
- {
11
- "instanceof": "RegExp"
12
- }
13
- ]
14
- },
15
- "minItems": 1
16
- }
1
+ {
2
+ "description": "A list of RegExps or absolute paths to directories or files that should be ignored",
3
+ "type": "array",
4
+ "items": {
5
+ "description": "RegExp or absolute path to directories or files that should be ignored",
6
+ "oneOf": [
7
+ {
8
+ "type": "string"
9
+ },
10
+ {
11
+ "instanceof": "RegExp"
12
+ }
13
+ ]
14
+ },
15
+ "minItems": 1
16
+ }
@@ -1,12 +1,12 @@
1
- {
2
- "type": "object",
3
- "additionalProperties": false,
4
- "properties": {
5
- "outputPath": {
6
- "description": "Path to the output file e.g. `profiling/events.json`. Defaults to `events.json`.",
7
- "type": "string",
8
- "absolutePath": false,
9
- "minLength": 4
10
- }
11
- }
12
- }
1
+ {
2
+ "type": "object",
3
+ "additionalProperties": false,
4
+ "properties": {
5
+ "outputPath": {
6
+ "description": "Path to the output file e.g. `profiling/events.json`. Defaults to `events.json`.",
7
+ "type": "string",
8
+ "absolutePath": false,
9
+ "minLength": 4
10
+ }
11
+ }
12
+ }
@@ -1,22 +1,22 @@
1
- {
2
- "type": "object",
3
- "additionalProperties": false,
4
- "properties": {
5
- "minSize": {
6
- "description": "Byte, split point. Default: 30720",
7
- "type": "number"
8
- },
9
- "maxSize": {
10
- "description": "Byte, maxsize of per file. Default: 51200",
11
- "type": "number"
12
- },
13
- "chunkOverhead": {
14
- "description": "Default: 0",
15
- "type": "number"
16
- },
17
- "entryChunkMultiplicator": {
18
- "description": "Default: 1",
19
- "type": "number"
20
- }
21
- }
22
- }
1
+ {
2
+ "type": "object",
3
+ "additionalProperties": false,
4
+ "properties": {
5
+ "minSize": {
6
+ "description": "Byte, split point. Default: 30720",
7
+ "type": "number"
8
+ },
9
+ "maxSize": {
10
+ "description": "Byte, maxsize of per file. Default: 51200",
11
+ "type": "number"
12
+ },
13
+ "chunkOverhead": {
14
+ "description": "Default: 0",
15
+ "type": "number"
16
+ },
17
+ "entryChunkMultiplicator": {
18
+ "description": "Default: 1",
19
+ "type": "number"
20
+ }
21
+ }
22
+ }
@@ -1,15 +1,15 @@
1
- {
2
- "type": "object",
3
- "additionalProperties": false,
4
- "properties": {
5
- "maxChunks": {
6
- "description": "Limit the maximum number of chunks using a value greater greater than or equal to 1",
7
- "type": "number",
8
- "minimum": 1
9
- },
10
- "minChunkSize": {
11
- "description": "Set a minimum chunk size",
12
- "type": "number"
13
- }
14
- }
15
- }
1
+ {
2
+ "type": "object",
3
+ "additionalProperties": false,
4
+ "properties": {
5
+ "maxChunks": {
6
+ "description": "Limit the maximum number of chunks using a value greater greater than or equal to 1",
7
+ "type": "number",
8
+ "minimum": 1
9
+ },
10
+ "minChunkSize": {
11
+ "description": "Set a minimum chunk size",
12
+ "type": "number"
13
+ }
14
+ }
15
+ }