@@ -2,6 +2,7 @@ import { expect, test } from '@playwright/test'
2
2
import { setupInlineFixture , useFixture , type Fixture } from './fixture'
3
3
import { defineStarterTest } from './starter'
4
4
import { expectNoPageError , waitForHydration } from './helper'
5
+ import { x } from 'tinyexec'
5
6
6
7
test . describe ( 'dev-default' , ( ) => {
7
8
const f = useFixture ( { root : 'examples/starter' , mode : 'dev' } )
@@ -94,3 +95,49 @@ test.describe('duplicate loadCss', () => {
94
95
} )
95
96
}
96
97
} )
98
+
99
+ test . describe ( 'isolated build' , ( ) => {
100
+ const root = 'examples/e2e/temp/isolated-build'
101
+
102
+ test . beforeAll ( async ( ) => {
103
+ // build twice programmatically to verify two plugin states are independent
104
+ async function testFn ( ) {
105
+ const vite = await import ( 'vite' )
106
+ const fs = await import ( 'node:fs' )
107
+
108
+ console . log ( '======== first build ========' )
109
+ const builder1 = await vite . createBuilder ( )
110
+ await builder1 . buildApp ( )
111
+
112
+ // edit files to remove client references
113
+ fs . rmSync ( `src/client.tsx` )
114
+ fs . writeFileSync (
115
+ `src/root.tsx` ,
116
+ fs
117
+ . readFileSync ( `src/root.tsx` , 'utf-8' )
118
+ . replace ( `import { ClientCounter } from './client.tsx'` , '' )
119
+ . replace ( `<ClientCounter />` , '' ) ,
120
+ )
121
+
122
+ console . log ( '======== second build ========' )
123
+ const builder2 = await vite . createBuilder ( )
124
+ await builder2 . buildApp ( )
125
+ }
126
+
127
+ await setupInlineFixture ( {
128
+ src : 'examples/starter' ,
129
+ dest : root ,
130
+ files : {
131
+ 'test.js' : `await (${ testFn . toString ( ) } )();\n` ,
132
+ } ,
133
+ } )
134
+ } )
135
+
136
+ test ( 'build' , async ( ) => {
137
+ const result = await x ( 'node' , [ './test.js' ] , {
138
+ nodeOptions : { cwd : root } ,
139
+ } )
140
+ expect ( result . stderr ) . not . toContain ( 'Build failed' )
141
+ expect ( result . exitCode ) . toBe ( 0 )
142
+ } )
143
+ } )
0 commit comments