@@ -41,44 +41,52 @@ export async function setup({ provide }: TestProject): Promise<void> {
4141 }
4242 } )
4343
44- // also setup dedicated copy for plugin-react-oxc tests
45- const oxcIgnoredDirs = new Set ( [
46- 'compiler' ,
47- 'compiler-react-18' ,
48- 'react-classic' ,
49- 'react-emotion' ,
50- 'node_modules' ,
51- ] )
52- const oxcPlaygrounds = (
44+ const playgrounds = (
5345 await fs . readdir ( path . resolve ( __dirname , '../playground' ) , {
5446 withFileTypes : true ,
5547 } )
56- ) . filter ( ( dirent ) => ! oxcIgnoredDirs . has ( dirent . name ) && dirent . isDirectory ( ) )
57- for ( const { name : playgroundName } of oxcPlaygrounds ) {
48+ ) . filter ( ( dirent ) => dirent . name !== 'node_modules' && dirent . isDirectory ( ) )
49+ for ( const { name : playgroundName } of playgrounds ) {
50+ // write vite proxy file to load vite from each playground
51+ await fs . writeFile (
52+ path . resolve ( tempDir , `${ playgroundName } /_vite-proxy.js` ) ,
53+ "export * from 'vite';" ,
54+ )
55+
56+ // also setup dedicated copy for plugin-react-oxc tests
57+ const oxcTestDir = path . resolve (
58+ __dirname ,
59+ '../playground' ,
60+ playgroundName ,
61+ '__tests__/oxc' ,
62+ )
63+ if ( ! ( await fs . exists ( oxcTestDir ) ) ) continue
64+
65+ const variantPlaygroundName = `${ playgroundName } __oxc`
5866 await fs . copy (
5967 path . resolve ( tempDir , playgroundName ) ,
60- path . resolve ( tempDir , ` ${ playgroundName } -oxc` ) ,
68+ path . resolve ( tempDir , variantPlaygroundName ) ,
6169 )
6270 await fs . remove (
6371 path . resolve (
6472 tempDir ,
65- `${ playgroundName } -oxc /node_modules/@vitejs/plugin-react` ,
73+ `${ variantPlaygroundName } /node_modules/@vitejs/plugin-react` ,
6674 ) ,
6775 )
6876 await fs . symlink (
6977 path . resolve ( __dirname , '../packages/plugin-react-oxc' ) ,
7078 path . resolve (
7179 tempDir ,
72- `${ playgroundName } -oxc /node_modules/@vitejs/plugin-react` ,
80+ `${ variantPlaygroundName } /node_modules/@vitejs/plugin-react` ,
7381 ) ,
7482 )
7583 await fs . symlink (
7684 path . resolve ( __dirname , '../packages/plugin-react-oxc/node_modules/vite' ) ,
77- path . resolve ( tempDir , `${ playgroundName } -oxc /node_modules/vite` ) ,
85+ path . resolve ( tempDir , `${ variantPlaygroundName } /node_modules/vite` ) ,
7886 )
7987 await fs . copy (
8088 path . resolve ( __dirname , '../packages/plugin-react-oxc/node_modules/.bin' ) ,
81- path . resolve ( tempDir , `${ playgroundName } -oxc /node_modules/.bin` ) ,
89+ path . resolve ( tempDir , `${ variantPlaygroundName } /node_modules/.bin` ) ,
8290 )
8391 }
8492}
0 commit comments