angular-architects / module-federation-plugin

MIT License
735 stars 203 forks source link

Build failure with native federation in angular 17 #684

Open Sean11133 opened 2 weeks ago

Sean11133 commented 2 weeks ago

For which library do you need help?

native-federation

Question

Reproduction of the bug/regression with instructions

this is my stackblitz

I used the ng-flex-layout and swiper packages, but I couldn't package them correctly when running npm run start. I also tried adding the packages to the skip list, but it still wouldn't run.

Expected behavior

Build successfully by ignoring the packages mentioned in skip section of federated-config.js

Versions of Native/Module Federation, Angular, Node, Browser, and operating system

Native Federation: 17.1.8 Angular: 17.3.12 Node: >18.9 Browser: Edge OS: Windows

Other information

Console Log


npm run start

> main@0.0.0 start
> ng serve

 INFO  Building federation artefacts
 INFO  Preparing shared npm packages
 NOTE  This only needs to be done once, as results are cached
 NOTE  Skip packages you don't want to share in your federation config
✘ [ERROR] File 'node_modules/swiper/types/index.d.ts' is missing from the TypeScript compilation. [plugin angular-compiler]

  Ensure the file is part of the TypeScript program via the 'files' or 'include' property.

1 of 4 errors shown (disable the message limit with --log-limit=0)
 ERR!  Error bundling shared npm package 
 ERR!  Build failed with 4 errors:
 ERR!  error: File 'node_modules/swiper/types/index.d.ts' is missing from the TypeScript compilation.
 ERR!  node_modules/ng-flex-layout/fesm2022/ng-flex-layout-server.mjs:4:38: ERROR: Could not resolve "@angular/platform-server"
 ERR!  node_modules/swiper/swiper-react.mjs:13:107: ERROR: Could not resolve "react"
 ERR!  node_modules/swiper/swiper-vue.mjs:13:122: ERROR: Could not resolve "vue"
 ERR!  For more information, run in verbose mode
 NOTE  
 NOTE  
 NOTE  ** Important Information: ***
 NOTE  The error message above shows an issue with bundling a node_module.
 NOTE  In most cases this is because you (indirectly) shared a Node.js package,
 NOTE  while Native Federation builds for the browser.
 NOTE  You can move such packages into devDependencies or skip them in your federation.config.js.
 NOTE  
 NOTE  More Details: https://bit.ly/nf-issue
 NOTE  
 NOTE  
⠋ Building...
(node:50) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unpipe listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:50) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
(node:50) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
(node:50) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 finish listeners added to [WriteStrea
Initial chunk files   | Names         |  Raw size
polyfills.js          | polyfills     | 174.06 kB | 
main.js               | main          | 255 bytes | 
styles.css            | styles        |  96 bytes | 

                      | Initial total | 174.40 kB

Lazy chunk files      | Names         |  Raw size
bootstrap-F7JMTHFZ.js | bootstrap     |  22.99 kB | 

Application bundle generation complete. [14.403 seconds]

Watch mode enabled. Watching for file changes...
Re-optimizing dependencies because vite config has changed
  ➜  Local:   http://localhost:4200/
  ➜  press h + enter to show help