originjs/vite-plugin-federation

How can I work with static import ?

huylevuanh opened this issue · 2 comments

I am using Vite + React
In the Host app instead of exposing specific component, I am exposing the whole folder components via index.ts file
image
In the remote app, i use static import to import the component,
image
But when deploying application, i got this error:
image
Can anyone help me to explain this issue and how to fix it, thank a lot

I tried to use lazy import but, i am using named export in the host app, so if I change the whole source code to export default, it will be a big problems.

I think it only works when you export your component with default keyword

import Button from '@mui/material/Button'
import Stack from '@mui/material/Stack'

export default function BasicButtons() {
  return (
    <Stack spacing={2} direction="row">
      <Button variant="text">Text</Button>
      <Button variant="contained">Contained</Button>
      <Button variant="outlined">Outlined</Button>
    </Stack>
  )
}
import {Container, Typography} from '@mui/material'
import Buttons from 'example/buttons'

export function Home() {
  return (
      <Buttons />
  )
}