You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

动态模块联邦无法获取remoteEntry导出内容的问题求助

动态模块联邦无法获取remoteEntry导出内容的问题求助

各位大佬好,我正在搭建一个采用动态模块联邦的应用,想用动态模块联邦加载远程组件,但目前遇到了问题——没法获取到remoteEntry导出的内容,想请大家帮忙排查下!

Remote应用配置(由NX生成的webpack.config.ts)

const config: ModuleFederationConfig = {
  name: 'master',
  exposes: {
    './Module': './src/remote-entry.tsx',
  },
};

export default composePlugins(
  withNx(),   
  withReact(),
  withModuleFederation(config, { dts: false })
);

Host应用加载代码

import { init, loadRemote } from '@module-federation/enhanced/runtime';

init({
  name: 'loader',
  remotes: [
    {
      name: 'master',
      entry: 'http://localhost:4202/master/remoteEntry.js',
    },
  ],
});

loadRemote('master/Module').then((value) => console.log(value));

注意:我已经试过直接访问localhost:4202,确认remoteEntry.js是可以正常访问的,而且在浏览器的网络面板里也能看到这个脚本已经被成功请求到了,但就是拿不到导出的内容。

备注:内容来源于stack exchange,提问作者Andrea Costanzo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 07:34:34