Skip to content

Commit

Permalink
fix: flatten module return function when module default is function (#…
Browse files Browse the repository at this point in the history
…538)

* fix: flatten module return function when module default is function

* fix: update moduleCache before return
  • Loading branch information
unformalized authored Nov 20, 2023
1 parent 7b88529 commit d60c019
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/lib/src/prod/federation_fn_import.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ async function getSharedFromLocal(name) {
}
}
function flattenModule(module, name) {
// use a shared module which export default a function will getting error 'TypeError: xxx is not a function'
if (typeof module.default === 'function') {
Object.keys(module).forEach((key) => {
if (key !== 'default') {
module.default[key] = module[key]
}
})
moduleCache[name] = module.default
return module.default
}
if (module.default) module = Object.assign({}, module.default, module)
moduleCache[name] = module
return module
Expand Down

0 comments on commit d60c019

Please sign in to comment.