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 242 forks source link

externals @module-federation/webpack-bundler-runtime no work! #2539

Open ckken opened 6 months ago

ckken commented 6 months ago

Describe the bug

externals: { ... '@module-federation/webpack-bundler-runtime': 'MFWBR', '@module-federation/webpack-bundler-runtime/constant': 'MFWBRCT', ... },

Reproduction

...

Used Package Manager

pnpm

System Info

System:
    OS: macOS 14.4.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 74.85 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.13.1 - ~/.nvm/versions/node/v20.13.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.5.2 - ~/.nvm/versions/node/v20.13.1/bin/npm
    pnpm: 8.15.5 - ~/Library/pnpm/pnpm
    bun: 1.0.25 - ~/.bun/bin/bun
    Watchman: 2024.05.06.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 125.0.6422.78
    Safari: 17.4.1

Validations

ckken commented 6 months ago

image

zhoushaw commented 6 months ago

You cannot exclude the @module-federation/webpack-bundler-runtime dependency via external because it is injected via template

ckken commented 6 months ago

使用多个模块联邦的话会有性能问题!

ScriptedAlchemy commented 6 months ago

Bundler runtime is stateful I think. It's also quite small. You should look at externalizing the runtime package not the bundler runtime package. That's webpacks runtime code, you want that internalized. Bundler runtime used to be what was in webpacks MF1 runtime modules. Its webpack_require basically.

ckken commented 6 months ago

got it,The runtime package has been externalized. I am considering whether it can also be externalized together to further reduce the size.

ScriptedAlchemy commented 6 months ago

I don't think so since it attaches itself to webpack and uses the context of the runtime. But I know we are looking at how to reduce the payload size / allow something like shared for the runtime so if someone has it, others won't load it.

I believe we need to change some of our architecture to support this. But we are planning to look into it.

ckken commented 6 months ago

nice!

github-actions[bot] commented 4 months ago

Stale issue message

github-actions[bot] commented 1 month ago

Stale issue message

ScriptedAlchemy commented 1 month ago

Should be better once shareable runtime is avaliable