angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Project broke after generating a library (Module Federation)

Open Al00X opened this issue 5 years ago β€’ 2 comments

🐞 Bug report

Command (mark with an x)

  • [ ] new
  • [x] build
  • [x] serve
  • [ ] test
  • [ ] e2e
  • [ ] generate
  • [ ] add
  • [ ] update
  • [ ] lint
  • [ ] extract-i18n
  • [ ] run
  • [ ] config
  • [ ] help
  • [ ] version
  • [ ] doc

Is this a regression?

No.

Description

I have an NX Angular project with latest Webpack installed on it. I tried to use Module Federation on this project. Everything is running smoothly but there's a critical issue when adding a library using NX generate to the project.

When you run nx serve after adding a library, you get the error below.

I ignored this error because my application was running just fine; until I tried to build the project using nx build. The project build fails because of this error and cannot get procced.

πŸ”¬ Minimal Reproduction

You can take a look at my project and see the error yourself. https://github.com/adnanebrahimi/angular-module-federation-nx

  1. Clone.
  2. Switch to library branch.
  3. run yarn
  4. run nx s, nx b or npm run start:all

πŸ”₯ Exception or Error

./libs/weather/src/index.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: The AngularCompilerPlugin was not found. The @ngtools/webpack loader requires the plugin.
    at Object.ngcLoader (...\node_modules\@ngtools\webpack\src\loader.js:29:15)

Error: Conflict: Multiple assets emit different content to the same filename libs_weather_src_index_ts.js

🌍 Your Environment

Angular CLI: 11.0.5
Node: 12.16.3
OS: win32 x64

Angular: 11.0.5
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: 

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.5
@angular-devkit/build-angular   0.1100.5
@angular-devkit/core            11.0.5
@angular-devkit/schematics      11.0.5
@schematics/angular             11.0.5
@schematics/update              0.1100.5
rxjs                            6.5.5
typescript                      4.0.5

Anything else relevant?

Al00X avatar Jan 03 '21 10:01 Al00X

Hi @Al00X,

It appears that you are using 3rd party CLI builders.

While we do allow extending the Angular CLI, we do not provide support for custom Webpack configurations or 3rd party builders.

Support for Module federation is being tracked here: https://github.com/angular/angular-cli/issues/17556

alan-agius4 avatar Jan 04 '21 10:01 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.