angular-architects / module-federation-plugin

MIT License
713 stars 189 forks source link

Error: Dynamic require of "tslib" is not supported #572

Open omishyn-dm opened 3 months ago

omishyn-dm commented 3 months ago

After update @angular-architects/native-federation from 18.0.0 to 18.0.2 on serve i have error in console dev tools

Error: Dynamic require of "tslib" is not supported

and i found next code in artifact file

... // node_modules/@angular-architects/native-federation/src/index.js var require_src = __commonJS({ "node_modules/@angular-architects/native-federation/src/index.js"(exports) { "use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
var tslib_1 = __require("tslib");
tslib_1.__exportStar((init_softarc_native_federation_runtime(), __toCommonJS(softarc_native_federation_runtime_exports)), exports);

} }); ...

I think it heppends becouse you change index.js source code from

export * from '@softarc/native-federation-runtime';

to

"use strict"; Object.defineProperty(exports, "esModule", { value: true }); const tslib_1 = require("tslib"); tslib_1.exportStar(require("@softarc/native-federation-runtime"), exports);

I patched this file and it works again

Please return code in node_modules/@angular-architects/native-federation/src/index.js

mqrten commented 1 month ago

Same issue for me when using nested MFE-s 3 levels in and only if using @ViewContainer on the second level (if I remove ViewContainer error disappears). Furthermore, error occurs only if I access through first level, never when I access it through second level.

shell => mfe level 2 => mfe level 3.

Needed to downgrade to 18.0.0, furthermore, needed to add mfe level 3 remote to shell (defining it only in level 2 was not sufficient), otherwise mfe level 3 was not recognised.

dodesheide commented 1 month ago

Same issue for us. We created a duplicate here: https://github.com/angular-architects/module-federation-plugin/issues/602

dodesheide commented 4 weeks ago

Try to update to 18.1.1. This version fixed for me the error. See https://github.com/angular-architects/module-federation-plugin/issues/602 .

angelo-v commented 1 week ago

The error came back with 18.1.3

angelo-v commented 1 week ago

It seems the package got published as commonjs instead of esm again. Could you take a look at this and fix it @manfredsteyer?