最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Creating Micro-frontend application in nextjs using webpack - Stack Overflow

programmeradmin1浏览0评论

I am using nextjs@14 version.

here is my next.config.mjs

export default (phase, { defaultConfig }) => {
  //console.log('defaultConfig =>', defaultConfig);
  /**
   * @type {import('next').NextConfig}
   */
  const nextConfig = {
    ...defaultConfig,
    webpack(config, { isServer }) {
      config.plugins.push(
        new ModuleFederationPlugin({
          name: 'remoteApp',
          filename: 'static/remoteEntry.js',
          exposes: {
            './Button': './pages/components/Button',
            // Add more components as needed
          },
          shared: {
            react: { singleton: true, eager: true },
            'react-dom': { singleton: true, eager: true },
          }
        })
      )
      return config;
    }
  }

  return nextConfig
}

I am facing below error

[email protected] dev next dev

▲ Next.js 14.2.16

  • Local: http://localhost:3000

✓ Starting... TypeError: The 'compilation' argument must be an instance of Compilation at ModuleFederationPlugin.getCompilationHooks (D:\development\shell-app3\node_modules\webpack\lib\container\ModuleFederationPlugin.js:58:10) at D:\development\shell-app3\node_modules\webpack\lib\container\HoistContainerReferencesPlugin.js:36:33 at Hook.eval [as call] (eval at create (D:\development\shell-app3\node_modules\next\dist\compiled\webpack\bundle5.js:13:28636), :35:1) at Hook.CALL_DELEGATE [as _call] (D:\development\shell-app3\node_modules\next\dist\compiled\webpack\bundle5.js:13:25906) at Compiler.newCompilation (D:\development\shell-app3\node_modules\next\dist\compiled\webpack\bundle5.js:28:147853) at D:\development\shell-app3\node_modules\next\dist\compiled\webpack\bundle5.js:28:148673 at Hook.eval [as callAsync] (eval at create (D:\development\shell-app3\node_modules\next\dist\compiled\webpack\bundle5.js:13:28858), :6:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\development\shell-app3\node_modules\next\dist\compiled\webpack\bundle5.js:13:26012) at Compilerpile (D:\development\shell-app3\node_modules\next\dist\compiled\webpack\bundle5.js:28:148599) at D:\development\shell-app3\node_modules\next\dist\compiled\webpack\bundle5.js:28:491794

发布评论

评论列表(0)

  1. 暂无评论