Closed rbong closed 1 year ago
Re-posting this from the issue.
We have run into this issue using module federation and our in-house component library. babel-plugin-styled-components successfully namespaces styled components written within each app, preventing class name collision when multiple apps are loaded on the same page with module federation. However, each app also imports from our component library which is already transpiled, and these component class names are not namespaced, leading to class name collision bugs.
We've tested this PR in our dev environment and it fixes our issue.
This adds support for identifying styled components imports using
_interopRequiredDefault
and calls to styled components that use sequence expressions (ex.(0, _styled)('div')()
).This should improve support for MUI + Next with SSR.
In
isStyled
, I added equivalent checks for sequence expressions wherever they could be used instead of member expressions. However, there's one case that I'm not sure will ever apply:Please let me know if this needs an equivalent sequence expression check.
I thought maybe this PR might add some new errors on re-transpilation, but I ran tests using outputs as inputs and didn't see any new problems.