webpack 4.27.0 → 4.28.2

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/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
+ };
@@ -21,7 +21,7 @@ export type IgnorePluginOptions =
21
21
  */
22
22
  checkContext?: ((context: string) => boolean);
23
23
  /**
24
- * A filter function for resource
24
+ * A filter function for resource and context
25
25
  */
26
- checkResource?: ((resource: string) => boolean);
26
+ checkResource?: ((resource: string, context: string) => boolean);
27
27
  };
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();
@@ -30,61 +30,47 @@ class IgnorePlugin {
30
30
  this.checkIgnore = this.checkIgnore.bind(this);
31
31
  }
32
32
 
33
- /**
34
- * @param {string} resource resource
35
- * @returns {boolean} returns true if a "resourceRegExp" exists
36
- * and the resource given matches the regexp.
37
- */
38
- checkResource(resource) {
39
- if ("checkResource" in this.options && this.options.checkResource) {
40
- return this.options.checkResource(resource);
41
- }
42
- if ("resourceRegExp" in this.options && this.options.resourceRegExp) {
43
- return this.options.resourceRegExp.test(resource);
44
- }
45
- return false;
46
- }
47
-
48
- /**
49
- * @param {string} context context
50
- * @returns {boolean} returns true if "contextRegExp" does not exist
51
- * or if context matches the given regexp.
52
- */
53
- checkContext(context) {
54
- if ("checkContext" in this.options && this.options.checkContext) {
55
- return this.options.checkContext(context);
56
- }
57
- if ("contextRegExp" in this.options && this.options.contextRegExp) {
58
- return this.options.contextRegExp.test(context);
59
- }
60
- return true;
61
- }
62
-
63
33
  /**
64
34
  * Note that if "contextRegExp" is given, both the "resourceRegExp"
65
35
  * and "contextRegExp" have to match.
66
36
  *
67
- * @param {TODO} result result
68
- * @returns {boolean} returns true if result should be ignored
69
- */
70
- checkResult(result) {
71
- if (!result) {
72
- return true;
73
- }
74
- return (
75
- this.checkResource(result.request) && this.checkContext(result.context)
76
- );
77
- }
78
-
79
- /**
80
37
  * @param {TODO} result result
81
38
  * @returns {TODO|null} returns result or null if result should be ignored
82
39
  */
83
40
  checkIgnore(result) {
84
- // check if result is ignored
85
- if (this.checkResult(result)) {
86
- return null;
41
+ if (!result) return result;
42
+
43
+ if (
44
+ "checkResource" in this.options &&
45
+ this.options.checkResource &&
46
+ this.options.checkResource(result.request, result.context)
47
+ ) {
48
+ // TODO webpack 5 remove checkContext, as checkResource already gets context
49
+ if ("checkContext" in this.options && this.options.checkContext) {
50
+ if (this.options.checkContext(result.context)) {
51
+ return null;
52
+ }
53
+ } else {
54
+ return null;
55
+ }
87
56
  }
57
+
58
+ if (
59
+ "resourceRegExp" in this.options &&
60
+ this.options.resourceRegExp &&
61
+ this.options.resourceRegExp.test(result.request)
62
+ ) {
63
+ if ("contextRegExp" in this.options && this.options.contextRegExp) {
64
+ // if "contextRegExp" is given,
65
+ // both the "resourceRegExp" and "contextRegExp" have to match.
66
+ if (this.options.contextRegExp.test(result.context)) {
67
+ return null;
68
+ }
69
+ } else {
70
+ return null;
71
+ }
72
+ }
73
+
88
74
  return result;
89
75
  }
90
76
 
@@ -116,9 +116,6 @@ module.exports = class NodeSourcePlugin {
116
116
  normalModuleFactory.hooks.parser
117
117
  .for("javascript/dynamic")
118
118
  .tap("NodeSourcePlugin", handler);
119
- normalModuleFactory.hooks.parser
120
- .for("javascript/esm")
121
- .tap("NodeSourcePlugin", handler);
122
119
  }
123
120
  );
