@itrocks/lazy-loading 0.0.4 → 0.0.5

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.
@@ -85,15 +85,25 @@ function initLazyLoading() {
85
85
  Module.prototype.require = function () {
86
86
  const original = superRequire.call(this, ...arguments);
87
87
  let module;
88
+ let replacements;
88
89
  for (const [name, type] of Object.entries(original)) {
89
90
  if (!(0, class_type_1.isAnyType)(type))
90
91
  continue;
92
+ if (module && replacements) {
93
+ const replacement = replacements.get(type);
94
+ if (replacement) {
95
+ module[name] = replacement;
96
+ continue;
97
+ }
98
+ }
91
99
  const withORM = initClass(type);
92
100
  if (!withORM)
93
101
  continue;
94
- if (!module) {
102
+ if (!replacements) {
95
103
  module = { ...original };
104
+ replacements = new Map();
96
105
  }
106
+ replacements.set(type, withORM);
97
107
  // @ts-ignore TS18048 but module is always initialized
98
108
  module[name] = withORM;
99
109
  }
@@ -82,15 +82,25 @@ export function initLazyLoading() {
82
82
  Module.prototype.require = function () {
83
83
  const original = superRequire.call(this, ...arguments);
84
84
  let module;
85
+ let replacements;
85
86
  for (const [name, type] of Object.entries(original)) {
86
87
  if (!isAnyType(type))
87
88
  continue;
89
+ if (module && replacements) {
90
+ const replacement = replacements.get(type);
91
+ if (replacement) {
92
+ module[name] = replacement;
93
+ continue;
94
+ }
95
+ }
88
96
  const withORM = initClass(type);
89
97
  if (!withORM)
90
98
  continue;
91
- if (!module) {
99
+ if (!replacements) {
92
100
  module = { ...original };
101
+ replacements = new Map();
93
102
  }
103
+ replacements.set(type, withORM);
94
104
  // @ts-ignore TS18048 but module is always initialized
95
105
  module[name] = withORM;
96
106
  }
package/package.json CHANGED
@@ -54,5 +54,5 @@
54
54
  "build:esm": "tsc -p tsconfig.esm.json && node esm/esm"
55
55
  },
56
56
  "types": "./esm/lazy-loading.d.ts",
57
- "version": "0.0.4"
57
+ "version": "0.0.5"
58
58
  }