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

[Bug]: Error [ Federation Runtime ]: [ Federation Runtime ]: The attribute remoteEntry of tasks must not be undefined. #6647

Open
VictorPulzz opened this issue Dec 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@VictorPulzz
Copy link

VictorPulzz commented Dec 19, 2024

Version

System:
    OS: macOS 14.0
    CPU: (8) arm64 Apple M1
    Memory: 59.31 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 131.0.6778.141
    Safari: 17.0

Details

Hello dear devs!
I was planning to do it this way:
I have a host application modern.js
And there are some microfronts built on rsbuild.
And I wanted to connect them to each other.
Here is my config for rsbuild (just standard as from documentation + module federation)

rsbuild.config.ts

import {defineConfig} from '@rsbuild/core';
import {pluginReact} from '@rsbuild/plugin-react';
import {pluginSass} from '@rsbuild/plugin-sass';
import {pluginModuleFederation} from "@module-federation/rsbuild-plugin";

export default defineConfig({
  plugins: [
    pluginReact(),
    pluginSass(),
    pluginModuleFederation({
      name: 'tasks',
      manifest: true,
      filename: 'remoteEntry.js',
      exposes: {
        './App': './src/App.tsx',
      },
      shared: {
        react: {
          singleton: true,
          requiredVersion: "^18.0.0",
        },
        "react-dom": {
          singleton: true,
          requiredVersion: "^18.0.0",
        },
      },
    }),
  ],
  server: {
    port: 3051
  },
});

And installed basic modern.js and configured module federation from documentation
configs:
modern.config.ts:

import {appTools, defineConfig} from '@modern-js/app-tools';
import {config} from './main.config'
import { moduleFederationPlugin } from '@module-federation/modern-js';
import { tailwindcssPlugin } from '@modern-js/plugin-tailwindcss'

export default defineConfig(({env}) => ({
  dev: {
    port: env === 'development' ? config.devPort : config.prodPort,
  },
  runtime: {
    router: true,
  },
  server: {
    ssr: {
      mode: 'stream',
    },
  },
  output: {
    distPath: {
      // root: platformPathBuild('app')
    }
  },
  plugins: [
    appTools({
      bundler: 'rspack',
    }),
    tailwindcssPlugin(),
    moduleFederationPlugin(),
  ],
}));

module-federation.config.ts:

import { createModuleFederationConfig } from '@module-federation/modern-js';

export default createModuleFederationConfig({
  name: 'app',
  remotes: {
    tasks: 'tasks@http://localhost:3051/mf-manifest.json',
  },
  shared: {
    react: {
      singleton: true,
      requiredVersion: "^18.0.0",
    },
    "react-dom": {
      singleton: true,
      requiredVersion: "^18.0.0",
    },
  },
});

Reproduce link

https://github.com/VictorPulzz/modernjs-rsbuuld-modulefederation

Reproduce Steps

  1. cd app && npm i && cd ../tasks && npm i && cd ..
  2. cd app && npm run dev && cd ../tasks && npm run dev && cd ..
@VictorPulzz VictorPulzz added the bug Something isn't working label Dec 19, 2024
@VictorPulzz
Copy link
Author

VictorPulzz commented Dec 19, 2024

Error text:

[ Module Federation Dev Server ] Error [ Federation Runtime ]: [ Federation Runtime ]: The attribute remoteEntry of tasks must not be undefined.
  at Object.error (/modernjs-rsbuuld-modulefederation/app/node_modules/@module-federation/runtime/dist/share.cjs.js:25:1)
at assignRemoteInfo (/modernjs-rsbuuld-modulefederation/app/node_modules/@module-federation/runtime/dist/index.cjs.js:747:1)
at Array.afterResolve (/modernjs-rsbuuld-modulefederation/app/node_modules/@module-federation/runtime/dist/index.cjs.js:766:1)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at RemoteHandler.getRemoteModuleAndOptions (/modernjs-rsbuuld-modulefederation/app/node_modules/@module-federation/runtime/dist/index.cjs.js:1723:1)
at initRemoteModule (/modernjs-rsbuuld-modulefederation/app/node_modules/@module-federation/runtime/dist/index.cjs.js:1378:1)
at async Promise.all (index 0)
at /modernjs-rsbuuld-modulefederation/app/node_modules/@module-federation/runtime/dist/index.cjs.js:1251:1
at async Promise.all (index 0)
at SharedHandler.loadShare (/modernjs-rsbuuld-modulefederation/app/node_modules/@module-federation/runtime/dist/index.cjs.js:1250:1)
[ Module Federation Dev Server ] Error Process(54791) unhandledRejection, mf server will exit...

Process finished with exit code 1

@VictorPulzz
Copy link
Author

BTW, it would be cool to have more examples of how to use module federation. Because so far it works like a black box, many things are not understood:(
Let's say if I want to combine several applications:
Host: Modern.js
Remotes: Rspack, Webpack, Vite, etc.
I would also like examples with different api services: rest (tanstack react query/redux rtk), apollo graphql.
Thanks:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant