module-federation / core

Module Federation is a concept that allows developers to share code and resources across multiple JavaScript applications
https://module-federation.io/
MIT License
1.56k stars 243 forks source link

Vite warning when loading ESM with loadRemote from @module-federation/enhanced/runtime #3250

Closed sk-pub closed 1 day ago

sk-pub commented 1 week ago

Describe the bug

Steps to reproduce:

  1. Generate a new Angular 18 app with ng new
  2. Use loadRemote from @module-federation/enhanced/runtime
  3. Start dev server and open localhost:4200
  4. Observe the following message in terminal:
    [vite] warning: 
    .../.angular/cache/18.2.12/angular-module-federation-esm-warning/vite/deps/@module-federation_enhanced_runtime.js
    2134|                import(
    2135|                  /* webpackIgnore: true */
    2136|                  entry
    |                  ^^^^^
    2137|                ).then(resolve).catch(reject);
    2138|              } else {
    The above dynamic import cannot be analyzed by Vite.
    See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.
    Plugin: vite:import-analysis
    File: .../.angular/cache/18.2.12/angular-module-federation-esm-warning/vite/deps/@module-federation_enhanced_runtime.js?v=c3d1dba7

Reproduction

I'll create a PR with a fix.

Reproduction

https://github.com/sk-pub/angular-module-federation-esm-warning

Used Package Manager

npm

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 AMD Ryzen 9 7900X 12-Core Processor
    Memory: 13.57 GB / 31.15 GB
  Binaries:
    Node: 18.20.5 - ~\AppData\Local\Volta\tools\image\node\18.20.5\node.EXE
    npm: 10.8.2 - ~\AppData\Local\Volta\tools\image\node\18.20.5\npm.CMD
    pnpm: 8.11.0 - C:\Program Files\Volta\pnpm.EXE
    bun: 1.1.34 - ~\AppData\Local\Volta\bin\bun.EXE
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527

Validations

sk-pub commented 1 day ago

Checked with @module-federation/enhanced 0.7.7. The warning is gone.