ERROR Error: [ Federation Runtime ]: The remote entry interface does not contain "init" #RUNTIME-002
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
- [x] Read the docs.
- [x] Read the common issues list.
- [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [x] Make sure this is a Module federation issue and not a framework-specific issue.
- [x] The provided reproduction is a minimal reproducible example of the bug.
I upload my output bundle here.
import { registerRemotes, loadRemote } from '@module-federation/enhanced/runtime';
应该是这样的:
import { registerRemotes, loadRemote } from '@module-federation/runtime';
import { registerRemotes, loadRemote } from '@module-federation/enhanced/runtime';
应该是这样的:
import { registerRemotes, loadRemote } from '@module-federation/runtime';
还是同样的错...
Any follow up on this? Having similar case.
Stale issue message