-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[examples] Update styled-components to use SWC #34770
Conversation
example with-typescript-styled-components had a typescript dependency lower than the recommended version. Upgraded from 4.2.4 to 4.5.5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much! This is looking great. One last change.
This comment has been minimized.
This comment has been minimized.
remove Notes section since it describes a workaround which is no longer required to work with `next/link`.
Great, I removed the notes section as requested for the with-styled-components-babel example |
This comment has been minimized.
This comment has been minimized.
Failing test suitesCommit: 503bbbc
Expand output● Image Component Tests › dev mode › should warn at most once even after state change
● Image Component Tests › dev mode › should be valid W3C HTML
● Image Component Tests › server mode › should be valid W3C HTML
Read more about building and testing Next.js in contributing.md. |
What's the status on this? Are any changes required for my part? |
There have been a few flaky tests that are fixed, if tests will pass again, this should be merged automatically now. 👍 |
Stats from current PRDefault Build (Increase detected
|
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
buildDuration | 19.4s | 19.5s | |
buildDurationCached | 7.5s | 7.6s | |
nodeModulesSize | 372 MB | 372 MB | -14 B |
Page Load Tests Overall increase ✓
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 4.268 | 4.198 | -0.07 |
/ avg req/sec | 585.71 | 595.46 | +9.75 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 2.017 | 2.005 | -0.01 |
/error-in-render avg req/sec | 1239.46 | 1247.1 | +7.64 |
Client Bundles (main, webpack)
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
450.HASH.js gzip | 179 B | 179 B | ✓ |
framework-HASH.js gzip | 42 kB | 42 kB | ✓ |
main-HASH.js gzip | 27.9 kB | 27.9 kB | ✓ |
webpack-HASH.js gzip | 1.44 kB | 1.44 kB | ✓ |
Overall change | 71.5 kB | 71.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
_app-HASH.js gzip | 1.36 kB | 1.36 kB | ✓ |
_error-HASH.js gzip | 194 B | 194 B | ✓ |
amp-HASH.js gzip | 312 B | 312 B | ✓ |
css-HASH.js gzip | 326 B | 326 B | ✓ |
dynamic-HASH.js gzip | 2.57 kB | 2.57 kB | ✓ |
head-HASH.js gzip | 350 B | 350 B | ✓ |
hooks-HASH.js gzip | 919 B | 919 B | ✓ |
image-HASH.js gzip | 5.05 kB | 5.05 kB | ✓ |
index-HASH.js gzip | 263 B | 263 B | ✓ |
link-HASH.js gzip | 2.26 kB | 2.26 kB | ✓ |
routerDirect..HASH.js gzip | 321 B | 321 B | ✓ |
script-HASH.js gzip | 383 B | 383 B | ✓ |
withRouter-HASH.js gzip | 318 B | 318 B | ✓ |
85e02e95b279..7e3.css gzip | 107 B | 107 B | ✓ |
Overall change | 14.7 kB | 14.7 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
_buildManifest.js gzip | 459 B | 459 B | ✓ |
Overall change | 459 B | 459 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
index.html gzip | 531 B | 531 B | ✓ |
link.html gzip | 544 B | 544 B | ✓ |
withRouter.html gzip | 526 B | 526 B | ✓ |
Overall change | 1.6 kB | 1.6 kB | ✓ |
Default Build with SWC (Increase detected ⚠️ )
General Overall decrease ✓
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
buildDuration | 24.3s | 24.5s | |
buildDurationCached | 7.8s | 7.5s | -327ms |
nodeModulesSize | 372 MB | 372 MB | -14 B |
Page Load Tests Overall increase ✓
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 4.261 | 4.19 | -0.07 |
/ avg req/sec | 586.65 | 596.62 | +9.97 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 2.035 | 1.99 | -0.05 |
/error-in-render avg req/sec | 1228.3 | 1256.05 | +27.75 |
Client Bundles (main, webpack)
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
450.HASH.js gzip | 179 B | 179 B | ✓ |
framework-HASH.js gzip | 42.3 kB | 42.3 kB | ✓ |
main-HASH.js gzip | 28.1 kB | 28.1 kB | ✓ |
webpack-HASH.js gzip | 1.45 kB | 1.45 kB | ✓ |
Overall change | 72.1 kB | 72.1 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
_app-HASH.js gzip | 1.36 kB | 1.36 kB | ✓ |
_error-HASH.js gzip | 180 B | 180 B | ✓ |
amp-HASH.js gzip | 313 B | 313 B | ✓ |
css-HASH.js gzip | 326 B | 326 B | ✓ |
dynamic-HASH.js gzip | 2.56 kB | 2.56 kB | ✓ |
head-HASH.js gzip | 350 B | 350 B | ✓ |
hooks-HASH.js gzip | 921 B | 921 B | ✓ |
image-HASH.js gzip | 5.2 kB | 5.2 kB | ✓ |
index-HASH.js gzip | 261 B | 261 B | ✓ |
link-HASH.js gzip | 2.33 kB | 2.33 kB | ✓ |
routerDirect..HASH.js gzip | 321 B | 321 B | ✓ |
script-HASH.js gzip | 386 B | 386 B | ✓ |
withRouter-HASH.js gzip | 317 B | 317 B | ✓ |
85e02e95b279..7e3.css gzip | 107 B | 107 B | ✓ |
Overall change | 14.9 kB | 14.9 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
_buildManifest.js gzip | 456 B | 456 B | ✓ |
Overall change | 456 B | 456 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | Skagoo/next.js styled-components-swc | Change | |
---|---|---|---|
index.html gzip | 530 B | 530 B | ✓ |
link.html gzip | 543 B | 543 B | ✓ |
withRouter.html gzip | 527 B | 527 B | ✓ |
Overall change | 1.6 kB | 1.6 kB | ✓ |
@Skagoo @leerob @balazsorban44 I found a bug. When you run |
@dawidk92 I completely overlooked this, my bad. I did take a look now and I'm quite doubtfull (according to docs) that I missed something in the example setup. Do we have tests that prove the correct/working implementation of how SWC handles the SSR of StyledComponents? |
Why was custom I have created a PR to fix that: #35163 |
Since Next.js 12.1 we have improved SWC support, which removes the dependency of Babel to work with Styled Components within Next.js.
This PR:
with-styled-components
(using Babel) towith-styled-components-babel
with-typescript-styled-components
combiningTypeScript
andStyled Components
to work with SWCwith-styled-components
using SWC instead of Babel