WebpackChunkModuleIterator.js 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. "use strict";
  2. var __values = (this && this.__values) || function(o) {
  3. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  4. if (m) return m.call(o);
  5. if (o && typeof o.length === "number") return {
  6. next: function () {
  7. if (o && i >= o.length) o = void 0;
  8. return { value: o && o[i++], done: !o };
  9. }
  10. };
  11. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  12. };
  13. Object.defineProperty(exports, "__esModule", { value: true });
  14. exports.WebpackChunkModuleIterator = void 0;
  15. var WebpackStatsIterator_1 = require("./WebpackStatsIterator");
  16. var WebpackChunkModuleIterator = /** @class */ (function () {
  17. function WebpackChunkModuleIterator() {
  18. this.statsIterator = new WebpackStatsIterator_1.WebpackStatsIterator();
  19. }
  20. WebpackChunkModuleIterator.prototype.iterateModules = function (compilation, chunk, stats, callback) {
  21. var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
  22. if (typeof compilation.chunkGraph !== 'undefined' &&
  23. typeof stats !== 'undefined') {
  24. try {
  25. // webpack v5
  26. for (var _e = __values(compilation.chunkGraph.getChunkModulesIterable(chunk)), _f = _e.next(); !_f.done; _f = _e.next()) {
  27. var module_1 = _f.value;
  28. callback(module_1);
  29. }
  30. }
  31. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  32. finally {
  33. try {
  34. if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
  35. }
  36. finally { if (e_1) throw e_1.error; }
  37. }
  38. var statsModules = this.statsIterator.collectModules(stats, chunk.name);
  39. try {
  40. for (var statsModules_1 = __values(statsModules), statsModules_1_1 = statsModules_1.next(); !statsModules_1_1.done; statsModules_1_1 = statsModules_1.next()) {
  41. var module_2 = statsModules_1_1.value;
  42. callback(module_2);
  43. }
  44. }
  45. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  46. finally {
  47. try {
  48. if (statsModules_1_1 && !statsModules_1_1.done && (_b = statsModules_1.return)) _b.call(statsModules_1);
  49. }
  50. finally { if (e_2) throw e_2.error; }
  51. }
  52. }
  53. else if (typeof chunk.modulesIterable !== 'undefined') {
  54. try {
  55. for (var _g = __values(chunk.modulesIterable), _h = _g.next(); !_h.done; _h = _g.next()) {
  56. var module_3 = _h.value;
  57. callback(module_3);
  58. }
  59. }
  60. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  61. finally {
  62. try {
  63. if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
  64. }
  65. finally { if (e_3) throw e_3.error; }
  66. }
  67. }
  68. else if (typeof chunk.forEachModule === 'function') {
  69. chunk.forEachModule(callback);
  70. }
  71. else if (Array.isArray(chunk.modules)) {
  72. chunk.modules.forEach(callback);
  73. }
  74. if (typeof compilation.chunkGraph !== 'undefined') {
  75. try {
  76. for (var _j = __values(compilation.chunkGraph.getChunkEntryModulesIterable(chunk)), _k = _j.next(); !_k.done; _k = _j.next()) {
  77. var module_4 = _k.value;
  78. callback(module_4);
  79. }
  80. }
  81. catch (e_4_1) { e_4 = { error: e_4_1 }; }
  82. finally {
  83. try {
  84. if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
  85. }
  86. finally { if (e_4) throw e_4.error; }
  87. }
  88. }
  89. else if (chunk.entryModule) {
  90. callback(chunk.entryModule);
  91. }
  92. };
  93. return WebpackChunkModuleIterator;
  94. }());
  95. exports.WebpackChunkModuleIterator = WebpackChunkModuleIterator;