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

Failed to load url virtual:__federation__ with react #494

Closed
husayt opened this issue Sep 13, 2023 · 4 comments
Closed

Failed to load url virtual:__federation__ with react #494

husayt opened this issue Sep 13, 2023 · 4 comments

Comments

@husayt
Copy link

husayt commented Sep 13, 2023

Versions

  • vite-plugin-federation: 1.3.1
  • vite: 4.4.9

Steps to reproduce

using latest dynamic loading example to get react module to load dynamically.
this is the vite.config

export default defineConfig({
  plugins: [
    react(),
    topLevelAwait({
      promiseExportName: "__tla",
      promiseImportName: i => `__tla_${i}`
    }),
    federation({
      name: "mono",
      shared: ["react", "reactDom"]
     }),
   ]
})

What is actually happening?

Getting error message Failed to load url virtual:__federation__ (resolved id: virtual:__federation__)

so app doesn't recognise

import {
  __federation_method_setRemote,
  __federation_method_getRemote,
  __federation_method_unwrapDefault,
} from "virtual:__federation__";

Seems I am missing something

@zhtyytg
Copy link
Contributor

zhtyytg commented Sep 14, 2023

Can you provide a minimal demo?

@husayt
Copy link
Author

husayt commented Sep 14, 2023

this was to wrong configuration, I am not even sure what namely. after going through example again and copying right config it worked.

Thank you.

@husayt husayt closed this as completed Sep 14, 2023
@dk-v
Copy link

dk-v commented Oct 3, 2023

Hi, any chance you could share how you got this working? I've been trying to get dynamic remotes to work with React but I've been unsuccessful so far.

@AmauryD
Copy link

AmauryD commented Jan 18, 2025

Hi, any chance you could share how you got this working? I've been trying to get dynamic remotes to work with React but I've been unsuccessful so far.

Hi! I might be a bit late, but I managed to get it working by configuring the remotes: {} key on the host side. Since all my modules were dynamic, I forgot setting this key. However, this key is crucial for the plugin to distinguish whether a module is a host or a client. On a client, the virtual module is never injected.

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

4 participants