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

v1.0.0: Error with Nuxt as host app #73

Open
David-Sellen opened this issue Sep 2, 2024 · 18 comments
Open

v1.0.0: Error with Nuxt as host app #73

David-Sellen opened this issue Sep 2, 2024 · 18 comments

Comments

@David-Sellen
Copy link
Contributor

David-Sellen commented Sep 2, 2024

Hi there!

I have a Nuxt application acting as host and to load remote client side Vue apps. Currently we're using @originjs/vite-plugin-federation which works OK but we would like to migrate to this library instead for other reasons.

I'm trying out @module-federation/[email protected] and it works well when i test it on my simple Vue SPA host but not when I'm trying to replace the OriginJS plugin in our Nuxt host application.

I get the following error in the browser and when I check the network traffic it does not load the RemoteEntyr.js.

Uncaught (in promise) Error: [ Federation Runtime ]: Please call init first
    at error2 (share.cjs.js:26:11)
    at Object.assert2 [as assert] (share.cjs.js:18:9)
    at loadRemote (index.cjs.js:2137:11)
    at myremote_app.js:3:32

The Vite settings in the Nuxt.config

...
vite: {
    plugins: [
      federation({
        name: "ssr-host",
        remotes: {
          myremote: {
            name: "myremote",
            shareScope: "myremote",
            entry: "/assets/remoteEntry.js",
            entryGlobalName: "myremote",
            type: "module",
          },
        },
        filename: "remoteEntry.js",
        runtimePlugins: ["./mfPlugin"], // From your example. only contains console.logs.
      })
    ],
    build: {
      target: "chrome89",
      rollupOptions: {
        output: {
          manualChunks(id) {
            if (id.indexOf("/@module-federation/runtime") > -1) {
              return "mfruntime";
            }
          },
        },
      },
    },

Might there be something in this library that does not support this approach or do you guys have something that I can try out to make it work?

@zhangHongEn
Copy link
Contributor

The entry insertion code may not take into account the SSR application. I will fix it later.

@gioboa
Copy link
Collaborator

gioboa commented Sep 2, 2024

@David-Sellen thanks for your feedback. Can I ask you to add a Nuxt example please? You can add it next to the other ones. Appreciate

@zhangHongEn
Copy link
Contributor

SSR requires me to complete manifest.json in advance, which is originally on the roadmap, This will take some time, I will finish it this week

 WARN  [ Federation Runtime ]: [ Federation Runtime ]: Failed to get manifestJson for @namespace/viteViteRemote. The manifest URL is http://localhost:5176/.vite/manifest.json. Please ensure that the manifestUrl is accessible.
          
 Error message:
          
 Error: [ Federation Runtime ]: http://localhost:5176/.vite/manifest.json is not a federation manifest

  
  Error message:
  
  Error: [ Federation Runtime ]: http://localhost:5176/.vite/manifest.json is not a federation manifest

@zhangHongEn
Copy link
Contributor

The demo can be created, I will fix it this week

@David-Sellen
Copy link
Contributor Author

That sounds great @zhangHongEn ! I created a small Nuxt example here: https://github.com/David-Sellen/vite/tree/73-error-with-nuxt-as-host-app @gioboa

@gioboa
Copy link
Collaborator

gioboa commented Sep 3, 2024

Thanks @David-Sellen 👏

@zhangHongEn
Copy link
Contributor

image

I used the code of nuxt remote client in nuxt host server, and got this result as expected. Next, I need to find time to check how rust and webpack handle ssr.

This problem is more complicated and should take more time.

zhangHongEn pushed a commit to zhangHongEn/vite that referenced this issue Sep 8, 2024
@gioboa
Copy link
Collaborator

gioboa commented Sep 15, 2024

Closed by #86

@gioboa gioboa closed this as completed Sep 15, 2024
@zhangHongEn
Copy link
Contributor

zhangHongEn commented Sep 15, 2024 via email

@gioboa gioboa reopened this Sep 15, 2024
@husayt
Copy link
Contributor

husayt commented Sep 26, 2024

Also tried to get this working, but still not working.
@zhangHongEn there is an asyncentry setting in nuxt you might find useful

https://nuxt.com/docs/guide/going-further/experimental-features#asyncentry

@zhangHongEn
Copy link
Contributor

zhangHongEn commented Sep 26, 2024

Also tried to get this working, but still not working. @zhangHongEn there is an asyncentry setting in nuxt you might find useful

https://nuxt.com/docs/guide/going-further/experimental-features#asyncentry

nuxt should wait for rolldown support

@gioboa
Copy link
Collaborator

gioboa commented Sep 26, 2024

Hey @David-Sellen , thanks for opening this issue, and for the examples.
I'm closing this issue for now because we need to wait for rolldown support. Thanks.

@gioboa gioboa closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2024
@husayt
Copy link
Contributor

husayt commented Sep 26, 2024

@gioboa @zhangHongEn why do we need rolldown for this? let's keep the issue open, as nuxt support will pave the way for many others like Analog, solidstart as they also use nitro.

@gioboa gioboa reopened this Sep 26, 2024
@husayt
Copy link
Contributor

husayt commented Sep 26, 2024

yesterday, I spent 5 hours trying to get that working and would love to see that happen, just for the sake of those hours 😅

@danya-rnd
Copy link

Hi! Why we have different errors?:D

I appreciate if Nuxt support will be available in the closest time. But I'm trying to use simple Vite app inside Nuxt.

image

@gioboa
Copy link
Collaborator

gioboa commented Oct 4, 2024

I tried to test Nuxt MFE with Vite remote and I added a console.log for the loading remote.
It's not waiting for the promise.
image

@danya-rnd
Copy link

So do you have any ideas how to fix it at this moment?
As I can see this issue is marked as "Blocked by another PR" but all PRs inside this thread are already merged.

Nuxt support is really must have:)

@zhangHongEn
Copy link
Contributor

There are still some unresolved issues: nuxt/nuxt#28911. The most important thing is that I really don’t have time recently. I will continue working on it when I have some free time, but it won’t be very soon.

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

No branches or pull requests

5 participants