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

How to config webpack to reuse existing dependencies from the main bundle #620

Closed
trinhhcse opened this issue May 13, 2024 · 4 comments
Closed
Labels

Comments

@trinhhcse
Copy link

trinhhcse commented May 13, 2024

Ask your Question

Hi team,
I try to using repack v4 with Module Federation plugin in sub app but after run webpack bundle size. The output bundle still content shared dependencies (react, react-native).
I research from document
Beware, with dynamic scripts there's no dependency sharing by default. If you want your scripts to reuse existing dependencies from the main bundle, it's up to you to figure out how to do it. A good starting point would be: https://webpack.js.org/configuration/externals/ https://webpack.js.org/plugins/dll-plugin/

How to config webpack dll plugin in host app and miniapp to reuse existing dependencies from the host app bundle (react, react-native)
Thanks team.

@jbroma
Copy link
Member

jbroma commented May 13, 2024

@trinhhcse

Correct me If I'm wrong, but I'm guessing you are talking about the shared dependencies still being present in the output directory of the mini-app despite being declared shared right?

@trinhhcse
Copy link
Author

@jbroma Yes, that’s right.

@jbroma
Copy link
Member

jbroma commented May 14, 2024

You can add import: false to shared dependency config to prevent that (next to singleton and eager, for each dep). This is like saying: "I never want to use fallback from my app, I always want to rely on the shared dependency present in the host app"

@trinhhcse
Copy link
Author

I tried it. It works like a charm. Thanks you.

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

No branches or pull requests

2 participants