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

Can I use with vite-plugin-federation as a remote application? #3259

Open
5 tasks done
dante01yoon opened this issue Nov 20, 2024 · 5 comments
Open
5 tasks done

Can I use with vite-plugin-federation as a remote application? #3259

dante01yoon opened this issue Nov 20, 2024 · 5 comments

Comments

@dante01yoon
Copy link

dante01yoon commented Nov 20, 2024

Describe the bug

Versions

For Vite config

  • vite-plugin-federation: v1.3.6
  • vite: 5.0.6

For webpack config

  • @module-federation/enhanced0.7.5

Reproduction

can not import vite remote app in webpack host app.

Not sure this is related with vite plugin, can not use with webpack host app

e:  Error: [ Federation Runtime ]: Failed to get remoteEntry exports. #RUNTIME-001
args: {"remoteName":"myRemoteApp","remoteEntryUrl":"

this is vite config from remote app

federation({
        name: 'myRemoteApp',
        filename: 'remoteEntry.js',
        remotes: {
          'myHostApp': '/resources/something/host',
        },
        exposes: {
          './Spinner': './src/components/Spinner.vue',
        },
        shared: ['vue', 'pinia', 'vue-router'],
      }),

and this is host app actually import - using vue2

import { init, loadRemote } from '@module-federation/runtime';


    const instance = init({
      name: "myHostApp",
      remotes: [
        {
          name: "myRemoteApp",
          entry: "/resources/my-remote-app/assets/remoteEntry.js",
        },
      ]
    })

export default {
  // ... 
  async mounted() {
    const modules = await loadRemote('myRemoteApp/Spinner');
  }
}
e:  Error: [ Federation Runtime ]: Failed to get remoteEntry exports. #RUNTIME-001
args: {"remoteName":"myRemoteApp","remoteEntryUrl":"

Reproduction

sorry, it's enterprise

Used Package Manager

pnpm

System Info

Chrome 130.0.6723.92 (arm64)
Mac OSX

node 20.10 MacBook Pro 14 - OS 15.0.1

Validations

@ScriptedAlchemy
Copy link
Member

ScriptedAlchemy commented Nov 21, 2024

https://module-federation.io/guide/basic/vite.html

in init, remote needs type:module so that runtime knows if its script or esm module and how to handle it accordingly, otherwise it will assume its a script

Must use the implementation from federation organization. Any third party won't work

@dante01yoon
Copy link
Author

@ScriptedAlchemy Oh, so cross organization library won't cover this cases 😓

@ScriptedAlchemy
Copy link
Member

Unlikely. V2 is based on our new runtime. Vite, rspack, rollup etc all implement the central runtime. You can try setting the remote Type to module on the MF plugin and that may work. But generally these forks were never compliant with our designs and just replicated some interfaces, that said our vite plugin should work just fine because it's implemented to our specs and we still control the runtime itself

@DeveshSapkale
Copy link

@ScriptedAlchemy For build time plugin we can for sure use your above suggestion to add type:module when we enroll the remotes.

But what should be done in case of advance api example?
I see the solution is to add type property with either 'module' or 'esm' when invoking registerRemotes ().

But if we have let's say

  1. rspack host
  2. vite remote (using module-federation/vite)
  3. webpack remote
  4. rspack remote

And I want to use module federation runtime apis registerRemote and load remote.
I get details about remote like remote entry url using a fetch call...
But how can I determine in this case that if remote is ESM or script? Because host is unaware of what tools remote might be using.
I am really stuck at this point how can I determine this remote type dynamically?

@ScriptedAlchemy
Copy link
Member

ScriptedAlchemy commented Nov 26, 2024

You would know up front when you call register remote. Otherwise you may have more luck with the json remotes. They should contain the module type.

Read the docs about the manifest protocol

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

3 participants