mui / toolpad

Toolpad: Full stack components and low-code builder for dashboards and internal apps.
https://mui.com/toolpad/
MIT License
997 stars 256 forks source link

Support for module federation #2848

Open alphashr opened 11 months ago

alphashr commented 11 months ago

Duplicates

Latest version

Summary πŸ’‘

I would like to expose pages as a micro frontend modules. I am using OriginJS vite-plugin-federation as following:

import federation from '@originjs/vite-plugin-federation';
...
    plugins: [
      federation({
        name: 'playerList',
        filename: 'remoteEntry.js',
        exposes: {
          // './page1': './.generated/components/?????',
          // './page2': './.generated/pages/??????',
        },
        shared: ['react', 'react-dom'],
        shareScope: 'default',
      }),
    ],

I need some help to understand how the page is rendered in the iframe. If I can find how the iframes content are rendered, I may be able to expose pages similarly.

Examples 🌈

    plugins: [
      federation({
        name: 'playerList',
        filename: 'remoteEntry.js',
        exposes: {
          // './page1': './generated/components/?????',
          // './page2': './generated/pages/??????',
        },
        shared: ['react', 'react-dom'],
        shareScope: 'default',
      }),
    ],

Motivation πŸ”¦

To use Toolpad to achieve micro frontend architecture without having to use iframes.

Janpot commented 11 months ago

@alphashr Toolpad has a server component which needs to run as well. Currently we are working on support for running Toolpad as a express server middleware. At the moment it's undocumented as it's not 100% usable yet, but there is an example. (the feature will be documented once this work is pushed passed the finish line). Would this setup work for you?

alphashr commented 11 months ago

Thanks @Janpot for your reply. Yes this setup and the example that you shared is very helpful.

JerryWu1234 commented 9 months ago

Thanks @Janpot for your reply. Yes this setup and the example that you shared is very helpful.

@alphashr did you solve this problem ?