Port babel-plugin-styled-components to SWC
See original GitHub issueThis Babel plugin is the most used customization of .babelrc
.
The plugin is split up in multiple separate transforms:
The defaults are here: https://github.com/styled-components/babel-plugin-styled-components/blob/950692b92855f17609e4281d5081e3d2acbf4b6b/src/utils/options.js
The critical one which makes styled-components not have hydration issues with Next.js is displayNameAndId
. All the other ones seem to be optimizations. Because of this I’d start by porting the displayNameAndId
transform and then check what else can be ported.
Looking at the defaults the only transform that is disabled by default is the pure annotations one.
List of transforms:
- ssr – enabled when
styledComponents: true
- displayName – enabled when
styledComponents: true
, disabled in production to reduce file size - css prop
- fileName
- minify
- transpileTemplateLiterals
- pure
- namespace
Issue Analytics
- State:
- Created 2 years ago
- Reactions:197
- Comments:48 (19 by maintainers)
Top Results From Across the Web
swc/plugin-styled-components
SWC plugin for styled-components. Latest version: 1.5.33, last published: 5 days ago. Start using @swc/plugin-styled-components in your ...
Read more >Advanced Features: Next.js Compiler
Styled Components. We're working to port babel-plugin-styled-components to the Next.js Compiler. First, update to the latest version of Next.js: npm install ...
Read more >styled-components now usable with SWC in Next.js 12 ...
We've ported the critical option of babel-plugin-styled-components that prevents hydration mismatches to SWC. Learn more: ...
Read more >Next failed to load SWC binary
Delete the package-lock.json file and the node_modules directory in your project and then run npm install on your terminal.
Read more >Migrating your React app from Webpack to Vite
npm i --save-dev vite @vitejs/plugin-react vite-plugin-html ... For example, to add babel-plugin-styled-components plugin:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@timneutkens when are you planning to release support for
css
prop?The linked issue is unrelated as that one is about the minifier. This issue is about implementing the transforms that are critical for running styled-components correctly when doing SSR.