Skip to content

Commit

Permalink
fix: Flatten module with default exports when available (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
MauriceAyasse authored Sep 24, 2023
1 parent 055c759 commit 0bc4f8e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/lib/src/prod/federation_fn_import.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,24 @@ async function getSharedFromRuntime(name, shareScope) {
}
}
if (module) {
if (module.default && Object.keys(module).length < 2)
module = module.default
moduleCache[name] = module
return module
return flattenModule(module, name)
}
}
async function getSharedFromLocal(name) {
if (moduleMap[name]?.import) {
let module = await (await moduleMap[name].get())()
if (module.default && Object.keys(module).length < 2)
module = module.default
moduleCache[name] = module
return module
return flattenModule(module, name)
} else {
console.error(
`consumer config import=false,so cant use callback shared module`
)
}
}
function flattenModule(module, name) {
if (module.default) module = Object.assign({}, module.default, module)
moduleCache[name] = module
return module
}
export {
importShared,
getSharedFromRuntime as importSharedRuntime,
Expand Down

0 comments on commit 0bc4f8e

Please sign in to comment.