Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree Shaking on @module-federation/runtime doesn't work #3546

Open
5 tasks done
nicotu01 opened this issue Feb 26, 2025 · 2 comments
Open
5 tasks done

Tree Shaking on @module-federation/runtime doesn't work #3546

nicotu01 opened this issue Feb 26, 2025 · 2 comments

Comments

@nicotu01
Copy link

nicotu01 commented Feb 26, 2025

Describe the bug

Module Federation Runtime significantly increases the size of the deliverable.

  1. I created a vanilla vite project using the command npm create vite. Then, I deleted all the JavaScript code.

Here is the result of build command :

dist/assets/index-B5Qt9EMX.js  0.71 kB
  1. Then, I installed @module/federation-runtime and simply invoked init function from main.ts :
import { init } from "@module-federation/runtime";
init({
  name: "vite-vanilla",
  remotes: [
    { name: "remote1", entry: "http://localhost:4321/assets/remotesEntry.js" },
  ],
});

The result of the build command significantly increases :

dist/assets/index-DjYITZnQ.js  63.77 kB 

When I check the contents of the deliverable, I notice that the entire runtime library is present

Reproduction

https://github.com/nicotu01/vite-vanilla-federation-tree-shaking

Used Package Manager

npm

System Info

-

Validations

@ScriptedAlchemy
Copy link
Member

init requires the full system, runtime cannot be shaken in vite. in webpack and rspack we can share it, making the remotes only 14kb

@nicotu01
Copy link
Author

Hi @ScriptedAlchemy !
Without talking about sharing, I'm simply building an application that invokes the init function of @module-federation/runtime

I try it with webpack and have the same result : the bundle size is very heavy.

I just have an ìndex.js :

import { init } from "@module-federation/runtime";
init({
  name: "vite-vanilla",
  remotes: [
    { name: "remote1", entry: "http://localhost:4321/assets/remotesEntry.js" },
  ],
});

And the webpack build result :

dist/assets/index-DjYITZnQ.js  65.93 kB 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants