umijs / umi

A framework in react community ✨
https://umijs.org
MIT License
15.4k stars 2.65k forks source link

[Bug] umi3升级到umi4,chainWebpack配置模块联邦产出的文件格式不同 紧急 #12720

Open liyang1234567890 opened 1 month ago

liyang1234567890 commented 1 month ago
这是我的chainWebpack配置
  chainWebpack(memo, { env, webpack, createCSSRule }) {
    memo.plugin('module-federation').use(
      new webpack.container.ModuleFederationPlugin({
        name: 'abtest',
        filename: 'remoteEntry.js',
        exposes: {
          './dataset_list': './src/pages/dataset/exposes/list.tsx',
          './dataset_config': './src/pages/dataset/exposes/config.tsx',
        },
        library: { type: 'var', name: 'abtest' },
      }),
    );
  }

在umi3项目中生成的remoteEntry.js文件 umi3

umi4项目中生成的remoteEntry.js文件 umi4

导致现在在远程应用中获取不到window.abtest,报错_virtual_federation.a5d80c56.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'init'),无法正常展示页面 报错

求回复,感谢

stormslowly commented 1 month ago

觉得你可能需要修改这个配置 https://webpack.js.org/configuration/output/#outputlibrarytype