diff --git a/packages/plugin-rsc/e2e/fixture.ts b/packages/plugin-rsc/e2e/fixture.ts index 0f3e2c169..4c927a271 100644 --- a/packages/plugin-rsc/e2e/fixture.ts +++ b/packages/plugin-rsc/e2e/fixture.ts @@ -213,10 +213,11 @@ export async function setupInlineFixture(options: { // write additional files if (options.files) { - for (const [filename, contents] of Object.entries(options.files)) { + for (let [filename, contents] of Object.entries(options.files)) { let filepath = path.join(options.dest, filename) fs.mkdirSync(path.dirname(filepath), { recursive: true }) // strip indent + contents = contents.replace(/^\n/, '') const indent = contents.match(/^\s*/)?.[0] ?? '' const strippedContents = contents .split('\n') diff --git a/packages/plugin-rsc/e2e/starter.test.ts b/packages/plugin-rsc/e2e/starter.test.ts index cccdd7b1a..8b1958471 100644 --- a/packages/plugin-rsc/e2e/starter.test.ts +++ b/packages/plugin-rsc/e2e/starter.test.ts @@ -143,6 +143,66 @@ test.describe(() => { }) }) +test.describe(() => { + const root = 'examples/e2e/temp/module-runner-hmr-false' + + test.beforeAll(async () => { + await setupInlineFixture({ + src: 'examples/starter', + dest: root, + files: { + 'vite.config.ts': /* js */ ` + import rsc from '@vitejs/plugin-rsc' + import react from '@vitejs/plugin-react' + import { defineConfig, createRunnableDevEnvironment } from 'vite' + + export default defineConfig({ + plugins: [ + react(), + rsc({ + entries: { + client: './src/framework/entry.browser.tsx', + ssr: './src/framework/entry.ssr.tsx', + rsc: './src/framework/entry.rsc.tsx', + } + }), + ], + environments: { + ssr: { + dev: { + createEnvironment(name, config) { + return createRunnableDevEnvironment(name, config, { + runnerOptions: { + hmr: false, + }, + }) + }, + }, + }, + rsc: { + dev: { + createEnvironment(name, config) { + return createRunnableDevEnvironment(name, config, { + runnerOptions: { + hmr: false, + }, + }) + }, + }, + }, + }, + }) + `, + }, + }) + }) + + test.describe('dev-module-runner-hmr-false', () => { + const f = useFixture({ root, mode: 'dev' }) + defineTest(f) + }) +}) + function defineTest(f: Fixture, variant?: 'no-ssr') { const waitForHydration: typeof waitForHydration_ = (page) => waitForHydration_(page, variant === 'no-ssr' ? '#root' : 'body')