@@ -4,57 +4,89 @@ import dedent from "dedent";
44import { createProject , build , reactRouterConfig } from "./helpers/vite.js" ;
55
66test . 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";
1235 import mdx from "@mdx-js/rollup";
1336
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({
1541 plugins: [
16- reactRouter(),
42+ reactRouterRSC(),
43+ rsc(),
1744 mdx(),
1845 ],
19- }
46+ });
2047 ` ,
21- } ) ;
48+ "react-router.config.ts" : reactRouterConfig ( {
49+ viteEnvironmentApi : true ,
50+ } ) ,
51+ } ,
52+ "rsc-vite-framework" ,
53+ ) ;
2254
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+ } ) ;
2860
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 `
3365 import { defineConfig } from "vite";
3466 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";
3568 import mdx from "@mdx-js/rollup";
3669
3770 const { unstable_reactRouterRSC: reactRouterRSC } =
3871 __INTERNAL_DO_NOT_USE_OR_YOU_WILL_GET_A_STRONGLY_WORDED_LETTER__;
3972
4073 export default defineConfig({
4174 plugins: [
75+ rsc(),
4276 reactRouterRSC(),
43- mdx(),
4477 ],
4578 });
4679 ` ,
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+ ) ;
5991 } ) ;
6092} ) ;
0 commit comments