@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.
@@ -97,12 +97,19 @@ export function injectGlobalComponents() {
97
97
  const setupImportMap = async () => {
98
98
  const modulesResolved = {};
99
99
  // 确保 modules 的 value 中的所有 promise 都加载为 es module
100
- await Promise.all(Object.entries(modules).map(async ([modulePath, moduleContent]) => {
100
+ await Promise.all(Object.entries(win[BuiltinModulesGlobalVariableName].modules).map(async ([modulePath, moduleContent]) => {
101
101
  if (moduleContent instanceof Promise) {
102
102
  const mod = await moduleContent;
103
- modulesResolved[modulePath] = mod;
104
- // replace the original moduleContent with the resolved module
105
- win[BuiltinModulesGlobalVariableName].modules[modulePath] = mod;
103
+ // 重复确认依然是 promise 才进行替换
104
+ if (win[BuiltinModulesGlobalVariableName].modules[modulePath] instanceof Promise) {
105
+ modulesResolved[modulePath] = mod;
106
+ // replace the original moduleContent with the resolved module
107
+ win[BuiltinModulesGlobalVariableName].modules[modulePath] = mod;
108
+ }
109
+ else {
110
+ // 否则直接使用已加载的模块
111
+ modulesResolved[modulePath] = win[BuiltinModulesGlobalVariableName].modules[modulePath];
112
+ }
106
113
  return;
107
114
  }
108
115
  modulesResolved[modulePath] = moduleContent;