Skip to content
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

codspeed use tsup #29

Merged
merged 7 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ jobs:
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build benchmark suite
run: cd packages/benchmark && pnpm run codspeed
- name: Run benchmarks
uses: CodSpeedHQ/action@v1
with:
working-directory: "packages/benchmark"
run: pnpm run codspeed
run: NODE_ENV=production node --enable-source-maps ./codspeed/dist/index.bench.mjs
token: ${{ secrets.CODSPEED_TOKEN }}
3 changes: 2 additions & 1 deletion packages/benchmark/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ yarn-error.log*
# vercel
.vercel

benchmark/lighthouse
benchmark/lighthouse
codspeed/dist
1 change: 0 additions & 1 deletion packages/benchmark/codspeed/index.bench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { KanjiLetterComponentStyled } from "../letters/KanjiLetterComponent.styl
renderToString(<KanjiLetterComponentYak />).length;
})
.on("cycle", function (event: Benchmark.Event) {
console.log(event);
console.log(String(event.target));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use client";
import React, { type FunctionComponent } from 'react';
import { styled as styledYak } from '../../../packages/next-yak/runtime/';
import { styled as styledYak } from 'next-yak';

const JapaneseCard = styledYak.div("yak-class-0");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

"use client";
import React, { type FunctionComponent } from 'react';
import styled from 'styled-components';
import { styled } from 'styled-components';

const JapaneseCard = styled.div`
width: 100px;
Expand Down
5 changes: 1 addition & 4 deletions packages/benchmark/letters/gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function generateKanjiComponentFile() {
const fileContent = `
"use client";
import React, { type FunctionComponent } from 'react';
import ${lib === "next-yak" ? `{ styled as ${styled} }` : styled} from '${lib}';
import ${lib === "next-yak" ? `{ styled as ${styled} }` : `{ ${styled} }`} from '${lib}';

const JapaneseCard = ${styled}.div\`
width: 100px;
Expand Down Expand Up @@ -89,9 +89,6 @@ export const KanjiLetterComponent${
const compiled = "// @ts-nocheck\n" + fileContent.replace(
/`\n([^`]*)`/g,
(_, content) => `("yak-class-${i++}")`
).replace(
"import { styled as styledYak } from 'next-yak';",
"import { styled as styledYak } from '../../../packages/next-yak/runtime/';"
);
fs.writeFile(
`${__dirname}/KanjiLetterComponent.${lib}.compiled.tsx`,
Expand Down
6 changes: 4 additions & 2 deletions packages/benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"start": "next start",
"generate:letters": "node ./letters/gen.js",
"lighthouse": "node ./lighthouse.mjs",
"codspeed": "NODE_ENV=production tsx ./codspeed/index.bench.tsx"
"codspeed": "pnpm run codspeed:build && pnpm run codspeed:run",
"codspeed:build": "tsup ./codspeed/index.bench.tsx --sourcemap inline --format esm --target node20 --clean --outDir ./codspeed/dist --external benchmark --external react --external next-yak --external styled-components --external react-dom --external @codspeed/benchmark.js-plugin",
"codspeed:run": "NODE_ENV=production node ./codspeed/dist/index.bench.mjs"
},
"dependencies": {
"next": "14.0.2",
Expand All @@ -25,6 +27,6 @@
"tree-kill": "1.2.2",
"@codspeed/benchmark.js-plugin": "2.2.0",
"benchmark": "2.1.4",
"tsx": "4.1.1"
"tsup": "7.2.0"
}
}
61 changes: 34 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.