babel-plugin-styled-components
babel-plugin-styled-components copied to clipboard
Same className in production at version 5.x
https://github.com/styled-components/babel-plugin-styled-components/issues/24
I think this bug appeared again in 5.x.
// file1
const Container = styled.div`xxxx`;
// file2
const Container = styled.div`xxxx`;
The above code is normal in the development environment of development. But after production, they have the same className.
Having this right now as well. Maybe related with https://github.com/styled-components/babel-plugin-styled-components/issues/271 .
Interesting observation from our side:
- we have some component files at
src/features/...
and some atsrc/common/...
. - we have a file at
./package.json
but also atsrc/common/package.json
. (This is because oursrc/common/
directory is actually a git subrepo that is shared between multiple projects.) - if we remove the
src/common/package.json
file, the problem disappears.
So maybe as described in https://github.com/styled-components/babel-plugin-styled-components/issues/271 , if there are components being built by several projects, then there's some hash collision happening in https://github.com/styled-components/babel-plugin-styled-components/blob/master/src/visitors/displayNameAndId.js#L95 ... Not sure, I might be completely wrong, but just adding our three cents.