@@ -16,63 +16,39 @@ const templates = [
1616 ...getTemplates ( [ "rsc-vite-framework" ] ) ,
1717] ;
1818
19- const indexRoute = tsx `
20- // imports
21- import { useState, useEffect } from "react";
22-
23- export const meta = () => [{ title: "HMR updated title: 0" }]
24-
25- // loader
26-
27- export default function IndexRoute() {
28- // hooks
29- const [mounted, setMounted] = useState(false);
30- useEffect(() => {
31- setMounted(true);
32- }, []);
33-
34- return (
35- <div id="index">
36- <h2 data-title>Index</h2>
37- <input />
38- <p data-mounted>Mounted: {mounted ? "yes" : "no"}</p>
39- <p data-hmr>HMR updated: 0</p>
40- {/* elements */}
41- </div>
42- );
43- }
44- ` ;
45-
4619templates . forEach ( ( template ) => {
4720 const isRsc = template . name . includes ( "rsc" ) ;
48- const viteConfig = isRsc
49- ? tsx `
50- import { unstable_reactRouterRSC as reactRouterRSC } from '@react-router/dev/vite';
51- import rsc from '@vitejs/plugin-rsc';
52-
53- export default {
54- plugins: [
55- reactRouterRSC(),
56- rsc(),
57- ],
58- };
59- `
60- : tsx `
61- import { reactRouter } from '@react-router/dev/vite';
62-
63- export default {
64- plugins: [
65- reactRouter(),
66- ],
67- };
68- ` ;
6921
7022 test . describe ( `${ template . displayName } - HMR & HDR` , ( ) => {
7123 test . use ( {
7224 template : template . name ,
7325 files : {
74- "vite.config.ts" : viteConfig ,
75- "app/routes/_index.tsx" : indexRoute ,
26+ "app/routes/_index.tsx" : tsx `
27+ // imports
28+ import { useState, useEffect } from "react";
29+
30+ export const meta = () => [{ title: "HMR updated title: 0" }]
31+
32+ // loader
33+
34+ export default function IndexRoute() {
35+ // hooks
36+ const [mounted, setMounted] = useState(false);
37+ useEffect(() => {
38+ setMounted(true);
39+ }, []);
40+
41+ return (
42+ <div id="index">
43+ <h2 data-title>Index</h2>
44+ <input />
45+ <p data-mounted>Mounted: {mounted ? "yes" : "no"}</p>
46+ <p data-hmr>HMR updated: 0</p>
47+ {/* elements */}
48+ </div>
49+ );
50+ }
51+ ` ,
7652 } ,
7753 } ) ;
7854
0 commit comments