mm_machine 3.2.3 → 3.2.4

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.
Files changed (2) hide show
  1. package/manager.js +7 -3
  2. package/package.json +1 -1
package/manager.js CHANGED
@@ -237,11 +237,9 @@ Manager.prototype.delMod = function (name) {
237
237
  * 设置模块
238
238
  * @param {string} name 模块名
239
239
  * @param {object} mod 模块对象
240
- * @returns {object|null} 设置的模块对象
241
240
  */
242
241
  Manager.prototype.setMod = function (name, mod) {
243
242
  this.mods[name] = mod;
244
- return this.getMod(name);
245
243
  };
246
244
 
247
245
  /**
@@ -260,6 +258,10 @@ Manager.prototype.getMod = function (name) {
260
258
  for (var i = 0; i < entries.length; i++) {
261
259
  if (entries[i].name === name) {
262
260
  mod = this.newMod(entries[i].config_file);
261
+ // 保存到内存集合,避免后续访问时再次创建
262
+ if (mod) {
263
+ this.setMod(mod.config.name, mod);
264
+ }
263
265
  return mod;
264
266
  }
265
267
  }
@@ -527,7 +529,9 @@ Manager.prototype._loadFromRegistry = function () {
527
529
  var entry = lt[i];
528
530
  if (!this.config.lazy_load) {
529
531
  let mod = this.newMod(entry.config_file);
530
- this.mods[entry.name] = mod;
532
+ if (mod) {
533
+ this.setMod(mod.config.name, mod);
534
+ }
531
535
  }
532
536
  }
533
537
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
4
4
  "description": "A flexible Node.js plugin mechanism system for dynamic loading, management and execution of modules. Supports hot reload, lifecycle management, and modern JavaScript features.",
5
5
  "main": "index.js",
6
6
  "scripts": {