@blocklet/pages-kit 0.4.59 → 0.4.61

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.
@@ -126,12 +126,19 @@ function injectGlobalComponents() {
126
126
  const setupImportMap = async () => {
127
127
  const modulesResolved = {};
128
128
  // 确保 modules 的 value 中的所有 promise 都加载为 es module
129
- await Promise.all(Object.entries(modules).map(async ([modulePath, moduleContent]) => {
129
+ await Promise.all(Object.entries(win[builtin_1.BuiltinModulesGlobalVariableName].modules).map(async ([modulePath, moduleContent]) => {
130
130
  if (moduleContent instanceof Promise) {
131
131
  const mod = await moduleContent;
132
- modulesResolved[modulePath] = mod;
133
- // replace the original moduleContent with the resolved module
134
- win[builtin_1.BuiltinModulesGlobalVariableName].modules[modulePath] = mod;
132
+ // 重复确认依然是 promise 才进行替换
133
+ if (win[builtin_1.BuiltinModulesGlobalVariableName].modules[modulePath] instanceof Promise) {
134
+ modulesResolved[modulePath] = mod;
135
+ // replace the original moduleContent with the resolved module
136
+ win[builtin_1.BuiltinModulesGlobalVariableName].modules[modulePath] = mod;
137
+ }
138
+ else {
139
+ // 否则直接使用已加载的模块
140
+ modulesResolved[modulePath] = win[builtin_1.BuiltinModulesGlobalVariableName].modules[modulePath];
141
+ }
135
142
  return;
136
143
  }
137
144
  modulesResolved[modulePath] = moduleContent;