Sharing a component that is dependent on a library using nextjs-mf (Module Federation)

92 Views Asked by At

I'm currently working on a microfrontend project that I created using nextjs 13 and it uses the https://www.npmjs.com/package/@module-federation/nextjs-mf plugin and am having a bit of difficulty on finding out if what I'm trying to do is possible or not.

So, I have 2 projects, 1 is the parent and the other the child.

So the child is showing a line chart using https://github.com/recharts/recharts and I'm trying to show that in the parent by exposing the component that is showing the chart in the child project.

I tried out creating a button and exposing it too, which shows correctly just fine, but the charts doesn't show up on the parent project.

So I was wondering, is it possible to expose and share a component that is dependent on a library?

Other than that I also noticed that in using tailwind CSS, it's kind of a problem too because of it's default JIT mode, so the shared component doesn't load up its CSS correctly even though the parent component also already have tailwind installed.

0

There are 0 best solutions below