#7105·ice

怎么支持 module-federation2 的能力?

Author: senw18Created Jun 4, 2025Updated Oct 16, 2025
javascript
import { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';

export default defineConfig(() => ({
  webpack: (config) => {
      config.plugins?.push(
        new ModuleFederationPlugin({
          name: 'copilotkit',
          exposes: {
            './CopilotInput': './src/components/CopilotInput.tsx',
          },
          shared: {
            react: { singleton: true },
            'react-dom': { singleton: true },
          },
        })
      );
      return config;
  }
}))

上面的代码配置会有报错

Build Error TypeError: Cannot read properties of undefined (reading 'run') at outputDir (file:///Users/wu/app/copilotkit/node_modules/.pnpm/@[email protected]_react-dom@[email protected]__react@18.3.1/node_modules/@ice/app/esm/bundler/webpack/build.js:18:18) at new Promise ()