124
121
  compiler.hooks.afterResolvers.tap("NodeSourcePlugin", compiler => {
@@ -465,11 +465,7 @@ module.exports = class SplitChunksPlugin {
465
465
  module
466
466
  ) => {
467
467
  // Break if minimum number of chunks is not reached
468
- if (
469
- !cacheGroup.enforce &&
470
- selectedChunks.length < cacheGroup.minChunks
471
- )
472
- return;
468
+ if (selectedChunks.length < cacheGroup.minChunks) return;
473
469
  // Determine name for split chunk
474
470
  const name = cacheGroup.getName(
475
471
  module,
@@ -492,7 +488,7 @@ module.exports = class SplitChunksPlugin {
492
488
  modules: new SortableSet(undefined, sortByIdentifier),
493
489
  cacheGroup,
494
490
  name,
495
- validateSize: !cacheGroup.enforce && cacheGroup.minSize > 0,
491
+ validateSize: cacheGroup.minSize > 0,
496
492
  size: 0,
497
493
  chunks: new Set(),
498
494
  reuseableChunks: new Set(),
@@ -534,27 +530,40 @@ module.exports = class SplitChunksPlugin {
534
530
  priority: cacheGroupSource.priority || 0,
535
531
  chunksFilter:
536
532
  cacheGroupSource.chunksFilter || this.options.chunksFilter,
537
- enforce: cacheGroupSource.enforce,
538
533
  minSize:
534
+ cacheGroupSource.minSize !== undefined
535
+ ? cacheGroupSource.minSize
536
+ : cacheGroupSource.enforce
537
+ ? 0
538
+ : this.options.minSize,
539
+ minSizeForMaxSize:
539
540
  cacheGroupSource.minSize !== undefined
540
541
  ? cacheGroupSource.minSize
541
542
  : this.options.minSize,
542
543
  maxSize:
543
544
  cacheGroupSource.maxSize !== undefined
544
545
  ? cacheGroupSource.maxSize
545
- : this.options.maxSize,
546
+ : cacheGroupSource.enforce
547
+ ? 0
548
+ : this.options.maxSize,
546
549
  minChunks:
547
550
  cacheGroupSource.minChunks !== undefined
548
551
  ? cacheGroupSource.minChunks
549
- : this.options.minChunks,
552
+ : cacheGroupSource.enforce
553
+ ? 1
554
+ : this.options.minChunks,
550
555
  maxAsyncRequests:
551
556
  cacheGroupSource.maxAsyncRequests !== undefined
552
557
  ? cacheGroupSource.maxAsyncRequests
553
- : this.options.maxAsyncRequests,
558
+ : cacheGroupSource.enforce
559
+ ? Infinity
560
+ : this.options.maxAsyncRequests,
554
561
  maxInitialRequests:
555
562
  cacheGroupSource.maxInitialRequests !== undefined
556
563
  ? cacheGroupSource.maxInitialRequests
557
- : this.options.maxInitialRequests,
564
+ : cacheGroupSource.enforce
565
+ ? Infinity
566
+ : this.options.maxInitialRequests,
558
567
  getName:
559
568
  cacheGroupSource.getName !== undefined
560
569
  ? cacheGroupSource.getName
@@ -572,11 +581,7 @@ module.exports = class SplitChunksPlugin {
572
581
  // For all combination of chunk selection
573
582
  for (const chunkCombination of combs) {
574
583
  // Break if minimum number of chunks is not reached
575
- if (
576
- !cacheGroup.enforce &&
577
- chunkCombination.size < cacheGroup.minChunks
578
- )
579
- continue;
584
+ if (chunkCombination.size < cacheGroup.minChunks) continue;
580
585
  // Select chunks by configuration
581
586
  const {
582
587
  chunks: selectedChunks,
@@ -586,14 +591,12 @@ module.exports = class SplitChunksPlugin {
586
591
  cacheGroup.chunksFilter
587
592
  );
588
593
 
589
- if (selectedChunks.length > 0) {
590
- addModuleToChunksInfoMap(
591
- cacheGroup,
592
- selectedChunks,
593
- selectedChunksKey,
594
- module
595
- );
596
- }
594
+ addModuleToChunksInfoMap(
595
+ cacheGroup,
596
+ selectedChunks,
597
+ selectedChunksKey,
598
+ module
599
+ );
597
600
  }
598
601
  }
599
602
  }
@@ -672,9 +675,8 @@ module.exports = class SplitChunksPlugin {
672
675
  if (usedChunks.length === 0) continue;
673
676
 
674
677
  if (
675
- !item.cacheGroup.enforce &&
676
- (Number.isFinite(item.cacheGroup.maxInitialRequests) ||
677
- Number.isFinite(item.cacheGroup.maxAsyncRequests))
678
+ Number.isFinite(item.cacheGroup.maxInitialRequests) ||
679
+ Number.isFinite(item.cacheGroup.maxAsyncRequests)
678
680
  ) {
679
681
  const chunkInLimit = usedChunks.filter(chunk => {
680
682
  // respect max requests when not enforced
@@ -692,8 +694,6 @@ module.exports = class SplitChunksPlugin {
692
694
  });
693
695
 
694
696
  if (chunkInLimit.length < usedChunks.length) {
695
- // We do not need to check enforce here as it was
696
- // already checked above.
697
697
  if (chunkInLimit.length >= item.cacheGroup.minChunks) {
698
698
  for (const module of item.modules) {
699
699
  addModuleToChunksInfoMap(
@@ -775,7 +775,7 @@ module.exports = class SplitChunksPlugin {
775
775
  maxSizeQueueMap.set(newChunk, {
776
776
  minSize: Math.max(
777
777
  oldMaxSizeSettings ? oldMaxSizeSettings.minSize : 0,
778
- item.cacheGroup.minSize
778
+ item.cacheGroup.minSizeForMaxSize
779
779
  ),
780
780
  maxSize: Math.min(
781
781
  oldMaxSizeSettings ? oldMaxSizeSettings.maxSize : Infinity,
@@ -12,12 +12,11 @@ module.exports = function() {
12
12
 
13
13
  // eslint-disable-next-line no-unused-vars
14
14
  function hotDownloadUpdateChunk(chunkId) {
15
- var head = document.getElementsByTagName("head")[0];
16
15
  var script = document.createElement("script");
17
16
  script.charset = "utf-8";
18
17
  script.src = $require$.p + $hotChunkFilename$;
19
18
  if ($crossOriginLoading$) script.crossOrigin = $crossOriginLoading$;
20
- head.appendChild(script);
19
+ document.head.appendChild(script);
21
20
  }
22
21
 
23
22
  // eslint-disable-next-line no-unused-vars
@@ -282,9 +282,8 @@ class JsonpMainTemplatePlugin {
282
282
  "promises.push(installedChunkData[2] = promise);",
283
283
  "",
284
284
  "// start chunk loading",
285
- "var head = document.getElementsByTagName('head')[0];",
286
285
  mainTemplate.hooks.jsonpScript.call("", chunk, hash),
287
- "head.appendChild(script);"
286
+ "document.head.appendChild(script);"
288
287
  ]),
289
288
  "}"
290
289
  ]),
@@ -310,14 +309,13 @@ class JsonpMainTemplatePlugin {
310
309
  "var chunkPreloadData = chunkPreloadMap[chunkId];",
311
310
  "if(chunkPreloadData) {",
312
311
  Template.indent([
313
- "var head = document.getElementsByTagName('head')[0];",
314
312
  "chunkPreloadData.forEach(function(chunkId) {",
315
313
  Template.indent([
316
314
  "if(installedChunks[chunkId] === undefined) {",
317
315
  Template.indent([
318
316
  "installedChunks[chunkId] = null;",
319
317
  mainTemplate.hooks.linkPreload.call("", chunk, hash),
320
- "head.appendChild(link);"
318
+ "document.head.appendChild(link);"
321
319
  ]),
322
320
  "}"
323
321
  ]),
@@ -388,14 +386,13 @@ class JsonpMainTemplatePlugin {
388
386
  withPrefetch
389
387
  ? Template.asString([
390
388
  "// chunk prefetching for javascript",
391
- "var head = document.getElementsByTagName('head')[0];",
392
389
  "prefetchChunks.forEach(function(chunkId) {",
393
390
  Template.indent([
394
391
  "if(installedChunks[chunkId] === undefined) {",
395
392
  Template.indent([
396
393
  "installedChunks[chunkId] = null;",
397
394
  mainTemplate.hooks.linkPrefetch.call("", chunk, hash),
398
- "head.appendChild(link);"
395
+ "document.head.appendChild(link);"
399
396
  ]),
400
397
  "}"
401
398
  ]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "4.27.0",
3
+ "version": "4.28.2",
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",
@@ -27,9 +27,9 @@
27
27
  "tsType": "((context: string) => boolean)"
28
28
  },
29
29
  "checkResource": {
30
- "description": "A filter function for resource",
30
+ "description": "A filter function for resource and context",
31
31
  "instanceof": "Function",
32
- "tsType": "((resource: string) => boolean)"
32
+ "tsType": "((resource: string, context: string) => boolean)"
33
33
  }
34
34
  }
35
35
  }