@blocklet/pages-kit 0.4.85 → 0.4.86

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.
@@ -77,13 +77,16 @@ export function injectGlobalComponents() {
77
77
  modules,
78
78
  require(module) {
79
79
  // handle builtin module
80
- const builtinModule = this.modules[module];
80
+ const builtinModule = win[BuiltinModulesGlobalVariableName].modules[module];
81
+ const mergeModuleExports = (mod) => ({
82
+ ...(mod.default ? { ...mod.default } : {}),
83
+ ...mod,
84
+ });
85
+ if (builtinModule instanceof Promise) {
86
+ return builtinModule.then(mergeModuleExports);
87
+ }
81
88
  if (builtinModule) {
82
- return {
83
- // 针对某些包,比如 react-dom,需要同时导出 default 和非 default 的值
84
- ...(builtinModule.default ? { ...builtinModule.default } : {}),
85
- ...builtinModule,
86
- };
89
+ return mergeModuleExports(builtinModule);
87
90
  }
88
91
  // handle relative path import
89
92
  if (isRelativeModule(module)) {
@@ -5,7 +5,7 @@ export const isRelativeModule = (moduleSpecifier) => {
5
5
  }
6
6
  return moduleSpecifier.startsWith('./') || moduleSpecifier.startsWith('../');
7
7
  };
8
- export const isAwaitModule = (moduleSpecifier) => {
8
+ export const isAsyncModule = (moduleSpecifier) => {
9
9
  if (!moduleSpecifier) {
10
10
  return false;
11
11
  }
@@ -56,7 +56,7 @@ export const createBuiltinModuleTransformer = (ts) => (context) => (file) => {
56
56
  // call inject-global-components require method
57
57
  const requireCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(BuiltinModulesGlobalVariableName), 'require'), undefined, [factory.createStringLiteral(importInfo.moduleName)]);
58
58
  // create await expression if the module is ../ or ./
59
- const mod = isRelativeModule(importInfo.moduleName) || isAwaitModule(importInfo.moduleName)
59
+ const mod = isRelativeModule(importInfo.moduleName) || isAsyncModule(importInfo.moduleName)
60
60
  ? factory.createAwaitExpression(requireCall)
61
61
  : requireCall;
62
62
  return [