@@ -158,16 +158,25 @@ export async function setupIsolatedFixture(options: {
158158 filter : ( src ) => ! src . includes ( 'node_modules' ) ,
159159 } )
160160
161- // setup package.json overrides
162- const packagesDir = path . join ( import . meta. dirname , '..' , '..' )
163- const overrides = {
164- '@vitejs/plugin-rsc' : `file:${ path . join ( packagesDir , 'plugin-rsc' ) } ` ,
165- '@vitejs/plugin-react' : `file:${ path . join ( packagesDir , 'plugin-react' ) } ` ,
166- }
167- editFileJson ( path . join ( options . dest , 'package.json' ) , ( pkg : any ) => {
168- Object . assign ( ( ( pkg . pnpm ??= { } ) . overrides ??= { } ) , overrides )
169- return pkg
170- } )
161+ // extract workspace overrides
162+ const rootDir = path . join ( import . meta. dirname , '..' , '..' , '..' )
163+ const workspaceYaml = fs . readFileSync (
164+ path . join ( rootDir , 'pnpm-workspace.yaml' ) ,
165+ 'utf-8' ,
166+ )
167+ const overridesMatch = workspaceYaml . match (
168+ / o v e r r i d e s : \s * ( [ \s \S ] * ?) (? = \n \w | \n * $ ) / ,
169+ )
170+ const overridesSection = overridesMatch ? overridesMatch [ 0 ] : 'overrides:'
171+ const tempWorkspaceYaml = `\
172+ ${ overridesSection }
173+ '@vitejs/plugin-rsc': ${ JSON . stringify ( 'file:' + path . join ( rootDir , 'packages/plugin-rsc' ) ) }
174+ '@vitejs/plugin-react': ${ JSON . stringify ( 'file:' + path . join ( rootDir , 'packages/plugin-react' ) ) }
175+ `
176+ fs . writeFileSync (
177+ path . join ( options . dest , 'pnpm-workspace.yaml' ) ,
178+ tempWorkspaceYaml ,
179+ )
171180
172181 // install
173182 await x ( 'pnpm' , [ 'i' ] , {
@@ -183,17 +192,6 @@ export async function setupIsolatedFixture(options: {
183192 } )
184193}
185194
186- function editFileJson ( filepath : string , edit : ( s : string ) => string ) {
187- fs . writeFileSync (
188- filepath ,
189- JSON . stringify (
190- edit ( JSON . parse ( fs . readFileSync ( filepath , 'utf-8' ) ) ) ,
191- null ,
192- 2 ,
193- ) ,
194- )
195- }
196-
197195// inspired by
198196// https://github.com/remix-run/react-router/blob/433872f6ab098eaf946cc6c9cf80abf137420ad2/integration/helpers/vite.ts#L239
199197// for syntax highlighting of /* js */, use this extension
0 commit comments