@blocklet/pages-kit 0.4.64 → 0.4.66
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/lib/cjs/builtin/react-dom.js +13 -8
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/inject-global-components.js +14 -1
- package/lib/esm/builtin/react-dom.js +1 -2
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/inject-global-components.js +14 -1
- package/lib/types/builtin/react-dom.d.ts +1 -2
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -108,7 +108,11 @@ function injectGlobalComponents() {
|
|
|
108
108
|
// handle builtin module
|
|
109
109
|
const builtinModule = this.modules[module];
|
|
110
110
|
if (builtinModule) {
|
|
111
|
-
return
|
|
111
|
+
return {
|
|
112
|
+
// 针对某些包,比如 react-dom,需要同时导出 default 和非 default 的值
|
|
113
|
+
...(builtinModule.default ? { ...builtinModule.default } : {}),
|
|
114
|
+
...builtinModule,
|
|
115
|
+
};
|
|
112
116
|
}
|
|
113
117
|
// handle relative path import
|
|
114
118
|
if ((0, builtin_module_transformer_1.isRelativeModule)(module)) {
|
|
@@ -188,11 +192,20 @@ function injectGlobalComponents() {
|
|
|
188
192
|
const imports = Object.entries(modulesResolved).reduce((acc, [modulePath, moduleContent]) => {
|
|
189
193
|
const moduleContentResolved = moduleContent;
|
|
190
194
|
const namedExports = Object.keys(moduleContentResolved).filter((key) => key !== 'default');
|
|
195
|
+
const namedExportsMap = namedExports.reduce((acc, key) => {
|
|
196
|
+
acc[key] = moduleContentResolved[key];
|
|
197
|
+
return acc;
|
|
198
|
+
}, {});
|
|
191
199
|
const hasDefaultExport = 'default' in moduleContentResolved;
|
|
200
|
+
// default exports 优先级低于 named exports
|
|
201
|
+
const defaultExports = hasDefaultExport
|
|
202
|
+
? Object.keys(moduleContentResolved.default).filter((key) => !namedExportsMap[key])
|
|
203
|
+
: [];
|
|
192
204
|
// create module code
|
|
193
205
|
const moduleCode = `// GENERATED FILE. DO NOT EDIT.
|
|
194
206
|
const moduleSource = window['${builtin_1.BuiltinModulesGlobalVariableName}'].modules['${modulePath}'];
|
|
195
207
|
${namedExports.map((name) => `export const ${name} = moduleSource['${name}'];`).join('\n')}
|
|
208
|
+
${defaultExports.map((name) => `export const ${name} = moduleSource.default['${name}'];`).join('\n')}
|
|
196
209
|
export default ${hasDefaultExport ? 'moduleSource.default' : 'moduleSource'};
|
|
197
210
|
`;
|
|
198
211
|
// create base64 code
|