PluginModuleCache.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var PluginModuleCache = /** @class */ (function () {
  4. function PluginModuleCache() {
  5. this.totalCache = {};
  6. this.chunkCache = {};
  7. this.chunkSeenCache = {};
  8. }
  9. PluginModuleCache.prototype.registerModule = function (chunkName, module) {
  10. this.totalCache[module.name] = module;
  11. if (!this.chunkCache[chunkName]) {
  12. this.chunkCache[chunkName] = {};
  13. }
  14. this.chunkCache[chunkName][module.name] = module;
  15. };
  16. PluginModuleCache.prototype.getModule = function (packageName) {
  17. return this.totalCache[packageName] || null;
  18. };
  19. PluginModuleCache.prototype.markSeenForChunk = function (chunkName, packageName) {
  20. if (!this.chunkSeenCache[chunkName]) {
  21. this.chunkSeenCache[chunkName] = {};
  22. }
  23. this.chunkSeenCache[chunkName][packageName] = true;
  24. };
  25. PluginModuleCache.prototype.alreadySeenForChunk = function (chunkName, packageName) {
  26. return !!(this.chunkSeenCache[chunkName] &&
  27. this.chunkSeenCache[chunkName][packageName]);
  28. };
  29. PluginModuleCache.prototype.getAllModulesForChunk = function (chunkName) {
  30. var modules = [];
  31. var cache = this.chunkCache[chunkName];
  32. if (cache) {
  33. Object.keys(cache).forEach(function (key) {
  34. modules.push(cache[key]);
  35. });
  36. }
  37. return modules;
  38. };
  39. PluginModuleCache.prototype.getAllModules = function () {
  40. var _this = this;
  41. var modules = [];
  42. Object.keys(this.totalCache).forEach(function (key) {
  43. modules.push(_this.totalCache[key]);
  44. });
  45. return modules;
  46. };
  47. return PluginModuleCache;
  48. }());
  49. exports.PluginModuleCache = PluginModuleCache;