styled-components / babel-plugin-styled-components

Improve the debugging experience and add server-side rendering support to styled-components
MIT License
1.07k stars 139 forks source link

Doesn't identify styled components in pre-transpiled code #379

Open rbong opened 2 years ago

rbong commented 2 years ago

Imports which use _interopRequireDefault are not identified.

// not identified
const styled = _interopRequireDefault(require("styled-components"));

Calls using SequenceExpressions are also not identified.

const Test = (0, styled)('div')();
rbong commented 2 years ago

This is what causes https://github.com/styled-components/babel-plugin-styled-components/pull/365

eckmLJE commented 2 years ago

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.

Commenting to add our support for @rbong's PR to add this support after testing it in our dev environment.