оболочка: < /p>
const { withModuleFederationPlugin, shareAll } = require('@angular-architects/module-federation/webpack');
const config = withModuleFederationPlugin({
name: 'host',
exposes: {},
remotes: {
blog: 'blog@localhost:4201/remoteEntry.js',
},
shared: {
}
});
config.output.uniqueName = 'shell';
config.optimization.runtimeChunk = false;
module.exports = config;
< /code>
remote: < /p>
const { withModuleFederationPlugin } = require('@angular-architects/module-federation/webpack');
const config = withModuleFederationPlugin({
name: 'blog',
filename: 'remoteEntry.js',
exposes: {
'./BlogLandingPageComponent': './projects/blog/src/app/blog/blog-landing-page/blog-landing-page.component',
'./BlogService': './projects/blog/src/app/blog/blog.service',
},
shared: {
},
remoteType: 'var',
library: {
type: 'var',
name: 'blog'
},
});
config.output = {
chunkFormat: 'array-push',
chunkLoading: 'jsonp',
uniqueName: 'blog',
publicPath: "auto", // Use auto public path for dynamic loading
scriptType: 'text/javascript'
};
config.optimization = {
runtimeChunk: false,
};
module.exports = config;
< /code>
Затем, в моем Main.ts я пытаюсь инициализировать удаленное подобное: < /p>
Promise.all([
loadRemoteEntry({
type: 'script',
remoteEntry: "http://localhost:4201/remoteEntry.js",
remoteName: 'blog'
}),
])
.catch((err) => console.error('Error loading remote entries', err))
.then((val) => {
console.log('Remote entry loaded successfully:', val);
// Check if the remote container is available
if (window['blog']) {
console.log('
} else {
console.error('
}
if (document.readyState === 'complete') {
bootstrap();
} else {
document.addEventListener('DOMContentLoaded', bootstrap);
}
})
< /code>
Комментируя метод LoadRemoteEntry. Цикл обновления исчезает. Это проблема HMR (Hot Module Reloading)?
Подробнее здесь: https://stackoverflow.com/questions/797 ... ite-reload