我最近制作了一个联合模块主机,用于联合站点的页眉和页脚。一切都按预期工作,但如果对联合主机的请求失败,我会尝试构建一些后备。
new ModuleFederationPlugin({
name: 'app',
remotes: {
app2: 'app2@https:/example.com/remoteEntry.js',
},
shared: { react: { singleton: true, eager: true }, 'react-dom': { singleton: true, eager: true } },
}),
如果我阻止对 https:/example.com/remoteEntry.js 的请求,我会收到下面的 webpack 错误。理想情况下,我想加载一个基本的后备标题,或者只是没有标题,而不是页面完全死掉
(error: https://example.com/remoteEntry.js1)
while loading "./Footer" from webpack/container/reference/app2