Skip to content

Commit 7223093

Browse files
authored
test(rsc): test module runner hmr: false (#595)
1 parent 5167266 commit 7223093

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

packages/plugin-rsc/e2e/fixture.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,11 @@ export async function setupInlineFixture(options: {
213213

214214
// write additional files
215215
if (options.files) {
216-
for (const [filename, contents] of Object.entries(options.files)) {
216+
for (let [filename, contents] of Object.entries(options.files)) {
217217
let filepath = path.join(options.dest, filename)
218218
fs.mkdirSync(path.dirname(filepath), { recursive: true })
219219
// strip indent
220+
contents = contents.replace(/^\n/, '')
220221
const indent = contents.match(/^\s*/)?.[0] ?? ''
221222
const strippedContents = contents
222223
.split('\n')

packages/plugin-rsc/e2e/starter.test.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,66 @@ test.describe(() => {
143143
})
144144
})
145145

146+
test.describe(() => {
147+
const root = 'examples/e2e/temp/module-runner-hmr-false'
148+
149+
test.beforeAll(async () => {
150+
await setupInlineFixture({
151+
src: 'examples/starter',
152+
dest: root,
153+
files: {
154+
'vite.config.ts': /* js */ `
155+
import rsc from '@vitejs/plugin-rsc'
156+
import react from '@vitejs/plugin-react'
157+
import { defineConfig, createRunnableDevEnvironment } from 'vite'
158+
159+
export default defineConfig({
160+
plugins: [
161+
react(),
162+
rsc({
163+
entries: {
164+
client: './src/framework/entry.browser.tsx',
165+
ssr: './src/framework/entry.ssr.tsx',
166+
rsc: './src/framework/entry.rsc.tsx',
167+
}
168+
}),
169+
],
170+
environments: {
171+
ssr: {
172+
dev: {
173+
createEnvironment(name, config) {
174+
return createRunnableDevEnvironment(name, config, {
175+
runnerOptions: {
176+
hmr: false,
177+
},
178+
})
179+
},
180+
},
181+
},
182+
rsc: {
183+
dev: {
184+
createEnvironment(name, config) {
185+
return createRunnableDevEnvironment(name, config, {
186+
runnerOptions: {
187+
hmr: false,
188+
},
189+
})
190+
},
191+
},
192+
},
193+
},
194+
})
195+
`,
196+
},
197+
})
198+
})
199+
200+
test.describe('dev-module-runner-hmr-false', () => {
201+
const f = useFixture({ root, mode: 'dev' })
202+
defineTest(f)
203+
})
204+
})
205+
146206
function defineTest(f: Fixture, variant?: 'no-ssr') {
147207
const waitForHydration: typeof waitForHydration_ = (page) =>
148208
waitForHydration_(page, variant === 'no-ssr' ? '#root' : 'body')

0 commit comments

Comments
 (0)