@pyreon/vite-plugin 0.24.5 → 0.24.6
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/package.json +2 -4
- package/src/hmr-runtime.ts +0 -92
- package/src/index.ts +0 -2116
- package/src/rocketstyle-collapse.ts +0 -199
- package/src/tests/cache-eviction-on-delete.test.ts +0 -187
- package/src/tests/compat-resolve.test.ts +0 -260
- package/src/tests/cross-module-signals.test.ts +0 -425
- package/src/tests/dev-server.test.ts +0 -171
- package/src/tests/islands-registry.test.ts +0 -236
- package/src/tests/lpih-auto-bridge.test.ts +0 -408
- package/src/tests/lpih-injection.test.ts +0 -559
- package/src/tests/rocketstyle-collapse-dev.test.ts +0 -119
- package/src/tests/rocketstyle-collapse.test.ts +0 -352
- package/src/tests/ssr-no-external.test.ts +0 -82
- package/src/tests/vite-plugin.test.ts +0 -503
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/vite-plugin",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.6",
|
|
4
4
|
"description": "Vite plugin for Pyreon — .pyreon SFC support, HMR, compiler integration",
|
|
5
5
|
"homepage": "https://github.com/pyreon/pyreon/tree/main/packages/vite-plugin#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"lib",
|
|
17
17
|
"!lib/**/*.map",
|
|
18
|
-
"src",
|
|
19
18
|
"README.md",
|
|
20
19
|
"LICENSE"
|
|
21
20
|
],
|
|
@@ -26,7 +25,6 @@
|
|
|
26
25
|
"types": "./lib/types/index.d.ts",
|
|
27
26
|
"exports": {
|
|
28
27
|
".": {
|
|
29
|
-
"bun": "./src/index.ts",
|
|
30
28
|
"import": "./lib/index.js",
|
|
31
29
|
"types": "./lib/types/index.d.ts"
|
|
32
30
|
}
|
|
@@ -43,7 +41,7 @@
|
|
|
43
41
|
"prepublishOnly": "bun run build"
|
|
44
42
|
},
|
|
45
43
|
"dependencies": {
|
|
46
|
-
"@pyreon/compiler": "^0.24.
|
|
44
|
+
"@pyreon/compiler": "^0.24.6"
|
|
47
45
|
},
|
|
48
46
|
"devDependencies": {
|
|
49
47
|
"vite": "^8.0.0"
|
package/src/hmr-runtime.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pyreon HMR Runtime — preserves signal state across hot module reloads.
|
|
3
|
-
*
|
|
4
|
-
* Served as a virtual module `\0pyreon/hmr-runtime` and injected into every
|
|
5
|
-
* .tsx/.jsx module during development.
|
|
6
|
-
*
|
|
7
|
-
* ## How it works
|
|
8
|
-
*
|
|
9
|
-
* 1. The Vite plugin rewrites top-level `signal()` calls:
|
|
10
|
-
* `const count = signal(0)` → `const count = __hmr_signal("src/App.tsx", "count", signal, 0)`
|
|
11
|
-
*
|
|
12
|
-
* 2. `__hmr_signal` checks a global registry for a saved value under the
|
|
13
|
-
* composite key `moduleId + ":" + name`. If found, it creates the signal
|
|
14
|
-
* with the preserved value instead of the initial one.
|
|
15
|
-
*
|
|
16
|
-
* 3. When `import.meta.hot.accept()` fires, a `dispose` callback saves every
|
|
17
|
-
* registered signal's current value into the registry before the old module
|
|
18
|
-
* is discarded.
|
|
19
|
-
*
|
|
20
|
-
* The registry lives on `globalThis` so it survives module re-execution.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
interface SignalLike {
|
|
24
|
-
peek(): unknown
|
|
25
|
-
set(value: unknown): void
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface ModuleSignals {
|
|
29
|
-
entries: Map<string, SignalLike>
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const REGISTRY_KEY = '__pyreon_hmr_registry__'
|
|
33
|
-
|
|
34
|
-
type Registry = Map<string, Map<string, unknown>>
|
|
35
|
-
|
|
36
|
-
function getRegistry(): Registry {
|
|
37
|
-
const g = globalThis as Record<string, unknown>
|
|
38
|
-
if (!g[REGISTRY_KEY]) {
|
|
39
|
-
g[REGISTRY_KEY] = new Map()
|
|
40
|
-
}
|
|
41
|
-
return g[REGISTRY_KEY] as Registry
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const moduleSignals = new Map<string, ModuleSignals>()
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Called in place of `signal(initialValue)` for module-scope signals.
|
|
48
|
-
* Restores the previous value if the module is being hot-reloaded.
|
|
49
|
-
*/
|
|
50
|
-
export function __hmr_signal<T>(
|
|
51
|
-
moduleId: string,
|
|
52
|
-
name: string,
|
|
53
|
-
signalFn: (value: T, options?: { name?: string }) => SignalLike,
|
|
54
|
-
initialValue: T,
|
|
55
|
-
): ReturnType<typeof signalFn> {
|
|
56
|
-
const registry = getRegistry()
|
|
57
|
-
const saved = registry.get(moduleId)
|
|
58
|
-
|
|
59
|
-
// Use saved value if available (hot reload), otherwise use initial
|
|
60
|
-
const value = saved?.has(name) ? (saved.get(name) as T) : initialValue
|
|
61
|
-
|
|
62
|
-
const s = signalFn(value, { name })
|
|
63
|
-
|
|
64
|
-
// Track this signal for future disposal
|
|
65
|
-
let mod = moduleSignals.get(moduleId)
|
|
66
|
-
if (!mod) {
|
|
67
|
-
mod = { entries: new Map() }
|
|
68
|
-
moduleSignals.set(moduleId, mod)
|
|
69
|
-
}
|
|
70
|
-
mod.entries.set(name, s)
|
|
71
|
-
|
|
72
|
-
return s
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Called in the `import.meta.hot.dispose` callback.
|
|
77
|
-
* Saves all registered signal values for the module before it is discarded.
|
|
78
|
-
*/
|
|
79
|
-
export function __hmr_dispose(moduleId: string): void {
|
|
80
|
-
const mod = moduleSignals.get(moduleId)
|
|
81
|
-
if (!mod) return
|
|
82
|
-
|
|
83
|
-
const registry = getRegistry()
|
|
84
|
-
const saved = new Map<string, unknown>()
|
|
85
|
-
for (const [name, s] of mod.entries) {
|
|
86
|
-
saved.set(name, s.peek())
|
|
87
|
-
}
|
|
88
|
-
registry.set(moduleId, saved)
|
|
89
|
-
|
|
90
|
-
// Clear entries so the new module can re-register
|
|
91
|
-
moduleSignals.delete(moduleId)
|
|
92
|
-
}
|