webpack 4.26.0 → 4.26.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 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/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
@@ -7,7 +7,7 @@ g = (function() {
7
7
 
8
8
  try {
9
9
  // This works if eval is allowed (see CSP)
10
- g = g || Function("return this")() || (1, eval)("this");
10
+ g = g || new Function("return this")();
11
11
  } catch (e) {
12
12
  // This works if the window reference is available
13
13
  if (typeof window === "object") g = window;
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();
@@ -795,7 +795,7 @@ module.exports = class SplitChunksPlugin {
795
795
  maxSizeQueueMap.get(chunk) || this.options.fallbackCacheGroup;
796
796
  if (!maxSize) continue;
797
797
  const results = deterministicGroupingForModules({
798
- maxSize,
798
+ maxSize: Math.max(minSize, maxSize),
799
799
  minSize,
800
800
  items: chunk.modulesIterable,
801
801
  getKey(module) {
@@ -124,6 +124,13 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
124
124
  /** @type {Node<T>[]} */
125
125
  const initialNodes = [];
126
126
 
127
+ // lexically ordering of keys
128
+ nodes.sort((a, b) => {
129
+ if (a.key < b.key) return -1;
130
+ if (a.key > b.key) return 1;
131
+ return 0;
132
+ });
133
+
127
134
  // return nodes bigger than maxSize directly as group
128
135
  for (const node of nodes) {
129
136
  if (node.size >= maxSize) {
@@ -134,13 +141,6 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
134
141
  }
135
142
 
136
143
  if (initialNodes.length > 0) {
137
- // lexically ordering of keys
138
- initialNodes.sort((a, b) => {
139
- if (a.key < b.key) return -1;
140
- if (a.key > b.key) return 1;
141
- return 0;
142
- });
143
-
144
144
  // calculate similarities between lexically adjacent nodes
145
145
  /** @type {number[]} */
146
146
  const similarities = [];
@@ -150,76 +150,99 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
150
150
  similarities.push(similarity(a.key, b.key));
151
151
  }
152
152
 
153
- const queue = [new Group(initialNodes, similarities)];
153
+ const initialGroup = new Group(initialNodes, similarities);
154
154
 
155
- while (queue.length) {
156
- const group = queue.pop();
157
- // only groups bigger than maxSize need to be splitted
158
- if (group.size < maxSize) {
159
- result.push(group);
160
- continue;
155
+ if (initialGroup.size < minSize) {
156
+ // We hit an edgecase where the working set is already smaller than minSize
157
+ // We merge it with the smallest result node to keep minSize intact
158
+ if (result.length > 0) {
159
+ const smallestGroup = result.reduce(
160
+ (min, group) => (min.size > group.size ? group : min)
161
+ );
162
+ for (const node of initialGroup.nodes) smallestGroup.nodes.push(node);
163
+ smallestGroup.nodes.sort((a, b) => {
164
+ if (a.key < b.key) return -1;
165
+ if (a.key > b.key) return 1;
166
+ return 0;
167
+ });
168
+ } else {
169
+ // There are no other nodes
170
+ // We use all nodes and have to accept that it's smaller than minSize
171
+ result.push(initialGroup);
161
172
  }
173
+ } else {
174
+ const queue = [initialGroup];
162
175
 
163
- // find unsplittable area from left and right
164
- // going minSize from left and right
165
- let left = 0;
166
- let leftSize = 0;
167
- while (leftSize < minSize) {
168
- leftSize += group.nodes[left].size;
169
- left++;
170
- }
171
- let right = group.nodes.length - 1;
172
- let rightSize = 0;
173
- while (rightSize < minSize) {
174
- rightSize += group.nodes[right].size;
175
- right--;
176
- }
176
+ while (queue.length) {
177
+ const group = queue.pop();
178
+ // only groups bigger than maxSize need to be splitted
179
+ if (group.size < maxSize) {
180
+ result.push(group);
181
+ continue;
182
+ }
177
183
 
178
- if (left - 1 > right) {
179
- // can't split group while holding minSize
180
- // because minSize is preferred of maxSize we return
181
- // the group here even while it's too big
182
- // To avoid this make sure maxSize > minSize * 3
183
- result.push(group);
184
- continue;
185
- }
186
- if (left <= right) {
187
- // when there is a area between left and right
188
- // we look for best split point
189
- // we split at the minimum similarity
190
- // here key space is separated the most
191
- let best = left - 1;
192
- let bestSimilarity = group.similarities[best];
193
- for (let i = left; i <= right; i++) {
194
- const similarity = group.similarities[i];
195
- if (similarity < bestSimilarity) {
196
- best = i;
197
- bestSimilarity = similarity;
184
+ // find unsplittable area from left and right
185
+ // going minSize from left and right
186
+ // at least one node need to be included otherwise we get stuck
187
+ let left = 0;
188
+ let leftSize = 0;
189
+ while (leftSize <= minSize) {
190
+ leftSize += group.nodes[left].size;
191
+ left++;
192
+ }
193
+ let right = group.nodes.length - 1;
194
+ let rightSize = 0;
195
+ while (rightSize <= minSize) {
196
+ rightSize += group.nodes[right].size;
197
+ right--;
198
+ }
199
+
200
+ if (left - 1 > right) {
201
+ // can't split group while holding minSize
202
+ // because minSize is preferred of maxSize we return
203
+ // the group here even while it's too big
204
+ // To avoid this make sure maxSize > minSize * 3
205
+ result.push(group);
206
+ continue;
207
+ }
208
+ if (left <= right) {
209
+ // when there is a area between left and right
210
+ // we look for best split point
211
+ // we split at the minimum similarity
212
+ // here key space is separated the most
213
+ let best = left - 1;
214
+ let bestSimilarity = group.similarities[best];
215
+ for (let i = left; i <= right; i++) {
216
+ const similarity = group.similarities[i];
217
+ if (similarity < bestSimilarity) {
218
+ best = i;
219
+ bestSimilarity = similarity;
220
+ }
198
221
  }
222
+ left = best + 1;
223
+ right = best;
199
224
  }
200
- left = best + 1;
201
- right = best;
202
- }
203
225
 
204
- // create two new groups for left and right area
205
- // and queue them up
206
- const rightNodes = [group.nodes[right + 1]];
207
- /** @type {number[]} */
208
- const rightSimilaries = [];
209
- for (let i = right + 2; i < group.nodes.length; i++) {
210
- rightSimilaries.push(group.similarities[i - 1]);
211
- rightNodes.push(group.nodes[i]);
212
- }
213
- queue.push(new Group(rightNodes, rightSimilaries));
214
-
215
- const leftNodes = [group.nodes[0]];
216
- /** @type {number[]} */
217
- const leftSimilaries = [];
218
- for (let i = 1; i < left; i++) {
219
- leftSimilaries.push(group.similarities[i - 1]);
220
- leftNodes.push(group.nodes[i]);
226
+ // create two new groups for left and right area
227
+ // and queue them up
228
+ const rightNodes = [group.nodes[right + 1]];
229
+ /** @type {number[]} */
230
+ const rightSimilaries = [];
231
+ for (let i = right + 2; i < group.nodes.length; i++) {
232
+ rightSimilaries.push(group.similarities[i - 1]);
233
+ rightNodes.push(group.nodes[i]);
234
+ }
235
+ queue.push(new Group(rightNodes, rightSimilaries));
236
+
237
+ const leftNodes = [group.nodes[0]];
238
+ /** @type {number[]} */
239
+ const leftSimilaries = [];
240
+ for (let i = 1; i < left; i++) {
241
+ leftSimilaries.push(group.similarities[i - 1]);
242
+ leftNodes.push(group.nodes[i]);
243
+ }
244
+ queue.push(new Group(leftNodes, leftSimilaries));
221
245
  }
222
- queue.push(new Group(leftNodes, leftSimilaries));
223
246
  }
224
247
  }
225
248
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "4.26.0",
3
+ "version": "4.26.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",