@buding0904/vitepad 0.2.0
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/LICENSE +21 -0
- package/README.md +196 -0
- package/dist/cli.cjs +785 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +774 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +782 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +770 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/frameworks.d.ts +28 -0
- package/dist/runtime/frameworks.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +17 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 buding0904
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>vitepad</h1>
|
|
3
|
+
|
|
4
|
+
<p><strong>Run any single frontend file with Vite</strong></p>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
<a href="https://www.npmjs.com/package/@buding0904/vitepad"><img src="https://img.shields.io/npm/v/@buding0904/vitepad.svg" alt="npm version" /></a>
|
|
8
|
+
<a href="./LICENSE"><img src="https://img.shields.io/npm/l/@buding0904/vitepad.svg" alt="license" /></a>
|
|
9
|
+
<img src="https://img.shields.io/badge/frameworks-React%20%7C%20Preact%20%7C%20Solid%20%7C%20Vue%20%7C%20Svelte-blue" alt="frameworks" />
|
|
10
|
+
<img src="https://img.shields.io/badge/Tailwind-v4-38bdf8" alt="Tailwind CSS" />
|
|
11
|
+
</p>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
`vitepad` creates a temporary Vite playground for one entry file. Use it to preview a component, test a small main entry, or compare the same file across different framework versions without creating a project or changing the current project's dependencies.
|
|
17
|
+
|
|
18
|
+
Tailwind CSS is enabled by default. Framework packages are resolved to exact npm versions, downloaded on demand, and cached under `~/.cache/vitepad/frameworks`. No ESLint, Biome, Husky, or formatting pipeline is included.
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
**Single-file Vite runner**
|
|
23
|
+
|
|
24
|
+
- Run `App.tsx`, `App.vue`, `App.svelte`, `main.ts`, `demo.js`, and similar files directly
|
|
25
|
+
- `.js`, `.mjs`, `.cjs`, `.ts`, `.mts`, and `.cts` are treated as main entry files
|
|
26
|
+
- `.jsx`, `.tsx`, `.vue`, and `.svelte` are treated as App component files and mounted into `#root`
|
|
27
|
+
- Extra Vite config can be merged with `--config`
|
|
28
|
+
|
|
29
|
+
**Frameworks**
|
|
30
|
+
|
|
31
|
+
- Built-in component wrappers for React, Preact, Solid, Vue, and Svelte
|
|
32
|
+
- JSX/TSX framework inference from imports, with React as the fallback
|
|
33
|
+
- Explicit framework selection with `--framework react`, `--framework vue`, etc.
|
|
34
|
+
- Version specs are supported, such as `react@18`, `vue@3.4`, `svelte@5`, or `react@latest`
|
|
35
|
+
|
|
36
|
+
**Version testing**
|
|
37
|
+
|
|
38
|
+
- Test the same component against different framework versions without touching `package.json`
|
|
39
|
+
- `latest` and semver ranges are resolved to exact versions before caching
|
|
40
|
+
- Cache keys use exact versions, for example `react-19.2.6`
|
|
41
|
+
- `--force-install` recreates the selected framework cache
|
|
42
|
+
|
|
43
|
+
**Styling and environment**
|
|
44
|
+
|
|
45
|
+
- Tailwind CSS v4 is available by default through `@tailwindcss/vite`
|
|
46
|
+
- User project `node_modules` is not modified
|
|
47
|
+
- Framework dependencies are exposed through the temporary Vite workspace
|
|
48
|
+
- No linting or formatting toolchain is installed
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install -g @buding0904/vitepad
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pnpm add -g @buding0904/vitepad
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
yarn global add @buding0904/vitepad
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
vitepad ./App.tsx
|
|
68
|
+
vitepad ./App.vue
|
|
69
|
+
vitepad ./App.svelte
|
|
70
|
+
vitepad ./main.ts
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
No install needed:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx @buding0904/vitepad ./App.tsx
|
|
77
|
+
pnpm dlx @buding0904/vitepad ./App.vue
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Framework Version Testing
|
|
81
|
+
|
|
82
|
+
Run the same entry with different framework versions:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
vitepad ./App.tsx --framework react@18
|
|
86
|
+
vitepad ./App.tsx --framework react@19
|
|
87
|
+
vitepad ./App.tsx --framework react@latest
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
vitepad ./App.vue --framework vue@3.4
|
|
92
|
+
vitepad ./App.vue --framework vue@latest
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
vitepad ./App.svelte --framework svelte@4
|
|
97
|
+
vitepad ./App.svelte --framework svelte@5
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## CLI
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
vitepad <entry> [options]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Options
|
|
107
|
+
|
|
108
|
+
| Option | Description |
|
|
109
|
+
|--------|-------------|
|
|
110
|
+
| `<entry>` | Entry file to run |
|
|
111
|
+
| `-f, --framework <name>` | `auto`, `react`, `preact`, `solid`, `vue`, `svelte`, or `vanilla`; version specs are supported, e.g. `react@18` |
|
|
112
|
+
| `--force-install` | Reinstall the selected framework cache |
|
|
113
|
+
| `-p, --port <number>` | Dev server port (default: `8000`) |
|
|
114
|
+
| `--host <host>` | Dev server host (default: `0.0.0.0`) |
|
|
115
|
+
| `--no-open` | Do not open the browser automatically |
|
|
116
|
+
| `-c, --config <file>` | Merge an extra Vite config file |
|
|
117
|
+
| `-h, --help` | Show help |
|
|
118
|
+
|
|
119
|
+
Examples:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
vitepad ./App.tsx --framework react@18 --port 3000
|
|
123
|
+
vitepad ./App.vue --host 127.0.0.1 --no-open
|
|
124
|
+
vitepad ./App.svelte --config ./vite.extra.js
|
|
125
|
+
vitepad ./App.tsx --framework react@latest --force-install
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Entry Rules
|
|
129
|
+
|
|
130
|
+
| Extension | Mode | Behavior |
|
|
131
|
+
|-----------|------|----------|
|
|
132
|
+
| `.js`, `.mjs`, `.cjs` | main | Imported as the app entry |
|
|
133
|
+
| `.ts`, `.mts`, `.cts` | main | Imported as the app entry |
|
|
134
|
+
| `.jsx`, `.tsx` | component | Mounted as an App component |
|
|
135
|
+
| `.vue` | component | Mounted with Vue |
|
|
136
|
+
| `.svelte` | component | Mounted with Svelte |
|
|
137
|
+
|
|
138
|
+
For main entry files, the file is responsible for mounting itself. For component entry files, vitepad creates the framework-specific mount code.
|
|
139
|
+
|
|
140
|
+
## Cache
|
|
141
|
+
|
|
142
|
+
Framework versions are resolved before installation:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
vitepad ./App.tsx --framework react
|
|
146
|
+
# react@latest -> react@19.2.6
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Framework caches are stored in:
|
|
150
|
+
|
|
151
|
+
```text
|
|
152
|
+
~/.cache/vitepad/frameworks
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Example cache directory:
|
|
156
|
+
|
|
157
|
+
```text
|
|
158
|
+
~/.cache/vitepad/frameworks/react-19.2.6
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
If a framework version is not cached, vitepad downloads it and prints install progress. The user's working directory and `node_modules` are left untouched.
|
|
162
|
+
|
|
163
|
+
## Local Development
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
pnpm install
|
|
167
|
+
pnpm run build
|
|
168
|
+
pnpm run typecheck
|
|
169
|
+
pnpm run smoke
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`pnpm run smoke` starts temporary Vite servers for main, React, Preact, Solid, Vue, and Svelte entries. It downloads framework caches on first run.
|
|
173
|
+
|
|
174
|
+
To test the CLI globally before publishing:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
pnpm run build
|
|
178
|
+
pnpm link --global
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Then run it from another project:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
cd /path/to/project
|
|
185
|
+
vitepad ./src/App.tsx
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Uninstall the linked global command:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
pnpm remove --global @buding0904/vitepad
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT
|