module-federation-examples icon indicating copy to clipboard operation
module-federation-examples copied to clipboard

Is there no more correct solution for next.js with ssr?

Open micro-chipset opened this issue 4 years ago • 15 comments

Is there no hack-free solution https://github.com/module-federation/module-federation-examples/blob/master/nextjs-ssr/host/next.config.js

        remoteLib: isServer
          ? "remoteLib@http://localhost:3002/node/remoteEntry.js"
          : //This is a hack (I cannot run successfully MF in client-side with NextJS and React, maybe doing smth wrong)
            {
              external: `external new Promise((r, j) => {
              window['remoteLib'].init({
                react: {
                  "${packageJsonDeps.react}": {
                    get: () => Promise.resolve().then(() => () => globalThis.React),
                  }
                }
              });
              r({
                get: (request) => window['remoteLib'].get(request),
                init: (args) => {}
              });
            })`,
            },
        // : "remoteLib@http://localhost:3001/remoteEntry.js",
      },```

micro-chipset avatar Aug 17 '21 17:08 micro-chipset

bump

wibed avatar Aug 20 '21 10:08 wibed

Yes there is but it's not open source and requires a paid workshop.

ScriptedAlchemy avatar Aug 24 '21 09:08 ScriptedAlchemy

Take a look at this issue https://github.com/telenko/node-mf-example/issues/2

telenko avatar Aug 26 '21 08:08 telenko

https://scriptedalchemy.medium.com/next-js-11-module-federation-and-ssr-a-whole-new-world-6da7641a25b4

ScriptedAlchemy avatar Aug 27 '21 23:08 ScriptedAlchemy

For the SSR variant, there is only a paid workshop and no code examples.

micro-chipset avatar Aug 28 '21 07:08 micro-chipset

Correct. You can use the code streaming plugin mentioned in this issue. But the fetch() system is pay to play. The source is only available to those who go to the workshop.

It was hard to solve, took us months

ScriptedAlchemy avatar Aug 30 '21 07:08 ScriptedAlchemy

Close to releasing SSR support as a plugin for next. Already in production and should go into open beta soon

ScriptedAlchemy avatar Jan 13 '22 06:01 ScriptedAlchemy

PR open for SSR support, however the plugin powering it is a closed beta for the time being while it undergoes testing.

https://github.com/module-federation/module-federation-examples/pull/1468

ScriptedAlchemy avatar Jan 19 '22 03:01 ScriptedAlchemy

@ScriptedAlchemy Will there public version?

micro-chipset avatar Jan 21 '22 12:01 micro-chipset

Unlikely. Too expensive to build and support for free unfortunately

ScriptedAlchemy avatar Mar 26 '22 20:03 ScriptedAlchemy

plugin has been released: https://app.privjs.com/buy/packageDetail?pkg=@module-federation/nextjs-ssr

ScriptedAlchemy avatar Apr 29 '22 05:04 ScriptedAlchemy

Is there a trial that I can try or any live version to see if it is working?

prudhvitesting avatar May 06 '22 04:05 prudhvitesting

Email/DM me and that can be arranged.

https://next-federation-reference-architecture-checkout.vercel.app/ https://next-federation-reference-architecture-home.vercel.app/ https://next-federation-reference-architecture-shop.vercel.app/

ScriptedAlchemy avatar May 09 '22 05:05 ScriptedAlchemy

@ScriptedAlchemy , the three demo sites above seem to be broken.

cwoolum avatar Jun 24 '22 16:06 cwoolum

Yeah the core code has changed quite a bit and I’ve been focusing on internal app upgrades. im refreshing the implementation now to bring everything back up. It’s several releases behind right now, but I’ve got it up locally again so likely just need to redeploy the apps with the new plugin code

ScriptedAlchemy avatar Jun 28 '22 07:06 ScriptedAlchemy

module-federation/node module-federation/nextjs-mf

ScriptedAlchemy avatar Sep 29 '22 00:09 ScriptedAlchemy