babel-plugin-styled-components icon indicating copy to clipboard operation
babel-plugin-styled-components copied to clipboard

Doesn't identify styled components in pre-transpiled code

Open rbong opened this issue 3 years ago • 2 comments

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 avatar Jul 30 '22 17:07 rbong

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

rbong avatar Jul 30 '22 17:07 rbong

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.

eckmLJE avatar Sep 01 '22 13:09 eckmLJE