@pyreon/vite-plugin 0.1.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 +77 -0
- package/lib/analysis/index.js.html +5406 -0
- package/lib/index.js +256 -0
- package/lib/index.js.map +1 -0
- package/lib/types/index.d.ts +217 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index2.d.ts +22 -0
- package/lib/types/index2.d.ts.map +1 -0
- package/package.json +49 -0
- package/src/hmr-runtime.ts +92 -0
- package/src/index.ts +376 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Vit Bokisch
|
|
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,77 @@
|
|
|
1
|
+
# @pyreon/vite-plugin
|
|
2
|
+
|
|
3
|
+
Vite plugin for the Pyreon framework. Applies the Pyreon JSX reactive transform to `.tsx`, `.jsx`, and `.pyreon` files, and optionally adds SSR dev middleware.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add -D @pyreon/vite-plugin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start (SPA)
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// vite.config.ts
|
|
15
|
+
import pyreon from "@pyreon/vite-plugin"
|
|
16
|
+
import { defineConfig } from "vite"
|
|
17
|
+
|
|
18
|
+
export default defineConfig({
|
|
19
|
+
plugins: [pyreon()],
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## SSR Mode
|
|
24
|
+
|
|
25
|
+
Pass an `ssr` option to enable SSR dev middleware. The plugin will load your server entry via Vite's `ssrLoadModule` and call its exported `handler` function for every non-asset GET request.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
// vite.config.ts
|
|
29
|
+
import pyreon from "@pyreon/vite-plugin"
|
|
30
|
+
import { defineConfig } from "vite"
|
|
31
|
+
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
plugins: [pyreon({ ssr: { entry: "./src/entry-server.ts" } })],
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Your server entry must export a `handler` (or default export) with the signature `(req: Request) => Promise<Response>`:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// src/entry-server.ts
|
|
41
|
+
import { renderToString } from "@pyreon/runtime-server"
|
|
42
|
+
import { h } from "@pyreon/core"
|
|
43
|
+
import App from "./App"
|
|
44
|
+
|
|
45
|
+
export async function handler(req: Request): Promise<Response> {
|
|
46
|
+
const html = await renderToString(h(App, null))
|
|
47
|
+
return new Response(html, {
|
|
48
|
+
headers: { "Content-Type": "text/html" },
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For production, build client and server bundles separately:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
vite build # client bundle
|
|
57
|
+
vite build --ssr src/entry-server.ts --outDir dist/server # server bundle
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## API
|
|
61
|
+
|
|
62
|
+
### `pyreonPlugin(options?)`
|
|
63
|
+
|
|
64
|
+
Default export. Returns a Vite `Plugin`.
|
|
65
|
+
|
|
66
|
+
### Options
|
|
67
|
+
|
|
68
|
+
| Option | Type | Description |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `ssr.entry` | `string` | Server entry file path. Enables SSR dev middleware. |
|
|
71
|
+
|
|
72
|
+
## What It Does
|
|
73
|
+
|
|
74
|
+
- Configures `resolve.conditions: ["bun"]` so Vite resolves Pyreon workspace source files.
|
|
75
|
+
- Sets `esbuild.jsx` to `automatic` with `@pyreon/core` as the JSX import source.
|
|
76
|
+
- Transforms `.tsx`, `.jsx`, and `.pyreon` files through `@pyreon/compiler` for reactive JSX optimizations.
|
|
77
|
+
- In SSR mode, adds a catch-all middleware that renders pages through your server entry with full HMR support.
|