@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
|
@@ -79,7 +79,11 @@ export function injectGlobalComponents() {
|
|
|
79
79
|
// handle builtin module
|
|
80
80
|
const builtinModule = this.modules[module];
|
|
81
81
|
if (builtinModule) {
|
|
82
|
-
return
|
|
82
|
+
return {
|
|
83
|
+
// 针对某些包,比如 react-dom,需要同时导出 default 和非 default 的值
|
|
84
|
+
...(builtinModule.default ? { ...builtinModule.default } : {}),
|
|
85
|
+
...builtinModule,
|
|
86
|
+
};
|
|
83
87
|
}
|
|
84
88
|
// handle relative path import
|
|
85
89
|
if (isRelativeModule(module)) {
|
|
@@ -159,11 +163,20 @@ export function injectGlobalComponents() {
|
|
|
159
163
|
const imports = Object.entries(modulesResolved).reduce((acc, [modulePath, moduleContent]) => {
|
|
160
164
|
const moduleContentResolved = moduleContent;
|
|
161
165
|
const namedExports = Object.keys(moduleContentResolved).filter((key) => key !== 'default');
|
|
166
|
+
const namedExportsMap = namedExports.reduce((acc, key) => {
|
|
167
|
+
acc[key] = moduleContentResolved[key];
|
|
168
|
+
return acc;
|
|
169
|
+
}, {});
|
|
162
170
|
const hasDefaultExport = 'default' in moduleContentResolved;
|
|
171
|
+
// default exports 优先级低于 named exports
|
|
172
|
+
const defaultExports = hasDefaultExport
|
|
173
|
+
? Object.keys(moduleContentResolved.default).filter((key) => !namedExportsMap[key])
|
|
174
|
+
: [];
|
|
163
175
|
// create module code
|
|
164
176
|
const moduleCode = `// GENERATED FILE. DO NOT EDIT.
|
|
165
177
|
const moduleSource = window['${BuiltinModulesGlobalVariableName}'].modules['${modulePath}'];
|
|
166
178
|
${namedExports.map((name) => `export const ${name} = moduleSource['${name}'];`).join('\n')}
|
|
179
|
+
${defaultExports.map((name) => `export const ${name} = moduleSource.default['${name}'];`).join('\n')}
|
|
167
180
|
export default ${hasDefaultExport ? 'moduleSource.default' : 'moduleSource'};
|
|
168
181
|
`;
|
|
169
182
|
// create base64 code
|