originjs / vite-plugin-federation

Module Federation for vite & rollup
Other
2.39k stars 241 forks source link

How can I work with static import ? #607

Open huylevuanh opened 4 months ago

huylevuanh commented 4 months ago

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

huylevuanh commented 4 months ago

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.

phcbarros commented 4 months ago

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 />
  )
}