core icon indicating copy to clipboard operation
core copied to clipboard

ERROR Error: [ Federation Runtime ]: The remote entry interface does not contain "init" #RUNTIME-002

Open Griffin23 opened this issue 1 year ago • 5 comments

Describe the bug

Hey guys, I'm using angular v17 and try to migrate from @angular-architect/module-federation to @module-federation/enhanced in my project, but I always encounter the error: ERROR Error: [ Federation Runtime ]: The remote entry interface does not contain "init" #RUNTIME-002 after loadRemote().

So I downgrade official starter demo of @angular-architect/module-federation from angular v19 to v17 and switch to mf2.0 to verity if I am doing something wrong. But I get the same error #RUNTIME-002.

It looks like there are some problems about the output bundle when using mf2.0 + angular v17 (builder is ngx-build-plus v17), and I have read the doc about #RUNTIME-002 error but that is not fit for me...

Some codes: Remote: webpack.config.js

const { ModuleFederationPlugin } = require("@module-federation/enhanced/webpack");

module.exports = {
  plugins: [
    new ModuleFederationPlugin({
      name: "mfe1",
      filename: 'remoteEntry.js',
      exposes: {
        "./Module": "./projects/mfe1/src/app/flights/flights.module.ts",
      },
      shared: {},
    }),
  ],
};

Host: webpack.config.js

const { ModuleFederationPlugin } = require("@module-federation/enhanced/webpack");

module.exports = {
  plugins: [
    new ModuleFederationPlugin({
      name: 'my_host',
      remotes: {}, // will dynamic register remote later
      shared: {},
    }),
  ]
};

Host: home.component.ts

import { Component, OnInit } from '@angular/core';
import { registerRemotes, loadRemote } from '@module-federation/enhanced/runtime';

@Component({
    selector: 'app-home',
    templateUrl: './home.component.html',
    standalone: false
})
export class HomeComponent implements OnInit {

  constructor() { }

  ngOnInit() {
    registerRemotes([{
      name: 'mfe1',
      type: 'module',
      entry: 'http://localhost:3000/remoteEntry.js'
    }]);

    loadRemote('mfe1/Module').then(r => {
      console.log('-----------------------', r);
    });
  }
}

The output remoteEntry.js, seems lack of many stuff:

"use strict";
var mfe1;
(self["webpackChunkmfe1"] = self["webpackChunkmfe1"] || []).push([["mfe1"],{},
/******/ __webpack_require__ => { // webpackRuntimeModules
/******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
/******/ var __webpack_exports__ = (__webpack_exec__(205));
/******/ mfe1 = __webpack_exports__;
/******/ }
]);

For detail sample code please find at Reproduction.

Reproduction

https://github.com/Griffin23/MF2.0Fork

Used Package Manager

npm

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
    Memory: 11.62 GB / 31.73 GB
  Binaries:
    Node: 18.20.5 - C:\Softwares\Nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.8.2 - C:\Softwares\Nodejs\npm.CMD
  Browsers:
    Edge: Chromium (133.0.3065.82)
    Internet Explorer: 11.0.22621.3527

Validations

Griffin23 avatar Apr 01 '25 08:04 Griffin23

I upload my output bundle here.

Griffin23 avatar Apr 01 '25 08:04 Griffin23

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

应该是这样的:

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

erichow avatar May 06 '25 08:05 erichow

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

应该是这样的:

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

还是同样的错...

Griffin23 avatar May 19 '25 06:05 Griffin23

Any follow up on this? Having similar case.

jsPl avatar Jul 02 '25 09:07 jsPl

Stale issue message

github-actions[bot] avatar Aug 31 '25 15:08 github-actions[bot]