angular-architects / module-federation-plugin

MIT License
710 stars 189 forks source link

Native Federation Loading Library Files in Importmap/remoteEntry.json Shared Twice #599

Closed dipu7388 closed 1 month ago

dipu7388 commented 1 month ago

Issue Description:

Native Federation Loading Library Files in Importmap/remoteEntry.json Shared Twice

When using native federation loading in Angular, the library files are being shared twice in the importmap/remoteEntry.json. Specifically, they are being shared once through a simple HTTP call (http://localhost:4200/_angular_router-17_3_11-dev.js) and once through a blob URL (blob:http://localhost:4200/37dd49b6-c9b2-4b0d-ad99-80b0722f8b53).

Expected Behavior:

Ideally, the library files should only be shared once in the importmap/remoteEntry.json, using a consistent method (preferably the HTTP call).

Steps to Reproduce:

  1. Clone the repository dipu7388/multiple-entry.
  2. Install dependencies (npm install).
  3. Start the development server (npm start).
  4. Open developer tools and search for any variable name (e.g., RouteConfigLoadEnd) to locate where it is defined or imported.
  5. Observe how _angular_router-17_3_11-dev.js is referenced in the file.

Repository Link: dipu7388/multiple-entry

dipu7388 commented 1 month ago

@manfredsteyer please look into it, as it causes performance degradation, and increased in code duplication, api calls. is there is a way to merge multiple chunk in one, ex merge rxjs, and rxjsoperatores bundle into one then update importmap.json and remoteEntry.json.

dipu7388 commented 1 month ago

@manfredsteyer @jogelin @GregOnNet can we have workaround please

manfredsteyer commented 1 month ago

It's indeed only loaded once. It just looks like it's loaded twice because the polyfill creates an object URL for it.