create-rolldown 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -118
- package/package.json +7 -3
- package/template-react/.editorconfig +15 -0
- package/template-react/CHANGELOG.md +20 -0
- package/template-react/CONTRIBUTING.md +46 -0
- package/template-react/LICENSE +21 -0
- package/template-react/README.md +164 -0
- package/template-react/package.json +57 -0
- package/template-react/playground/index.html +13 -0
- package/template-react/playground/public/rolldown.svg +1 -0
- package/template-react/playground/src/App.tsx +18 -0
- package/template-react/playground/src/index.tsx +10 -0
- package/template-react/playground/src/style.css +93 -0
- package/template-react/pnpm-lock.yaml +1356 -0
- package/template-react/rolldown.config.js +10 -0
- package/template-react/src/MyButton.tsx +18 -0
- package/template-react/src/index.ts +1 -0
- package/template-react/tsconfig.json +18 -0
- package/template-react/vite.config.ts +7 -0
- package/template-solid/.editorconfig +15 -0
- package/template-solid/CHANGELOG.md +20 -0
- package/template-solid/CONTRIBUTING.md +46 -0
- package/template-solid/LICENSE +21 -0
- package/template-solid/README.md +168 -0
- package/template-solid/package.json +60 -0
- package/template-solid/playground/index.html +13 -0
- package/template-solid/playground/public/rolldown.svg +1 -0
- package/template-solid/playground/src/App.tsx +18 -0
- package/template-solid/playground/src/index.tsx +5 -0
- package/template-solid/playground/src/style.css +93 -0
- package/template-solid/pnpm-lock.yaml +1565 -0
- package/template-solid/rolldown.config.js +12 -0
- package/template-solid/src/MyButton.tsx +18 -0
- package/template-solid/src/index.ts +1 -0
- package/template-solid/tsconfig.json +19 -0
- package/template-solid/vite.config.ts +7 -0
- package/template-svelte/.editorconfig +15 -0
- package/template-svelte/CHANGELOG.md +20 -0
- package/template-svelte/CONTRIBUTING.md +46 -0
- package/template-svelte/LICENSE +21 -0
- package/template-svelte/README.md +161 -0
- package/template-svelte/package.json +60 -0
- package/template-svelte/playground/index.html +13 -0
- package/template-svelte/playground/public/rolldown.svg +1 -0
- package/template-svelte/playground/src/App.svelte +30 -0
- package/template-svelte/playground/src/index.ts +9 -0
- package/template-svelte/playground/src/style.css +93 -0
- package/template-svelte/pnpm-lock.yaml +1230 -0
- package/template-svelte/rolldown.config.js +23 -0
- package/template-svelte/src/MyButton.svelte +15 -0
- package/template-svelte/src/index.ts +1 -0
- package/template-svelte/tsconfig.json +21 -0
- package/template-svelte/vite.config.ts +7 -0
- package/template-vanilla/.editorconfig +15 -0
- package/template-vanilla/CHANGELOG.md +19 -0
- package/template-vanilla/CONTRIBUTING.md +45 -0
- package/template-vanilla/LICENSE +21 -0
- package/template-vanilla/README.md +124 -0
- package/template-vanilla/package.json +47 -0
- package/template-vanilla/rolldown.config.js +9 -0
- package/template-vanilla/src/index.ts +42 -0
- package/template-vanilla/tsconfig.json +17 -0
- package/template-vue/.editorconfig +15 -0
- package/template-vue/CHANGELOG.md +20 -0
- package/template-vue/CONTRIBUTING.md +46 -0
- package/template-vue/LICENSE +21 -0
- package/template-vue/README.md +165 -0
- package/template-vue/package.json +57 -0
- package/template-vue/playground/index.html +13 -0
- package/template-vue/playground/public/rolldown.svg +1 -0
- package/template-vue/playground/src/App.vue +16 -0
- package/template-vue/playground/src/index.ts +5 -0
- package/template-vue/playground/src/style.css +93 -0
- package/template-vue/pnpm-lock.yaml +1140 -0
- package/template-vue/rolldown.config.js +12 -0
- package/template-vue/src/MyButton.vue +17 -0
- package/template-vue/src/index.ts +1 -0
- package/template-vue/tsconfig.json +20 -0
- package/template-vue/vite.config.ts +7 -0
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/create-rolldown)
|
|
4
4
|
[](https://github.com/rolldown/create-rolldown/blob/main/LICENSE)
|
|
5
|
+
[](https://github.com/sunny-117/create-rolldown)
|
|
6
|
+
[](https://github.com/sunny-117/create-rolldown)
|
|
5
7
|
|
|
6
8
|
Scaffolding tool for [Rolldown](https://rolldown.rs) library projects - a fast JavaScript bundler written in Rust.
|
|
7
9
|
|
|
@@ -79,27 +81,6 @@ Available templates:
|
|
|
79
81
|
svelte Svelte component library
|
|
80
82
|
```
|
|
81
83
|
|
|
82
|
-
## Examples
|
|
83
|
-
|
|
84
|
-
### Create a React library (components, hooks, utilities)
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
npm create rolldown@latest my-react-lib
|
|
88
|
-
# Select "react"
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Create a utility library and start immediately
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
npm create rolldown@latest my-utils -- --template vanilla --immediate
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Create a Vue composables library in CI/CD
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
npm create rolldown@latest my-vue-composables -- --template vue --no-interactive
|
|
101
|
-
```
|
|
102
|
-
|
|
103
84
|
## Supported Templates
|
|
104
85
|
|
|
105
86
|
| Template | Description | Use Cases | Playground |
|
|
@@ -110,64 +91,18 @@ npm create rolldown@latest my-vue-composables -- --template vue --no-interactive
|
|
|
110
91
|
| `solid` | SolidJS library with TypeScript | Solid components, primitives | ✅ Vite |
|
|
111
92
|
| `svelte` | Svelte 5 library with TypeScript | Svelte components, actions | ✅ Vite |
|
|
112
93
|
|
|
113
|
-
### Template Architecture
|
|
114
|
-
|
|
115
|
-
**Vanilla Template** - For pure TypeScript/JavaScript libraries:
|
|
116
|
-
|
|
117
|
-
```
|
|
118
|
-
your-library/
|
|
119
|
-
├── src/
|
|
120
|
-
│ └── index.ts # Main entry point
|
|
121
|
-
├── dist/ # Build output (generated)
|
|
122
|
-
├── rolldown.config.ts
|
|
123
|
-
├── tsconfig.json
|
|
124
|
-
└── package.json
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
**Framework Templates** (React, Vue, Solid, Svelte) - For framework-specific libraries:
|
|
128
|
-
|
|
129
|
-
```
|
|
130
|
-
your-library/
|
|
131
|
-
├── src/ # Component library source code
|
|
132
|
-
│ ├── index.ts # Main entry point (exports)
|
|
133
|
-
│ └── MyButton.* # Example component
|
|
134
|
-
├── playground/ # Development playground (Vite)
|
|
135
|
-
│ ├── src/
|
|
136
|
-
│ │ ├── App.* # Playground app
|
|
137
|
-
│ │ ├── index.* # Playground entry
|
|
138
|
-
│ │ └── style.css # Playground styles
|
|
139
|
-
│ ├── index.html
|
|
140
|
-
│ └── public/
|
|
141
|
-
├── dist/ # Build output (generated)
|
|
142
|
-
├── rolldown.config.js # Rolldown configuration
|
|
143
|
-
├── vite.config.ts # Vite configuration (for playground)
|
|
144
|
-
├── tsconfig.json
|
|
145
|
-
├── package.json
|
|
146
|
-
└── README.md
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
**Key Features:**
|
|
150
|
-
|
|
151
|
-
- `src/` - Your library source code (built with Rolldown)
|
|
152
|
-
- `playground/` - Development environment (powered by Vite with HMR)
|
|
153
|
-
- `npm run build` - Build library with Rolldown
|
|
154
|
-
- `npm run dev` - Watch mode for library development
|
|
155
|
-
- `npm run play` - Start Vite playground for testing your library
|
|
156
|
-
- Ready for npm publishing with proper exports configuration
|
|
157
|
-
- Perfect for component libraries, utility libraries, hooks, composables, and more
|
|
158
|
-
|
|
159
94
|
## Development
|
|
160
95
|
|
|
161
96
|
### Prerequisites
|
|
162
97
|
|
|
163
98
|
- Node.js 20.19.0+ or 22.12.0+
|
|
164
|
-
- pnpm (recommended)
|
|
99
|
+
- pnpm (recommended)
|
|
165
100
|
|
|
166
101
|
### Setup
|
|
167
102
|
|
|
168
103
|
```bash
|
|
169
104
|
# Clone the repository
|
|
170
|
-
git clone https://github.com/
|
|
105
|
+
git clone https://github.com/Sunny-117/create-rolldown.git
|
|
171
106
|
cd create-rolldown
|
|
172
107
|
|
|
173
108
|
# Install dependencies
|
|
@@ -185,6 +120,9 @@ pnpm test
|
|
|
185
120
|
# Run tests in watch mode
|
|
186
121
|
pnpm test:watch
|
|
187
122
|
|
|
123
|
+
# Generate test coverage report
|
|
124
|
+
pnpm test:coverage
|
|
125
|
+
|
|
188
126
|
# Type checking
|
|
189
127
|
pnpm typecheck
|
|
190
128
|
|
|
@@ -198,51 +136,6 @@ pnpm format
|
|
|
198
136
|
pnpm format:check
|
|
199
137
|
```
|
|
200
138
|
|
|
201
|
-
### Project Structure
|
|
202
|
-
|
|
203
|
-
```
|
|
204
|
-
create-rolldown/
|
|
205
|
-
├── src/
|
|
206
|
-
│ ├── cli.ts # Main CLI entry point
|
|
207
|
-
│ └── utils/ # Utility modules
|
|
208
|
-
│ ├── args.ts # Argument parsing
|
|
209
|
-
│ ├── command.ts # Command execution
|
|
210
|
-
│ ├── constants.ts # Framework definitions
|
|
211
|
-
│ ├── file.ts # File operations
|
|
212
|
-
│ ├── package-manager.ts # Package manager detection
|
|
213
|
-
│ ├── prompts.ts # Interactive prompts
|
|
214
|
-
│ ├── types.ts # TypeScript types
|
|
215
|
-
│ └── validation.ts # Input validation
|
|
216
|
-
├── __tests__/
|
|
217
|
-
│ └── cli.spec.ts # Integration tests
|
|
218
|
-
├── template-vanilla/ # Vanilla TS template
|
|
219
|
-
├── template-react/ # React template
|
|
220
|
-
├── template-vue/ # Vue template
|
|
221
|
-
├── template-solid/ # Solid template
|
|
222
|
-
├── template-svelte/ # Svelte template
|
|
223
|
-
├── index.js # CLI entry point
|
|
224
|
-
├── package.json
|
|
225
|
-
└── tsconfig.json
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
### Testing
|
|
229
|
-
|
|
230
|
-
The project uses a comprehensive testing strategy:
|
|
231
|
-
|
|
232
|
-
- **Unit Tests**: Test specific functions and edge cases
|
|
233
|
-
- **Property-Based Tests**: Test universal properties across many inputs using [fast-check](https://github.com/dubzzz/fast-check)
|
|
234
|
-
- **Integration Tests**: Test complete CLI workflows
|
|
235
|
-
|
|
236
|
-
Run tests:
|
|
237
|
-
|
|
238
|
-
```bash
|
|
239
|
-
# Run all tests once
|
|
240
|
-
pnpm test
|
|
241
|
-
|
|
242
|
-
# Run tests in watch mode
|
|
243
|
-
pnpm test:watch
|
|
244
|
-
```
|
|
245
|
-
|
|
246
139
|
### Adding a New Template
|
|
247
140
|
|
|
248
141
|
1. Create a new directory: `template-{framework}` (e.g., `template-preact`)
|
|
@@ -269,10 +162,6 @@ pnpm test:watch
|
|
|
269
162
|
6. **Update files** (package.json name, metadata)
|
|
270
163
|
7. **Optionally install dependencies** and start playground
|
|
271
164
|
|
|
272
|
-
## Requirements
|
|
273
|
-
|
|
274
|
-
- Node.js ^20.19.0 || >=22.12.0
|
|
275
|
-
|
|
276
165
|
## Contributing
|
|
277
166
|
|
|
278
167
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-rolldown",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Scaffolding tool for Rolldown projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bundler",
|
|
@@ -24,9 +24,11 @@
|
|
|
24
24
|
"create-rolldown": "index.js"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
|
+
"dist",
|
|
27
28
|
"index.js",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"README.md",
|
|
31
|
+
"template-*/**"
|
|
30
32
|
],
|
|
31
33
|
"type": "module",
|
|
32
34
|
"scripts": {
|
|
@@ -35,6 +37,7 @@
|
|
|
35
37
|
"typecheck": "tsc --noEmit",
|
|
36
38
|
"test": "vitest --run",
|
|
37
39
|
"test:watch": "vitest",
|
|
40
|
+
"test:coverage": "vitest --run --coverage",
|
|
38
41
|
"lint": "oxlint",
|
|
39
42
|
"format": "oxfmt",
|
|
40
43
|
"format:check": "oxfmt --check",
|
|
@@ -53,6 +56,7 @@
|
|
|
53
56
|
"@types/cross-spawn": "^6.0.6",
|
|
54
57
|
"@types/mri": "^1.1.5",
|
|
55
58
|
"@types/node": "^20.11.0",
|
|
59
|
+
"@vitest/coverage-v8": "^1.6.1",
|
|
56
60
|
"changelogen": "^0.6.2",
|
|
57
61
|
"execa": "^9.0.0",
|
|
58
62
|
"fast-check": "^3.15.0",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# EditorConfig helps maintain consistent coding styles
|
|
2
|
+
# https://editorconfig.org
|
|
3
|
+
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
[*]
|
|
7
|
+
charset = utf-8
|
|
8
|
+
end_of_line = lf
|
|
9
|
+
indent_style = space
|
|
10
|
+
indent_size = 2
|
|
11
|
+
insert_final_newline = true
|
|
12
|
+
trim_trailing_whitespace = true
|
|
13
|
+
|
|
14
|
+
[*.md]
|
|
15
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial release
|
|
13
|
+
- React component library setup with Rolldown
|
|
14
|
+
- Vite playground for development
|
|
15
|
+
- TypeScript support
|
|
16
|
+
- Example MyButton component
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
Created with [create-rolldown](https://github.com/sunny-117/create-rolldown)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing to this project! 🎉
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
1. Fork and clone the repository
|
|
8
|
+
2. Install dependencies:
|
|
9
|
+
```bash
|
|
10
|
+
npm install
|
|
11
|
+
```
|
|
12
|
+
3. Start the playground:
|
|
13
|
+
```bash
|
|
14
|
+
npm run play
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Making Changes
|
|
18
|
+
|
|
19
|
+
1. Create a new branch for your feature/fix
|
|
20
|
+
2. Make your changes in the `src/` directory
|
|
21
|
+
3. Test your changes in the playground
|
|
22
|
+
4. Build the library to ensure no errors:
|
|
23
|
+
```bash
|
|
24
|
+
npm run build
|
|
25
|
+
```
|
|
26
|
+
5. Run type checking:
|
|
27
|
+
```bash
|
|
28
|
+
npm run typecheck
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Submitting Changes
|
|
32
|
+
|
|
33
|
+
1. Commit your changes with a clear message
|
|
34
|
+
2. Push to your fork
|
|
35
|
+
3. Open a Pull Request with a description of your changes
|
|
36
|
+
|
|
37
|
+
## Code Style
|
|
38
|
+
|
|
39
|
+
- Follow the existing code style
|
|
40
|
+
- Use TypeScript for type safety
|
|
41
|
+
- Add JSDoc comments for public APIs
|
|
42
|
+
- Keep components simple and focused
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
This project was created with [create-rolldown](https://github.com/sunny-117/create-rolldown)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [year] [author]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Rolldown React Starter
|
|
2
|
+
|
|
3
|
+
> 🚀 Created with [create-rolldown](https://github.com/sunny-117/create-rolldown) - Fast scaffolding for Rolldown library projects
|
|
4
|
+
|
|
5
|
+
A modern React component library starter powered by Rolldown - the blazingly fast JavaScript bundler written in Rust.
|
|
6
|
+
|
|
7
|
+
## ✨ Features
|
|
8
|
+
|
|
9
|
+
- ⚡️ **Lightning Fast** - Powered by [Rolldown](https://rolldown.rs), a Rust-based bundler
|
|
10
|
+
- ⚛️ **React 19** - Latest React with full TypeScript support
|
|
11
|
+
- 🎮 **Live Playground** - Vite-powered dev environment with HMR
|
|
12
|
+
- 📦 **NPM Ready** - Pre-configured for publishing React libraries
|
|
13
|
+
- 🔧 **TypeScript First** - Full type safety and IntelliSense
|
|
14
|
+
- 🔄 **Watch Mode** - Instant feedback during library development
|
|
15
|
+
- 💡 **Perfect For** - React components, hooks, utilities, and UI libraries
|
|
16
|
+
|
|
17
|
+
## 🚀 Quick Start
|
|
18
|
+
|
|
19
|
+
Install dependencies:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install
|
|
23
|
+
# or
|
|
24
|
+
pnpm install
|
|
25
|
+
# or
|
|
26
|
+
yarn install
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 📦 Development Workflow
|
|
30
|
+
|
|
31
|
+
### 🎮 Run the playground (Recommended for development)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm run play
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Opens a Vite dev server at `http://localhost:5173` with:
|
|
38
|
+
|
|
39
|
+
- ⚡️ Hot Module Replacement (HMR)
|
|
40
|
+
- 🔄 Instant updates when you edit components
|
|
41
|
+
- 🎨 Live preview of your library
|
|
42
|
+
|
|
43
|
+
**Tip**: Edit `src/MyButton.tsx` and see changes instantly in the playground!
|
|
44
|
+
|
|
45
|
+
### 📦 Build the library
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run build
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Outputs to `dist/` directory with:
|
|
52
|
+
|
|
53
|
+
- `index.js` - ESM bundle
|
|
54
|
+
- `index.d.ts` - TypeScript declarations
|
|
55
|
+
|
|
56
|
+
### 🔄 Watch mode for library development
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm run dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Automatically rebuilds the library on file changes. Use this when:
|
|
63
|
+
|
|
64
|
+
- Testing your library in another project
|
|
65
|
+
- Preparing for publishing
|
|
66
|
+
- Running alongside the playground
|
|
67
|
+
|
|
68
|
+
### 🔍 Type checking
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm run typecheck
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 📁 Project Structure
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
your-library/
|
|
78
|
+
├── src/ # 📚 Your library source code
|
|
79
|
+
│ ├── index.ts # 📝 Main entry - export your components here
|
|
80
|
+
│ └── MyButton.tsx # 🎨 Example component (replace with yours)
|
|
81
|
+
│
|
|
82
|
+
├── playground/ # 🎮 Development playground (Vite)
|
|
83
|
+
│ ├── src/
|
|
84
|
+
│ │ ├── App.tsx # 🎪 Test your components here
|
|
85
|
+
│ │ ├── index.tsx # 🚪 Playground entry point
|
|
86
|
+
│ │ └── style.css # 🎨 Playground styles
|
|
87
|
+
│ ├── index.html # 📄 HTML template
|
|
88
|
+
│ └── public/ # 📁 Static assets
|
|
89
|
+
│
|
|
90
|
+
├── dist/ # 📦 Build output (generated)
|
|
91
|
+
│ ├── index.js # ESM bundle
|
|
92
|
+
│ └── index.d.ts # Type declarations
|
|
93
|
+
│
|
|
94
|
+
├── rolldown.config.js # ⚙️ Rolldown bundler config
|
|
95
|
+
├── vite.config.ts # ⚡️ Vite playground config
|
|
96
|
+
├── tsconfig.json # 🔧 TypeScript config
|
|
97
|
+
└── package.json # 📋 Package metadata
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 💡 Usage Example
|
|
101
|
+
|
|
102
|
+
After building and publishing, users can import your components:
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { MyButton } from 'your-library-name';
|
|
106
|
+
|
|
107
|
+
function App() {
|
|
108
|
+
return (
|
|
109
|
+
<div>
|
|
110
|
+
<MyButton />
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 📤 Publishing to NPM
|
|
117
|
+
|
|
118
|
+
1. Update `package.json` with your library details:
|
|
119
|
+
- `name` - Your package name (e.g., `@yourname/react-components`)
|
|
120
|
+
- `version` - Semantic version (start with `0.1.0`)
|
|
121
|
+
- `description` - What your library does
|
|
122
|
+
- `author` - Your name and email
|
|
123
|
+
- `repository` - Your git repository URL
|
|
124
|
+
- `keywords` - Help users find your package
|
|
125
|
+
|
|
126
|
+
2. Build the library:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npm run build
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
3. Test the build locally:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npm pack
|
|
136
|
+
# Creates a .tgz file you can test in another project
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
4. Publish to npm:
|
|
140
|
+
```bash
|
|
141
|
+
npm publish
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The `prepublishOnly` script ensures your library is built before publishing.
|
|
145
|
+
|
|
146
|
+
## 🎯 Best Practices
|
|
147
|
+
|
|
148
|
+
- **Export Strategy**: Export all public components from `src/index.ts`
|
|
149
|
+
- **Peer Dependencies**: React and ReactDOM are peer dependencies (users provide them)
|
|
150
|
+
- **Tree Shaking**: Use named exports for better tree-shaking
|
|
151
|
+
- **TypeScript**: Add proper types and JSDoc comments
|
|
152
|
+
- **Testing**: Test components in the playground before publishing
|
|
153
|
+
- **Versioning**: Follow [semantic versioning](https://semver.org/)
|
|
154
|
+
|
|
155
|
+
## 🔗 Learn More
|
|
156
|
+
|
|
157
|
+
- [Rolldown Documentation](https://rolldown.rs)
|
|
158
|
+
- [create-rolldown](https://github.com/sunny-117/create-rolldown)
|
|
159
|
+
- [React Documentation](https://react.dev)
|
|
160
|
+
- [TypeScript Handbook](https://www.typescriptlang.org/docs/)
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
Built with ❤️ using create-rolldown
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rolldown-react-starter",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "A starter for creating a React library with Rolldown.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"bundler",
|
|
7
|
+
"component",
|
|
8
|
+
"library",
|
|
9
|
+
"react",
|
|
10
|
+
"rolldown",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/author/library#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/author/library/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Author Name <author.name@mail.com>",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/author/library.git"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./dist/index.js",
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "rolldown -c rolldown.config.js",
|
|
39
|
+
"dev": "rolldown -c rolldown.config.js --watch",
|
|
40
|
+
"play": "vite",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"prepublishOnly": "pnpm run build"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^25.0.3",
|
|
46
|
+
"@types/react": "^19.2.8",
|
|
47
|
+
"@types/react-dom": "^19.2.3",
|
|
48
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
49
|
+
"rolldown": "^1.0.0-beta.60",
|
|
50
|
+
"typescript": "^5.9.3",
|
|
51
|
+
"vite": "^7.3.1"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"react": "^19.2.0",
|
|
55
|
+
"react-dom": "^19.2.0"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/rolldown.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Rolldown + React</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/index.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="46" fill="none" viewBox="0 0 48 46"><path fill="#863bff" d="M25.946 44.938c-.664.845-2.021.375-2.021-.698V33.937a2.26 2.26 0 0 0-2.262-2.262H10.287c-.92 0-1.456-1.04-.92-1.788l7.48-10.471c1.07-1.497 0-3.578-1.842-3.578H1.237c-.92 0-1.456-1.04-.92-1.788L10.013.474c.214-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.471c-1.07 1.498 0 3.579 1.842 3.579h11.377c.943 0 1.473 1.088.89 1.83L25.947 44.94z" style="fill:#863bff;fill:color(display-p3 .5252 .23 1);fill-opacity:1"/></svg>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MyButton } from '../../src';
|
|
2
|
+
|
|
3
|
+
export function App() {
|
|
4
|
+
return (
|
|
5
|
+
<>
|
|
6
|
+
<div>
|
|
7
|
+
<a href="https://rolldown.rs" target="_blank" rel="noopener noreferrer">
|
|
8
|
+
<img src="/rolldown.svg" className="logo" alt="Rolldown logo" />
|
|
9
|
+
</a>
|
|
10
|
+
</div>
|
|
11
|
+
<h1>Rolldown + React</h1>
|
|
12
|
+
<div className="card">
|
|
13
|
+
<MyButton />
|
|
14
|
+
</div>
|
|
15
|
+
<p className="read-the-docs">Click on the Rolldown logo to learn more</p>
|
|
16
|
+
</>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
.logo {
|
|
58
|
+
height: 6em;
|
|
59
|
+
padding: 1.5em;
|
|
60
|
+
will-change: filter;
|
|
61
|
+
transition: filter 300ms;
|
|
62
|
+
}
|
|
63
|
+
.logo:hover {
|
|
64
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.card {
|
|
68
|
+
padding: 2em;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
#app {
|
|
72
|
+
max-width: 1280px;
|
|
73
|
+
margin: 0 auto;
|
|
74
|
+
padding: 2rem;
|
|
75
|
+
text-align: center;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.read-the-docs {
|
|
79
|
+
color: #888;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@media (prefers-color-scheme: light) {
|
|
83
|
+
:root {
|
|
84
|
+
color: #213547;
|
|
85
|
+
background-color: #ffffff;
|
|
86
|
+
}
|
|
87
|
+
a:hover {
|
|
88
|
+
color: #747bff;
|
|
89
|
+
}
|
|
90
|
+
button {
|
|
91
|
+
background-color: #f9f9f9;
|
|
92
|
+
}
|
|
93
|
+
}
|