From 90ac39084cef34af16561f9a21af8322c355e994 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 8 Dec 2024 17:44:04 +0900 Subject: [PATCH] chore: add mpa example --- .../rolldown-dev-mpa/__tests__/basic.spec.ts | 12 ++++++++++ playground/rolldown-dev-mpa/package.json | 10 ++++++++ .../rolldown-dev-mpa/src/about/index.html | 15 ++++++++++++ .../rolldown-dev-mpa/src/about/index.js | 3 +++ playground/rolldown-dev-mpa/src/index.html | 15 ++++++++++++ playground/rolldown-dev-mpa/src/index.js | 3 +++ playground/rolldown-dev-mpa/vite.config.ts | 23 +++++++++++++++++++ pnpm-lock.yaml | 2 ++ 8 files changed, 83 insertions(+) create mode 100644 playground/rolldown-dev-mpa/__tests__/basic.spec.ts create mode 100644 playground/rolldown-dev-mpa/package.json create mode 100644 playground/rolldown-dev-mpa/src/about/index.html create mode 100644 playground/rolldown-dev-mpa/src/about/index.js create mode 100644 playground/rolldown-dev-mpa/src/index.html create mode 100644 playground/rolldown-dev-mpa/src/index.js create mode 100644 playground/rolldown-dev-mpa/vite.config.ts 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 @@ + + + + +
+

About

+ +
+
+ + + 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 @@ + + + + +
+

Home

+ +
+ +
+ + 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: