基于Nx的React微前端Webpack Module Federation报fn不是函数错误
Nx React微前端启动报错:TypeError: fn is not a function
我使用Nx工具创建了React微前端应用,启动时触发错误:TypeError: fn is not a function,该错误在加载来自8640的./Module时出现。
我的Webpack配置如下:
const { ModuleFederationPlugin } = require('webpack').container; const nrwlConfig = require('@nrwl/react/plugins/webpack.js'); module.exports = (config, context) => { nrwlConfig(config); return { ...config, plugins: [ ...config.plugins, new ModuleFederationPlugin({ name: 'cart', filename: 'remoteEntry.js', exposes: { './Module': './src/remote-entry.ts', }, }), ], }; };
我已查阅Webpack官方文档相关说明,但未能找到可行解决方案。
复现步骤
- 获取对应代码仓库代码
- 执行命令
npm install - 执行命令
npm run start - 打开
http://localhost:4200/cart并开启开发者控制台
需要检查的文件:apps\cart\webpack.config.js
内容的提问来源于stack exchange,提问作者webDev_434
相关产品推荐
相关产品推荐

