Package Exports
- @buding0904/vitepad
Readme
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.
UnoCSS 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.
Features
Single-file Vite runner
- Run
App.tsx,App.vue,App.svelte,main.ts,demo.js, and similar files directly .js,.mjs,.cjs,.ts,.mts, and.ctsare treated as main entry files.jsx,.tsx,.vue, and.svelteare treated as App component files and mounted into#root- Extra Vite config can be merged with
--config
Frameworks
- Built-in component wrappers for React, Preact, Solid, Vue, and Svelte
- JSX/TSX framework inference from imports, with React as the fallback
- Explicit framework selection with
--framework react,--framework vue, etc. - Version specs are supported, such as
react@18,vue@3.4,svelte@5, orreact@latest
Version testing
- Test the same component against different framework versions without touching
package.json latestand semver ranges are resolved to exact versions before caching- Cache keys use exact versions, for example
react-19.2.6
Styling and environment
- UnoCSS is available by default through
unocss/vitewithpresetUno - Framework dependencies are exposed through the temporary Vite workspace
- Missing framework packages are linked into local
node_modulesfor editor type resolution - Existing local packages are left untouched, and
package.jsonis not modified - No linting or formatting toolchain is installed
Install
npm install -g @buding0904/vitepadpnpm add -g @buding0904/vitepadyarn global add @buding0904/vitepadQuick Start
vitepad ./App.tsx
vitepad ./App.vue
vitepad ./App.svelte
vitepad ./main.tsNo install needed:
npx @buding0904/vitepad ./App.tsx
pnpm dlx @buding0904/vitepad ./App.vueFramework Version Testing
Run the same entry with different framework versions:
vitepad ./App.tsx --framework react@18
vitepad ./App.tsx --framework react@19
vitepad ./App.tsx --framework react@latestvitepad ./App.vue --framework vue@3.4
vitepad ./App.vue --framework vue@latestvitepad ./App.svelte --framework svelte@4
vitepad ./App.svelte --framework svelte@5CLI
vitepad <entry> [options]Options
| Option | Description |
|---|---|
<entry> |
Entry file to run |
-f, --framework <name> |
auto, react, preact, solid, vue, svelte, or vanilla; version specs are supported, e.g. react@18 |
-p, --port <number> |
Dev server port (default: 8000) |
--strictPort |
Exit if the configured port is already in use |
--host <host> |
Dev server host (default: 0.0.0.0) |
-c, --config <file> |
Merge an extra Vite config file |
-h, --help |
Show help |
Examples:
vitepad ./App.tsx --framework react@18 --port 3000
vitepad ./App.vue --host 127.0.0.1
vitepad ./App.svelte --config ./vite.extra.js
vitepad ./App.tsx --framework react@latestEditor Types
VSCode's TypeScript server resolves imports and JSX types from the opened file's directory tree, not from vitepad's temporary Vite workspace. To keep editor diagnostics aligned with the file you run, vitepad looks from the entry file directory up through its parent directories for framework packages before linking anything. If a package cannot be resolved from that directory tree, vitepad creates a lightweight symlink inside the entry file directory's node_modules.
For React, vitepad links react, react-dom, @types/react, and @types/react-dom when they are missing. Existing packages are left untouched, so a project that already has React installed keeps using its local version for editor types. Runtime dependencies still come from vitepad's cache, and vitepad does not write to package.json.
If multiple vitepad processes run React entries in the same directory with different React versions, runtime behavior is still isolated per process. Editor links are shared by that directory, so whichever version is linked first is the version VSCode sees; later runs keep existing local packages instead of replacing them.
Entry Rules
| Extension | Mode | Behavior |
|---|---|---|
.js, .mjs, .cjs |
main | Imported as the app entry |
.ts, .mts, .cts |
main | Imported as the app entry |
.jsx, .tsx |
component | Mounted as an App component |
.vue |
component | Mounted with Vue |
.svelte |
component | Mounted with Svelte |
For main entry files, the file is responsible for mounting itself. For component entry files, vitepad creates the framework-specific mount code.
Cache
Framework versions are resolved before installation:
vitepad ./App.tsx --framework react
# react@latest -> react@19.2.6Framework caches are stored in:
~/.cache/vitepad/frameworksExample cache directory:
~/.cache/vitepad/frameworks/react-19.2.6If a framework version is not cached, vitepad downloads it and prints install progress. The user's package.json is left untouched. Missing framework packages may be symlinked into local node_modules so editors can resolve imports and JSX types.
Local Development
pnpm install
pnpm run build
pnpm run typecheck
pnpm run smokepnpm run smoke starts temporary Vite servers for main, React, Preact, Solid, Vue, and Svelte entries. It downloads framework caches on first run.
To test the CLI globally before publishing:
pnpm run build
pnpm link --globalThen run it from another project:
cd /path/to/project
vitepad ./src/App.tsxUninstall the linked global command:
pnpm remove --global @buding0904/vitepadLicense
MIT