@@ -4,57 +4,89 @@ import dedent from "dedent";
4
4
import { createProject , build , reactRouterConfig } from "./helpers/vite.js" ;
5
5
6
6
test . describe ( "Vite plugin order validation" , ( ) => {
7
- test . describe ( "MDX" , ( ) => {
8
- test ( "Framework Mode" , async ( ) => {
9
- let cwd = await createProject ( {
10
- "vite.config.ts" : dedent `
11
- import { reactRouter } from "@react-router/dev/vite";
7
+ test ( "Framework Mode with MDX plugin after React Router plugin" , async ( ) => {
8
+ let cwd = await createProject ( {
9
+ "vite.config.ts" : dedent `
10
+ import { reactRouter } from "@react-router/dev/vite";
11
+ import mdx from "@mdx-js/rollup";
12
+
13
+ export default {
14
+ plugins: [
15
+ reactRouter(),
16
+ mdx(),
17
+ ],
18
+ }
19
+ ` ,
20
+ } ) ;
21
+
22
+ let buildResult = build ( { cwd } ) ;
23
+ expect ( buildResult . stderr . toString ( ) ) . toContain (
24
+ 'Error: The "@mdx-js/rollup" plugin should be placed before the React Router plugin in your Vite config' ,
25
+ ) ;
26
+ } ) ;
27
+
28
+ test ( "RSC Framework Mode with MDX plugin after React Router plugin" , async ( ) => {
29
+ let cwd = await createProject (
30
+ {
31
+ "vite.config.js" : dedent `
32
+ import { defineConfig } from "vite";
33
+ import { __INTERNAL_DO_NOT_USE_OR_YOU_WILL_GET_A_STRONGLY_WORDED_LETTER__ } from "@react-router/dev/internal";
34
+ import rsc from "@vitejs/plugin-rsc";
12
35
import mdx from "@mdx-js/rollup";
13
36
14
- export default {
37
+ const { unstable_reactRouterRSC: reactRouterRSC } =
38
+ __INTERNAL_DO_NOT_USE_OR_YOU_WILL_GET_A_STRONGLY_WORDED_LETTER__;
39
+
40
+ export default defineConfig({
15
41
plugins: [
16
- reactRouter(),
42
+ reactRouterRSC(),
43
+ rsc(),
17
44
mdx(),
18
45
],
19
- }
46
+ });
20
47
` ,
21
- } ) ;
48
+ "react-router.config.ts" : reactRouterConfig ( {
49
+ viteEnvironmentApi : true ,
50
+ } ) ,
51
+ } ,
52
+ "rsc-vite-framework" ,
53
+ ) ;
22
54
23
- let buildResult = build ( { cwd } ) ;
24
- expect ( buildResult . stderr . toString ( ) ) . toContain (
25
- 'Error: The "@mdx-js/rollup" plugin should be placed before the React Router plugin in your Vite config file ' ,
26
- ) ;
27
- } ) ;
55
+ let buildResult = build ( { cwd } ) ;
56
+ expect ( buildResult . stderr . toString ( ) ) . toContain (
57
+ 'Error: The "@mdx-js/rollup" plugin should be placed before the React Router plugin in your Vite config' ,
58
+ ) ;
59
+ } ) ;
28
60
29
- test ( "RSC Framework Mode" , async ( ) => {
30
- let cwd = await createProject (
31
- {
32
- "vite.config.js" : dedent `
61
+ test ( "RSC Framework Mode with @vitejs/plugin-rsc before React Router plugin " , async ( ) => {
62
+ let cwd = await createProject (
63
+ {
64
+ "vite.config.js" : dedent `
33
65
import { defineConfig } from "vite";
34
66
import { __INTERNAL_DO_NOT_USE_OR_YOU_WILL_GET_A_STRONGLY_WORDED_LETTER__ } from "@react-router/dev/internal";
67
+ import rsc from "@vitejs/plugin-rsc";
35
68
import mdx from "@mdx-js/rollup";
36
69
37
70
const { unstable_reactRouterRSC: reactRouterRSC } =
38
71
__INTERNAL_DO_NOT_USE_OR_YOU_WILL_GET_A_STRONGLY_WORDED_LETTER__;
39
72
40
73
export default defineConfig({
41
74
plugins: [
75
+ rsc(),
42
76
reactRouterRSC(),
43
- mdx(),
44
77
],
45
78
});
46
79
` ,
47
- "react-router.config.ts" : reactRouterConfig ( {
48
- viteEnvironmentApi : true ,
49
- } ) ,
50
- } ,
51
- "rsc-vite-framework" ,
52
- ) ;
53
-
54
- let buildResult = build ( { cwd } ) ;
55
- expect ( buildResult . stderr . toString ( ) ) . toContain (
56
- 'Error: The "@mdx-js/rollup" plugin should be placed before the React Router plugin in your Vite config file' ,
57
- ) ;
58
- } ) ;
80
+ "react-router.config.ts" : reactRouterConfig ( {
81
+ viteEnvironmentApi : true ,
82
+ } ) ,
83
+ } ,
84
+ "rsc-vite-framework" ,
85
+ ) ;
86
+
87
+ let buildResult = build ( { cwd } ) ;
88
+ expect ( buildResult . stderr . toString ( ) ) . toContain (
89
+ 'Error: The "@vitejs/plugin-rsc" plugin should be placed after the React Router RSC plugin in your Vite config' ,
90
+ ) ;
59
91
} ) ;
60
92
} ) ;
0 commit comments