1

We have a React Webapp where every route is lazy loaded:

const HomeScreen = React.lazy(() => import('../components/HomeScreen/HomeScreen'));

This, as expected, generates various JS files during a production build:

  • main.js
  • 1.main.js
  • 2.main.js

Is there any way to load those generated production code in another Webapp we have? Do they simply replace the content of a specific DOM element? and if so, how do they go about it?

1
  • Extra notes by author: clearly tweaking generated code does not seem like a good practice. However, under our circumstances of having a bundle created by legacy code, if possible, it could prove to be a good intermediate solution for combing new code with legacy code on a routing level. Commented Mar 22, 2022 at 19:32

1 Answer 1

0

You can use Module Fedration for this https://levelup.gitconnected.com/microfrontends-module-federation-exposing-remote-from-legacy-react-webpack4-created-by-f3753d70d34e

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.