@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.
- package/cjs/lazy-loading.js +11 -1
- package/esm/lazy-loading.js +11 -1
- package/package.json +1 -1
package/cjs/lazy-loading.js
CHANGED
|
@@ -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 (!
|
|
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
|
}
|
package/esm/lazy-loading.js
CHANGED
|
@@ -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 (!
|
|
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