zhangHongEn / universal-module-federation-plugin

Versioned remote module manager based on npm and module-federation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

exception: customContainer.init is not a function

junxiongchu opened this issue · comments

remotes[global] = {
url,
shareScope,
container: null,
containerPromise: Promise.resolve(useLoadScript(url))
.then(customContainer => {
var container = customContainer || _global[global]
_global[global] = _global[global] || container
if (!container) {
if (!container) throw new Error(not found container from global["${global}"])
}
remotes[global].container = container
return container.init(shareScopes[shareScope])
})
}

export default function loadScript(url) {
const {
promise,
reject,
resolve
} = getPromise()
const element = document.createElement('script');
element.src = url;
element.type = 'text/javascript';
element.async = true;
element.onload = () => {
resolve(element)
};
element.onerror = () => {
reject(element)
};
try {
return promise
} finally {
document.head.appendChild(element);
}
}

after exec Promise.resolve(useLoadScript(url)), found the customContainer was script dom, the useLoadScript function resolve a element dom obj, at the end of containerPromise but to call customContainer init function, at this time exception happened, customContainer.init was not a function, it as expected when i assign the variable container equal _global[global]

commented

fixed in module-federation-runtime@1.1.8

fixed in module-federation-runtime@1.1.8

1.1.8 is ok