@tsrx/vite-plugin-react 0.0.50 → 0.0.52
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 +3 -3
- package/src/index.js +26 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Vite plugin for @tsrx/react (.tsrx modules)",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.52",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tsrx/react": "0.2.
|
|
23
|
+
"@tsrx/react": "0.2.20"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"vite": "*"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"react-router": "^7.15.0",
|
|
36
36
|
"typescript": "^5.9.3",
|
|
37
37
|
"vite": "^8.0.12",
|
|
38
|
-
"@tsrx/core": "0.1.
|
|
38
|
+
"@tsrx/core": "0.1.20"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"src",
|
package/src/index.js
CHANGED
|
@@ -42,6 +42,20 @@ export function tsrxReact(options = {}) {
|
|
|
42
42
|
/** @type {Map<string, string>} */
|
|
43
43
|
const css_cache = new Map();
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @param {string} source
|
|
47
|
+
* @param {string} id
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
function update_css_cache(source, id) {
|
|
51
|
+
const { css } = compile(source, id);
|
|
52
|
+
if (css) {
|
|
53
|
+
css_cache.set(id, css);
|
|
54
|
+
} else {
|
|
55
|
+
css_cache.delete(id);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
45
59
|
return /** @type {TsrxReactPlugin} */ ({
|
|
46
60
|
name: '@tsrx/vite-plugin-react',
|
|
47
61
|
enforce: 'pre',
|
|
@@ -92,6 +106,18 @@ export function tsrxReact(options = {}) {
|
|
|
92
106
|
|
|
93
107
|
return { code: result.code, map: result.map };
|
|
94
108
|
},
|
|
109
|
+
|
|
110
|
+
async handleHotUpdate(ctx) {
|
|
111
|
+
if (!TSRX_EXTENSION_PATTERN.test(ctx.file)) return;
|
|
112
|
+
|
|
113
|
+
update_css_cache(await ctx.read(), ctx.file);
|
|
114
|
+
|
|
115
|
+
const css_mod = ctx.server.moduleGraph.getModuleById('\0' + ctx.file + CSS_QUERY);
|
|
116
|
+
if (!css_mod) return ctx.modules;
|
|
117
|
+
|
|
118
|
+
ctx.server.moduleGraph.invalidateModule(css_mod);
|
|
119
|
+
return [...ctx.modules, css_mod];
|
|
120
|
+
},
|
|
95
121
|
});
|
|
96
122
|
}
|
|
97
123
|
|