Modern.js is a progressive web development framework based on React. Internally at ByteDance, Modern.js supports the development of thousands of web applications.
The Module Federation team works closely with the Modern.js team and provides the @module-federation/modern-js
plugin to help users better utilize Module Federation within Modern.js.
We highly recommend referencing these applications, which showcases the best practices for integrating Modern.js with Module Federation:
You can install the plugin using the following commands:
Apply this plugin in the plugins
section of modern.config.ts
:
Then, create the module-federation.config.ts
file and add the required configuration:
For a better performance experience, Module Federation X Modern.js SSR only supports stream SSR.
There is no difference in using Module Federation in SSR scenarios compared to CSR scenarios; developers can continue with their existing development practices.
See Data Fetching.
The Modern.js plugin re-exports @module-federation/bridge-react
from @module-federation/modern-js/react
, so you don't need to install it separately.
@module-federation/modern-js
re-exports @module-federation/modern-js/runtime
from the runtime
subpath. You can use @module-federation/modern-js/runtime
to get the MF Runtime.Runtime。
false
undefined
@module-federation/modern-js
will automatically add SSR-related build presets based on server.ssr
in the modern.js config.
If the current project only needs to load MF in CSR, you can set ssr: false
to help with progressive migration.
Record<string, unknown>
undefined
If a downgrade occurs, an HTTP request will be sent to the server. This configuration can be used to add query parameters to that request.