mauriciovigolo / keycloak-angular

Easy Keycloak setup for Angular applications.
MIT License
730 stars 280 forks source link

MFE WEBPACK_IMPORTED_MODULE_5 is not a constructor #465

Closed Ketec closed 1 year ago

Ketec commented 1 year ago
"keycloak-angular": "^12.2.0",
"keycloak-js": "^20.0.2",

Getting the error with MFE (therefor with webpack 5). TypeError: keycloak_js__WEBPACK_IMPORTED_MODULE_5__ is not a constructor

pointing to the this._instance = new Keycloak(config);

I tried same init logic in code:

    const options: KeycloakOptions = {};
    console.log(new Keycloak(options.config));

And it seems to work fine - so keycloak-js itself seems to be fine.

michaelhunziker commented 1 year ago

@Ketec Did you ever come up with a solution to this issue?

We're getting the same error with @angular-architects/module-federation (Webpack 5 Module Federation).

    "keycloak-angular": "^13.0.0",
    "keycloak-js": "^20.0.3",
    "@angular-architects/module-federation": "^15.0.3",
    "@angular/core": "^15.1.3",
    "typescript": "~4.9.5"
Ketec commented 1 year ago

I had to specifically add this to a custom excluded list in the shell. It seems to break if it is shared with remote modules.

That's assuming none of the remotes need to use Keycloak service anywhere.

michaelreh-timeless-systems commented 1 year ago

I had to specifically add this to a custom excluded list in the shell. It seems to break if it is shared with remote modules.

That's assuming none of the remotes need to use Keycloak service anywhere.

@Ketec I have the same issue . Can u provide a more specific workaround for this please. thx. What is a custom excluded list and what did u exclude ?

Ketec commented 1 year ago

The shareAll in webpack conf has one additional parameter for skip list.

const DEFAULT_SKIP_LIST = [
  '@angular-architects/module-federation',
  '@angular-architects/module-federation-runtime',
  'tslib',
  'zone.js',
  'keycloak-js'
];

I added keycloak-js - need to include the others (they were in the module federation library, but the skip parameter overrides defaults).

mauriciovigolo commented 1 year ago

Thank you for sharing the solution @Ketec. I'm going to close this issue for now. If something new appears, please let me know. Thanks!

prasadmamidi7 commented 1 year ago

I am also facing similar issue when I try to use this library with Nx . Is there solution ? or we need to directly use keycloak-js instead of angular keycloak

Sir-J commented 1 year ago

I am also facing similar issue when I try to use this library with Nx . Is there solution ? or we need to directly use keycloak-js instead of angular keycloak

Did you find a solution?

syedhannan commented 8 months ago

Facing the same issue here. Tried with the skip list array mentioned by @Ketec but that also does not work