Skip to content

Commit 0eac2b4

Browse files
jantimonTyderion
andauthored
transform styled dom component usage for improved performance (#154)
Co-authored-by: Gabriel Nadler <gabriel.nadler@digitecgalaxus.ch>
1 parent 0eef024 commit 0eac2b4

File tree

106 files changed

+877
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+877
-148
lines changed

.changeset/three-bikes-sit.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"next-yak": minor
3+
"yak-swc": minor
4+
---
5+
6+
improve bundle size by compiling styled.TAG_NAME

.github/workflows/codspeed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
run: cd packages/benchmarks && pnpm run codspeed
7777

7878
- name: Run benchmarks
79-
uses: CodSpeedHQ/action@v2
79+
uses: CodSpeedHQ/action@v3
8080
with:
8181
working-directory: "packages/benchmarks"
8282
run: NODE_ENV=production node --enable-source-maps ./codspeed/dist/index.bench.mjs

packages/cross-file-tests/__tests__/fixtures/constant/output/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { styled, css } from "next-yak/internal";
22
import { colors, negative, siteMaxWidth } from "./constants";
3+
import * as __yak from "next-yak/internal";
34
import __styleYak from "./index.yak.module.css!=!./index?./index.yak.module.css";
45
export var Button = /*YAK Extracted CSS:
56
.Button {
@@ -13,7 +14,7 @@ export var Button = /*YAK Extracted CSS:
1314
color: --yak-css-import: url("./constants:colors:secondary",mixin);
1415
background-color: --yak-css-import: url("./constants:colors:primary",mixin);
1516
}
16-
*/ /*#__PURE__*/ styled.button(__styleYak.Button, function(param) {
17+
*/ /*#__PURE__*/ __yak.__yak_button(__styleYak.Button, function(param) {
1718
var $variant = param.$variant;
1819
return $variant === "secondary" && /*#__PURE__*/ css(__styleYak.Button__);
1920
});
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { styled } from "next-yak/internal";
22
import { colors } from "./constants";
3+
import * as __yak from "next-yak/internal";
34
import __styleYak from "./index.yak.module.css!=!./index?./index.yak.module.css";
45
export var Button = /*YAK Extracted CSS:
56
.Button {
67
color: --yak-css-import: url("./constants:colors:primary",mixin);
78
background-color: --yak-css-import: url("./constants:colors:secondary",mixin);
89
}
9-
*/ /*#__PURE__*/ styled.button(__styleYak.Button);
10+
*/ /*#__PURE__*/ __yak.__yak_button(__styleYak.Button);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { styled } from "next-yak/internal";
2+
import * as __yak from "next-yak/internal";
23
import __styleYak from "./icon.yak.module.css!=!./icon?./icon.yak.module.css";
34
export var Icon = /*YAK Extracted CSS:
45
.Icon {
56
display: inline-block;
67
width: 20px;
78
height: 20px;
89
}
9-
*/ /*#__PURE__*/ styled.span(__styleYak.Icon);
10+
*/ /*#__PURE__*/ __yak.__yak_span(__styleYak.Icon);

packages/cross-file-tests/__tests__/fixtures/nestedMixin/output/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { styled } from "next-yak/internal";
22
import { buttonMixin } from './mixin';
33
import { primaryButtonMixin } from './helper/anotherMixin';
4+
import * as __yak from "next-yak/internal";
45
import __styleYak from "./index.yak.module.css!=!./index?./index.yak.module.css";
56
export var Button = /*YAK Extracted CSS:
67
.Button {
78
--yak-css-import: url("./mixin:buttonMixin",mixin);
89
}
9-
*/ /*#__PURE__*/ styled.button(__styleYak.Button);
10+
*/ /*#__PURE__*/ __yak.__yak_button(__styleYak.Button);
1011
export var PrimaryButton = /*YAK Extracted CSS:
1112
.PrimaryButton {
1213
--yak-css-import: url("./helper/anotherMixin:primaryButtonMixin",mixin);

packages/cross-file-tests/__tests__/fixtures/sameFileMixin/output/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { styled, css } from "next-yak/internal";
2+
import * as __yak from "next-yak/internal";
23
import __styleYak from "./index.yak.module.css!=!./index?./index.yak.module.css";
34
var buttonTextMixin = /*#__PURE__*/ css(function(param) {
45
var $disabled = param.$disabled;
@@ -17,7 +18,7 @@ var Button = /*YAK Extracted CSS:
1718
.Button__$disabled-01 {
1819
color: gray;
1920
}
20-
*/ /*#__PURE__*/ styled.button(__styleYak.Button, function(param) {
21+
*/ /*#__PURE__*/ __yak.__yak_button(__styleYak.Button, function(param) {
2122
var $disabled = param.$disabled;
2223
return $disabled && /*#__PURE__*/ css(__styleYak.Button__$disabled);
2324
}, function(param) {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { styled } from "next-yak/internal";
2+
import * as __yak from "next-yak/internal";
23
import __styleYak from "./icon.yak.module.css!=!./icon?./icon.yak.module.css";
3-
export var Icon = /*#__PURE__*/ styled.svg();
4-
export var AnyIcon = /*#__PURE__*/ styled.svg();
4+
export var Icon = /*#__PURE__*/ __yak.__yak_svg();
5+
export var AnyIcon = /*#__PURE__*/ __yak.__yak_svg();

packages/cross-file-tests/__tests__/fixtures/selector/output/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { styled } from "next-yak/internal";
22
import { AnyIcon, Icon } from "./icon";
3+
import * as __yak from "next-yak/internal";
34
import __styleYak from "./index.yak.module.css!=!./index?./index.yak.module.css";
45
export var Button = /*YAK Extracted CSS:
56
.Button {
@@ -10,4 +11,4 @@ export var Button = /*YAK Extracted CSS:
1011
margin-right: 15px;
1112
}
1213
}
13-
*/ /*#__PURE__*/ styled.button(__styleYak.Button);
14+
*/ /*#__PURE__*/ __yak.__yak_button(__styleYak.Button);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { styled } from "next-yak/internal";
22
import { lastChildMixin } from './mixin';
3+
import * as __yak from "next-yak/internal";
34
import __styleYak from "./index.yak.module.css!=!./index?./index.yak.module.css";
45
var ListItem = /*YAK Extracted CSS:
56
.ListItem {
@@ -8,5 +9,5 @@ var ListItem = /*YAK Extracted CSS:
89
--yak-css-import: url("./mixin:lastChildMixin",mixin);
910
}
1011
}
11-
*/ /*#__PURE__*/ styled.li(__styleYak.ListItem);
12+
*/ /*#__PURE__*/ __yak.__yak_li(__styleYak.ListItem);
1213
export default ListItem;

0 commit comments

Comments
 (0)