Skip to content

Commit 5a6f456

Browse files
authored
feat: add tsdown example (#115)
1 parent c98cbb2 commit 5a6f456

File tree

19 files changed

+3067
-596
lines changed

19 files changed

+3067
-596
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: lts/*
23+
24+
- run: npx changelogithub
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Unit Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Install pnpm
17+
uses: pnpm/[email protected]
18+
19+
- name: Set node LTS
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: lts/*
23+
cache: pnpm
24+
25+
- name: Install
26+
run: pnpm install
27+
28+
- name: Build
29+
run: pnpm run build
30+
31+
- name: Lint
32+
run: pnpm run lint
33+
34+
- name: Typecheck
35+
run: pnpm run typecheck
36+
37+
- name: Test
38+
run: pnpm run test

examples/tsdown/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
*.log
4+
.DS_Store
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.formatOnSave": true
3+
}

examples/tsdown/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# react-components-starter
2+
3+
A starter for creating a React component library.
4+
5+
## Development
6+
7+
- Install dependencies:
8+
9+
```bash
10+
npm install
11+
```
12+
13+
- Run the playground:
14+
15+
```bash
16+
npm run playground
17+
```
18+
19+
- Run the unit tests:
20+
21+
```bash
22+
npm run test
23+
```
24+
25+
- Build the library:
26+
27+
```bash
28+
npm run build
29+
```

examples/tsdown/package.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "react-components-starter",
3+
"version": "0.0.0",
4+
"description": "A starter for creating a React component library.",
5+
"type": "module",
6+
"license": "MIT",
7+
"homepage": "https://github.com/author/library#readme",
8+
"bugs": {
9+
"url": "https://github.com/author/library/issues"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/author/library.git"
14+
},
15+
"author": "Author Name <[email protected]>",
16+
"files": [
17+
"dist"
18+
],
19+
"main": "./dist/index.js",
20+
"module": "./dist/index.js",
21+
"types": "./dist/index.d.ts",
22+
"exports": {
23+
".": "./dist/index.js",
24+
"./package.json": "./package.json"
25+
},
26+
"publishConfig": {
27+
"access": "public"
28+
},
29+
"scripts": {
30+
"build": "tsdown",
31+
"dev": "tsdown --watch",
32+
"playground": "vite --config playground/vite.config.ts",
33+
"test": "vitest",
34+
"typecheck": "tsc --noEmit",
35+
"release": "bumpp && pnpm publish",
36+
"prepublishOnly": "pnpm run build"
37+
},
38+
"devDependencies": {
39+
"@testing-library/jest-dom": "^6.6.3",
40+
"@testing-library/react": "^16.3.0",
41+
"@types/node": "^22.15.17",
42+
"@types/react": "^19.1.3",
43+
"@types/react-dom": "^19.1.4",
44+
"@vitejs/plugin-react": "^4.4.1",
45+
"bumpp": "^10.1.0",
46+
"happy-dom": "^17.4.6",
47+
"react": "^19.1.0",
48+
"react-dom": "^19.1.0",
49+
"tsdown": "^0.11.1",
50+
"typescript": "^5.8.3",
51+
"vite": "npm:rolldown-vite@latest",
52+
"vitest": "^3.1.3",
53+
"zephyr-rolldown-plugin": "^0.1.0-next.1"
54+
}
55+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>React Components Starter</title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
<script type="module" src="/src/index.tsx"></script>
11+
</body>
12+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { MyButton } from '../../src'
2+
3+
export function App() {
4+
return (
5+
<>
6+
<MyButton type="primary" />
7+
</>
8+
)
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { StrictMode } from 'react'
2+
import { createRoot } from 'react-dom/client'
3+
import { App } from './App.tsx'
4+
import './style.css'
5+
6+
createRoot(document.querySelector('#app')!).render(
7+
<StrictMode>
8+
<App />
9+
</StrictMode>,
10+
)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
:root {
2+
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
3+
line-height: 1.5;
4+
font-weight: 400;
5+
6+
color-scheme: light dark;
7+
color: rgba(255, 255, 255, 0.87);
8+
background-color: #242424;
9+
10+
font-synthesis: none;
11+
text-rendering: optimizeLegibility;
12+
-webkit-font-smoothing: antialiased;
13+
-moz-osx-font-smoothing: grayscale;
14+
}
15+
16+
a {
17+
font-weight: 500;
18+
color: #646cff;
19+
text-decoration: inherit;
20+
}
21+
a:hover {
22+
color: #535bf2;
23+
}
24+
25+
body {
26+
margin: 0;
27+
display: flex;
28+
place-items: center;
29+
min-width: 320px;
30+
min-height: 100vh;
31+
}
32+
33+
h1 {
34+
font-size: 3.2em;
35+
line-height: 1.1;
36+
}
37+
38+
button {
39+
border-radius: 8px;
40+
border: 1px solid transparent;
41+
padding: 0.6em 1.2em;
42+
font-size: 1em;
43+
font-weight: 500;
44+
font-family: inherit;
45+
background-color: #1a1a1a;
46+
cursor: pointer;
47+
transition: border-color 0.25s;
48+
}
49+
button:hover {
50+
border-color: #646cff;
51+
}
52+
button:focus,
53+
button:focus-visible {
54+
outline: 4px auto -webkit-focus-ring-color;
55+
}
56+
57+
.card {
58+
padding: 2em;
59+
}
60+
61+
#app {
62+
max-width: 1280px;
63+
margin: 0 auto;
64+
padding: 2rem;
65+
text-align: center;
66+
}
67+
68+
@media (prefers-color-scheme: light) {
69+
:root {
70+
color: #213547;
71+
background-color: #ffffff;
72+
}
73+
a:hover {
74+
color: #747bff;
75+
}
76+
button {
77+
background-color: #f9f9f9;
78+
}
79+
}

0 commit comments

Comments
 (0)