From d60c019b288eb00337e38661985850bf8b426d34 Mon Sep 17 00:00:00 2001 From: liubin <1419831251@qq.com> Date: Mon, 20 Nov 2023 16:01:14 +0800 Subject: [PATCH] fix: flatten module return function when module default is function (#538) * fix: flatten module return function when module default is function * fix: update moduleCache before return --- packages/lib/src/prod/federation_fn_import.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/lib/src/prod/federation_fn_import.js b/packages/lib/src/prod/federation_fn_import.js index 55b1b1a6..9cb8194d 100644 --- a/packages/lib/src/prod/federation_fn_import.js +++ b/packages/lib/src/prod/federation_fn_import.js @@ -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