diff --git a/playground/rolldown-dev-mpa/__tests__/basic.spec.ts b/playground/rolldown-dev-mpa/__tests__/basic.spec.ts new file mode 100644 index 00000000000000..68b0e1f2f0363a --- /dev/null +++ b/playground/rolldown-dev-mpa/__tests__/basic.spec.ts @@ -0,0 +1,12 @@ +import { test } from 'vitest' +import { page } from '../../test-utils' + +test('basic', async () => { + await page.goto('/') + await page.getByRole('heading', { name: 'Home' }).click() + await page.getByText('Rendered by /index.js').click() + await page.getByRole('link', { name: 'About' }).click() + await page.waitForURL('/about') + await page.getByRole('heading', { name: 'About' }).click() + await page.getByText('Rendered by /about/index.js').click() +}) diff --git a/playground/rolldown-dev-mpa/package.json b/playground/rolldown-dev-mpa/package.json new file mode 100644 index 00000000000000..bf8bf186e5efe7 --- /dev/null +++ b/playground/rolldown-dev-mpa/package.json @@ -0,0 +1,10 @@ +{ + "name": "@vitejs/test-rolldown-dev-mpa", + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + } +} diff --git a/playground/rolldown-dev-mpa/src/about/index.html b/playground/rolldown-dev-mpa/src/about/index.html new file mode 100644 index 00000000000000..6c295a1671186f --- /dev/null +++ b/playground/rolldown-dev-mpa/src/about/index.html @@ -0,0 +1,15 @@ + + +
+ + + + + + diff --git a/playground/rolldown-dev-mpa/src/about/index.js b/playground/rolldown-dev-mpa/src/about/index.js new file mode 100644 index 00000000000000..2ed4b10fa69e81 --- /dev/null +++ b/playground/rolldown-dev-mpa/src/about/index.js @@ -0,0 +1,3 @@ +document.getElementById('root').innerHTML = ` +Rendered by /about/index.js: ${Math.random().toString(36).slice(2)}
+` diff --git a/playground/rolldown-dev-mpa/src/index.html b/playground/rolldown-dev-mpa/src/index.html new file mode 100644 index 00000000000000..0564e5db9b089f --- /dev/null +++ b/playground/rolldown-dev-mpa/src/index.html @@ -0,0 +1,15 @@ + + + + + + + diff --git a/playground/rolldown-dev-mpa/src/index.js b/playground/rolldown-dev-mpa/src/index.js new file mode 100644 index 00000000000000..a80b0213257e3a --- /dev/null +++ b/playground/rolldown-dev-mpa/src/index.js @@ -0,0 +1,3 @@ +document.getElementById('root').innerHTML = ` +Rendered by /index.js: ${Math.random().toString(36).slice(2)}
+` diff --git a/playground/rolldown-dev-mpa/vite.config.ts b/playground/rolldown-dev-mpa/vite.config.ts new file mode 100644 index 00000000000000..13b41466590a49 --- /dev/null +++ b/playground/rolldown-dev-mpa/vite.config.ts @@ -0,0 +1,23 @@ +import { defineConfig } from 'vite' + +export default defineConfig({ + clearScreen: false, + root: './src', + environments: { + client: { + build: { + rollupOptions: { + input: { + index: './index.html', + about: './about/index.html', + }, + }, + }, + }, + }, + experimental: { + rolldownDev: { + hmr: true, + }, + }, +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c2a8647ce1343a..ef17ff275d043c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1325,6 +1325,8 @@ importers: specifier: 0.10.64 version: 0.10.64 + playground/rolldown-dev-mpa: {} + playground/rolldown-dev-react: dependencies: react: