core icon indicating copy to clipboard operation
core copied to clipboard

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

Open ckken opened this issue 1 year ago • 8 comments

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 avatar May 24 '24 10:05 ckken

image

ckken avatar May 24 '24 10:05 ckken

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

zhoushaw avatar May 28 '24 06:05 zhoushaw

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

ckken avatar May 28 '24 11:05 ckken

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.

ScriptedAlchemy avatar Jun 03 '24 12:06 ScriptedAlchemy

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

ckken avatar Jun 03 '24 14:06 ckken

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.

ScriptedAlchemy avatar Jun 03 '24 14:06 ScriptedAlchemy

nice!

ckken avatar Jun 03 '24 14:06 ckken

Stale issue message

github-actions[bot] avatar Aug 02 '24 15:08 github-actions[bot]

Stale issue message

github-actions[bot] avatar Oct 02 '24 15:10 github-actions[bot]

Should be better once shareable runtime is avaliable

ScriptedAlchemy avatar Oct 02 '24 18:10 ScriptedAlchemy

Stale issue message

github-actions[bot] avatar Dec 02 '24 15:12 github-actions[bot]

Bump

ScriptedAlchemy avatar Dec 03 '24 01:12 ScriptedAlchemy

Stale issue message

github-actions[bot] avatar Feb 02 '25 15:02 github-actions[bot]

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.

@ScriptedAlchemy Hi, I noticed that this issue has been closed. I'm wondering if there are any effective solutions to the problem of the entry file size? I conducted a test in the apps/router-demo/router-remote1-2001 sub-repository. The size of the packaged remoteEntry.js reached 80k. Even after setting experiments.externalRuntime, the size was still 40k. In one of my projects, after injecting polyfill using swc-loader, the file size even exceeded 100k. With the same configuration, when using the builtin MF 1.5 of Rspack, the size of the remoteEntry.js is only 18k. This will have a significant impact on page resource loading on pages with multiple remote projects. Thank you for your answers in advance~

zavierkolten avatar Feb 07 '25 14:02 zavierkolten

Size should be https://github.com/module-federation/core/pull/3519 14k now

ScriptedAlchemy avatar Mar 15 '25 23:03 ScriptedAlchemy