-
Notifications
You must be signed in to change notification settings - Fork 86
Description
Describe the bug
Hey folks! I haven't used Module Federation since experimenting with it in its early days, and have a use-case now, so I thought I'd start prototyping. I created 2 apps, both with the same stack (TanStack Query + Router, Vite):
- host (offering an app shell + routing, host application, runs on port 5175)
- hello-world (a simple hello-world component, a remote, runs on port 4173, exposes mf-manifest.json)
I'm not using runtime or dynamic stuff, just a straight up import HelloWorld from 'hello-world/HelloWorld';. When I try to vier my app in browser, it seems as though Module Federation is confused:
It tries to load the assets/remoteEntry-CdYN5o5R.js from 5175 instead of 4173, so it 404s, which then leads to the remoteEntryExports being undefined.
If I change my host to load assets/remoteEntry-CdYN5o5R.js instead of mf-manifest.json instead, it kind of works, but I still get the following errors:
This is also kind of undesirable, as I'd have to keep track of hashes somehow, rather than just pointing to mf-manifest & letting that figure it out for me...
Am I missing something? I've upgraded everything in host & hello-world to latest versions of all dependencies (with npx npm-check-updates).
Version
6.2.0
Reproduction
It's literally the most basic example I can think of...
Relevant log output
Remote Config:
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { federation } from '@module-federation/vite';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
federation({
name: 'hello-world',
manifest: true,
exposes: {
'./HelloWorld': './src/components/HelloWorld.tsx',
'./routes': './src/routes/index.tsx',
},
shared: ['react', 'react-dom', '@tanstack/react-router'],
}),
],
build: {
target: 'esnext',
minify: false,
},
});Host config:
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { federation } from '@module-federation/vite';
import path from 'path';
export default defineConfig({
plugins: [
federation({
name: 'host',
remotes: {
'hello-world': {
name: 'hello-world',
type: 'module',
entry: 'http://localhost:4173/mf-manifest.json',
}
},
shared: ['react', 'react-dom', '@tanstack/react-query']
}),
react()
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
},
build: {
modulePreload: false,
target: 'esnext',
minify: false,
cssCodeSplit: false
}
});The generated mf-manifest.json:
{
"id": "hello-world",
"name": "hello-world",
"metaData": {
"name": "hello-world",
"type": "app",
"buildInfo": { "buildVersion": "1.0.0", "buildName": "hello-world" },
"remoteEntry": {
"name": "assets/remoteEntry-D0hsAXHw.js",
"path": "",
"type": "module"
},
"ssrRemoteEntry": {
"name": "assets/remoteEntry-D0hsAXHw.js",
"path": "",
"type": "module"
},
"types": { "path": "", "name": "" },
"globalName": "hello-world",
"pluginVersion": "0.2.5",
"publicPath": "/"
},
"shared": [
{
"id": "hello-world:@tanstack/react-router",
"name": "@tanstack/react-router",
"version": "1.111.11",
"requiredVersion": "^1.111.11",
"assets": {
"js": {
"async": [],
"sync": [
"assets/index-Bk4i2veO.js",
"assets/jsx-runtime-DtXR568w.js",
"assets/hello_mf_2_world__loadShare__react__loadShare__-BU5ovZIB.js",
"assets/hello_mf_2_world__mf_v__runtimeInit__mf_v__-Dfj3CfpL.js",
"assets/hello_mf_2_world__loadShare__react_mf_2_dom__loadShare__-dlIcOtSS.js"
]
},
"css": { "async": [], "sync": [] }
}
},
{
"id": "hello-world:react",
"name": "react",
"version": "19.0.0",
"requiredVersion": "^19.0.0",
"assets": {
"js": {
"async": [],
"sync": [
"assets/index-CWTAqxGv.js",
"assets/_commonjsHelpers-B85MJLTf.js"
]
},
"css": { "async": [], "sync": [] }
}
},
{
"id": "hello-world:react-dom",
"name": "react-dom",
"version": "19.0.0",
"requiredVersion": "^19.0.0",
"assets": {
"js": {
"async": [],
"sync": [
"assets/index-D4xJte0W.js",
"assets/_commonjsHelpers-B85MJLTf.js",
"assets/hello_mf_2_world__loadShare__react__loadShare__-BU5ovZIB.js",
"assets/hello_mf_2_world__mf_v__runtimeInit__mf_v__-Dfj3CfpL.js"
]
},
"css": { "async": [], "sync": [] }
}
}
],
"remotes": [],
"exposes": [
{
"id": "hello-world:HelloWorld",
"name": "HelloWorld",
"assets": {
"js": {
"async": [],
"sync": [
"assets/HelloWorld-D5KLP__Z.js",
"assets/jsx-runtime-DtXR568w.js"
]
},
"css": { "sync": [], "async": [] }
},
"path": "./HelloWorld"
},
{
"id": "hello-world:routes",
"name": "routes",
"assets": {
"js": {
"async": [],
"sync": [
"assets/index-BiBtT30k.js",
"assets/hello_mf_2_world__mf_v__runtimeInit__mf_v__-Dfj3CfpL.js",
"assets/jsx-runtime-DtXR568w.js",
"assets/HelloWorld-D5KLP__Z.js"
]
},
"css": { "sync": [], "async": [] }
},
"path": "./routes"
}
]
}
Validations
- Read the docs.
- Read the common issues list.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible example of the bug.

