Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextjs mf does not generate remoteEntry.js #3845

Closed
tryptamine25 opened this issue May 2, 2024 · 6 comments
Closed

nextjs mf does not generate remoteEntry.js #3845

tryptamine25 opened this issue May 2, 2024 · 6 comments

Comments

@tryptamine25
Copy link

tryptamine25 commented May 2, 2024

I was using nextjs as a host application, but it got so bad - any changes require a reboot of the dev server, during the build on the server memory consumption went from 2gb to 10gb, that I decided to try to use nextjs application as a remote application.
Here is my next.config.js:

/** @type {import('next').NextConfig} */
const NextFederationPlugin = require('@module-federation/nextjs-mf');

const nextConfig = ({
  reactStrictMode: false,
  swcMinify: true,
  basePath: '/new',
  env: {
    NEXT_PUBLIC_FRONTOFFICE_OPENAPI_URL: process.env.NEXT_PUBLIC_FRONTOFFICE_OPENAPI_URL,
    NEXT_PUBLIC_FRONTOFFICE_CLIENT_API_URL: process.env.NEXT_PUBLIC_FRONTOFFICE_CLIENT_API_URL,
    EDO_LIGHT_API_URL: process.env.EDO_LIGHT_API_URL
  },
  module: {
    parser: {
      javascript: {
        dynamicImportMode: "eager"
      }
    }
  },
  webpack: (config) => {
    config.plugins.push(
      new NextFederationPlugin({
        name: "FrontOffice",
        filename: 'static/chunks/remoteEntry.js',
        exposes: {
          "./FrontOffice": "./pages/_app",
        },
        remotes: {
          "Stepper": `Stepper@${process.env.STEPPER_HOST}/remoteEntry.js`,
          "Payments": `FrontOfficePayments@${process.env.PAYMENTS_HOST}/remoteEntry.js`,
        },
      })
    );
    return config;
  },
  async redirects() {
    return [
      {
        source: '/profile',
        destination: '/profile/customer',
        permanent: false,
      },
      {
        source: '/',
        destination: '/profile',
        permanent: false,
        has: [
          {
            type: 'cookie',
            key: 'auth.accessToken',
          }
        ]
      },
      {
        source: '/profile/payments/payroll',
        destination: '/profile/payments',
        permanent: false,
      },
      {
        source: '/profile/payments/direct-payments',
        destination: '/profile/payments',
        permanent: false,
      },
    ];
  }
});

module.exports = nextConfig;

And at http://localhost:3000/new/static/chunks/remoteEntry.js
Or http://localhost:3000/static/chunks/remoteEntry.js I get a 404 error

"next": "12.2.5",
"@module-federation/nextjs-mf": "^7.0.8",
"webpack": "^5.89.0"

@ScriptedAlchemy
Copy link
Member

use nextjs-mf v8

I recommend against next with module federation under any circumstance

@tryptamine25
Copy link
Author

@ScriptedAlchemy I tried the latest version of nextmf and I get the error - "No ModuleFederationPlugin(s) found.
Error: Cannot find module '/Users/alex/Documents/work/frontofficereact/node_modules/next/dist/compiled/lib/util/makeSerializable'"

@tryptamine25
Copy link
Author

@ScriptedAlchemy i read this - module-federation/core#1961 , but im work on macos

@tryptamine25
Copy link
Author

upgrading next version for 13.5.6 - not solved problem

@ScriptedAlchemy
Copy link
Member

@ScriptedAlchemy ScriptedAlchemy closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2024
@tryptamine25
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants