question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding a Kendo Dropdown breaks Module Federation with @angular/localize error

See original GitHub issue

Description of Issue

When I add a Kendo Dropdown to Angular Module Federation I get the error:

ERROR Error: It looks like your application or one of its dependencies is using i18n. Angular 9 introduced a global $localize() function that needs to be loaded. Please run ng add @angular/localize from the Angular CLI. (For non-CLI projects, add import '@angular/localize/init'; to your polyfills.ts file. For server-side rendering applications add the import to your main.server.ts file.)

This scenario is Kendo, but it may be the case that any third part project dependent on Angular i18n would have this issue.

Steps to Reproduce

  • run npx create-nx-workspace@latest
  • npm install --save-dev @nrwl/angular
  • Use Nx Vs Code Extension to create host and name it host
  • Use Nx Vs Code Extension to create a remote and name it remote
  • npm install --save @progress/kendo-angular-dropdowns @progress/kendo-angular-l10n @progress/kendo-angular-popup @progress/kendo-angular-treeview @progress/kendo-angular-inputs @progress/kendo-angular-intl @progress/kendo-drawing @progress/kendo-angular-common @progress/kendo-licensing
  • copy the code here https://www.telerik.com/kendo-angular-ui/components/dropdowns/combobox/ and place it on the app.component.ts and app.compnent.html respectively.

Alternately you can clone this same repository. https://github.com/avington/kendo-test

More Information

The error says to add @angular/localize to the polyfill.ts files so I added it to both of them and that did not help. Also, I when I first only added the host app and ran the code it worked, but when I added the remote, then the code started failing with above error.

If you add the import to the main.server.ts file I get this error instead consumes:146 Uncaught Error: Shared module is not available for eager consumption: 5597 at Object.webpack_require.m.<computed> (consumes:146:1) at webpack_require (bootstrap:19:1) at Module.5352 (polyfills.js:12:80) at webpack_require (bootstrap:19:1) at startup:5:1

I also opened a ticket on the Telerik site and as of now they are not aware of any problems on their end.

BTW: If I do all the same and make it a React MFE project, everything works fine, so it is just an Angular thing.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Coly010commented, May 9, 2022

Hey! 😄

You can remove @angular/localize/init from your remote.

Then in the module-federation.config.js of your Host application, add the following:

shared: (libraryName, libraryOptions) => {
    if (libraryName === '@angular/localize/init') {
      return {
        ...libraryOptions,
        eager: true,
      };
    }
  },

It should look like this:

module.exports = {
  name: 'host',
  remotes: ['test'],
  shared: (libraryName, libraryOptions) => {
    if (libraryName === '@angular/localize/init') {
      return {
        ...libraryOptions,
        eager: true,
      };
    }
  },
};

I’ll add some built-in allowances for this package however as it’s expected to be eagerly consumed

0reactions
Coly010commented, May 20, 2022

Yeah I agree. The change I made to try do this by default doesn’t appear to be working. Good spot

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Material and Kendo doesn't work with Module ...
I built a microfrontend application using Angular CLI and Module Federation Plugin. When I try to install Angular Material or Kendo ...
Read more >
The Angular Plus Show - Podcast Addict
In this episode, we conclude our four-part series on Micro-Frontends by discussing with Colum Ferry about Nx, Module Federation, and why using technology...
Read more >
SQL match cols by JSON on other table - t.co / Twitter
Recommended Answer. we can try to use json_contains function to filter JSON value with subquery. select *from members mwhere exists ( select 1...
Read more >
Halo recon helmet foam template - Weebly
define-names,add-deps,add-dick-puns,add-event-listener,add-events ... ,breach-module,bread,breadboard,breadcrumbs,breader,break,breakable,breakdown,breaker ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found