diff --git a/docs/guide/ssr.md b/docs/guide/ssr.md
index 2761161216d4ce..0e50dcb2358dd5 100644
--- a/docs/guide/ssr.md
+++ b/docs/guide/ssr.md
@@ -18,8 +18,8 @@ If you have questions, the community is usually helpful at [Vite Discord's #ssr
Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be used as references for this guide:
-- [Vue 3](https://github.com/vitejs/vite/tree/main/playground/ssr-vue)
-- [React](https://github.com/vitejs/vite/tree/main/playground/ssr-react)
+- [Vue 3](https://github.com/vitejs/vite-plugin-vue/tree/main/playground/ssr-vue)
+- [React](https://github.com/vitejs/vite-plugin-vue/tree/main/playground/ssr-react)
## Source Structure
@@ -177,7 +177,7 @@ Then, in `server.js` we need to add some production specific logic by checking `
- Move the creation and all usage of the `vite` dev server behind dev-only conditional branches, then add static file serving middlewares to serve files from `dist/client`.
-Refer to the [Vue](https://github.com/vitejs/vite/tree/main/playground/ssr-vue) and [React](https://github.com/vitejs/vite/tree/main/playground/ssr-react) demos for a working setup.
+Refer to the [Vue](https://github.com/vitejs/vite-plugin-vue/tree/main/playground/ssr-vue) and [React](https://github.com/vitejs/vite-plugin-react/tree/main/playground/ssr-react) demos for a working setup.
## Generating Preload Directives
@@ -201,11 +201,11 @@ const html = await vueServerRenderer.renderToString(app, ctx)
// ctx.modules is now a Set of module IDs that were used during the render
```
-In the production branch of `server.js` we need to read and pass the manifest to the `render` function exported by `src/entry-server.js`. This would provide us with enough information to render preload directives for files used by async routes! See [demo source](https://github.com/vitejs/vite/blob/main/playground/ssr-vue/src/entry-server.js) for a full example.
+In the production branch of `server.js` we need to read and pass the manifest to the `render` function exported by `src/entry-server.js`. This would provide us with enough information to render preload directives for files used by async routes! See [demo source](https://github.com/vitejs/vite-plugin-vue/blob/main/playground/ssr-vue/src/entry-server.js) for a full example.
## Pre-Rendering / SSG
-If the routes and the data needed for certain routes are known ahead of time, we can pre-render these routes into static HTML using the same logic as production SSR. This can also be considered a form of Static-Site Generation (SSG). See [demo pre-render script](https://github.com/vitejs/vite/blob/main/playground/ssr-vue/prerender.js) for working example.
+If the routes and the data needed for certain routes are known ahead of time, we can pre-render these routes into static HTML using the same logic as production SSR. This can also be considered a form of Static-Site Generation (SSG). See [demo pre-render script](https://github.com/vitejs/vite-plugin-vue/blob/main/playground/ssr-vue/prerender.js) for working example.
## SSR Externals
diff --git a/playground/react-classic/App.jsx b/playground/react-classic/App.jsx
deleted file mode 100644
index 1de7461b163776..00000000000000
--- a/playground/react-classic/App.jsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { useState } from 'react'
-
-function App() {
- const [count, setCount] = useState(0)
- return (
-
-
- Hello Vite + React
-
- setCount((count) => count + 1)}>
- count is: {count}
-
-
-
- Edit App.jsx
and save to test HMR updates.
-
-
- Learn React
-
-
-
- )
-}
-
-export default App
diff --git a/playground/react-classic/__tests__/react.spec.ts b/playground/react-classic/__tests__/react.spec.ts
deleted file mode 100644
index 15f6319220d7f2..00000000000000
--- a/playground/react-classic/__tests__/react.spec.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { expect, test } from 'vitest'
-import { editFile, isServe, page, untilUpdated } from '~utils'
-
-test('should render', async () => {
- expect(await page.textContent('h1')).toMatch('Hello Vite + React')
-})
-
-test('should update', async () => {
- expect(await page.textContent('button')).toMatch('count is: 0')
- await page.click('button')
- expect(await page.textContent('button')).toMatch('count is: 1')
-})
-
-test('should hmr', async () => {
- editFile('App.jsx', (code) => code.replace('Vite + React', 'Updated'))
- await untilUpdated(() => page.textContent('h1'), 'Hello Updated')
- // preserve state
- expect(await page.textContent('button')).toMatch('count is: 1')
-})
-
-test.runIf(isServe)(
- 'should have annotated jsx with file location metadata',
- async () => {
- const meta = await page.evaluate(() => {
- const button = document.querySelector('button')
- const key = Object.keys(button).find(
- (key) => key.indexOf('__reactFiber') === 0
- )
- return button[key]._debugSource
- })
- // If the evaluate call doesn't crash, and the returned metadata has
- // the expected fields, we're good.
- expect(Object.keys(meta).sort()).toEqual([
- 'columnNumber',
- 'fileName',
- 'lineNumber'
- ])
- }
-)
diff --git a/playground/react-classic/index.html b/playground/react-classic/index.html
deleted file mode 100644
index f0015ceb9829a3..00000000000000
--- a/playground/react-classic/index.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
diff --git a/playground/react-classic/package.json b/playground/react-classic/package.json
deleted file mode 100644
index 2210af8d89f986..00000000000000
--- a/playground/react-classic/package.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "test-react-classic",
- "private": true,
- "version": "0.0.0",
- "scripts": {
- "dev": "vite",
- "build": "vite build",
- "debug": "node --inspect-brk ../../packages/vite/bin/vite",
- "preview": "vite preview"
- },
- "dependencies": {
- "react": "^18.2.0",
- "react-dom": "^18.2.0"
- },
- "devDependencies": {
- "@vitejs/plugin-react": "^3.0.0-alpha.0"
- },
- "babel": {
- "presets": [
- "@babel/preset-env"
- ]
- }
-}
diff --git a/playground/react-classic/vite.config.ts b/playground/react-classic/vite.config.ts
deleted file mode 100644
index a2044e99ae2f3c..00000000000000
--- a/playground/react-classic/vite.config.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import react from '@vitejs/plugin-react'
-import type { UserConfig } from 'vite'
-
-const config: UserConfig = {
- plugins: [
- react({
- jsxRuntime: 'classic'
- })
- ],
- build: {
- // to make tests faster
- minify: false
- }
-}
-
-export default config
diff --git a/playground/react-emotion/App.jsx b/playground/react-emotion/App.jsx
deleted file mode 100644
index b3715369614530..00000000000000
--- a/playground/react-emotion/App.jsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import { useState } from 'react'
-import { css } from '@emotion/react'
-
-import _Switch from 'react-switch'
-const Switch = _Switch.default || _Switch
-
-export function Counter() {
- const [count, setCount] = useState(0)
-
- return (
- setCount((count) => count + 1)}
- >
- count is: {count}
-
- )
-}
-
-function FragmentTest() {
- const [checked, setChecked] = useState(false)
- return (
- <>
-
-
-
-
- >
- )
-}
-
-function App() {
- return (
-
- )
-}
-
-export default App
diff --git a/playground/react-emotion/__tests__/react.spec.ts b/playground/react-emotion/__tests__/react.spec.ts
deleted file mode 100644
index d326a4ad0abeb8..00000000000000
--- a/playground/react-emotion/__tests__/react.spec.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { expect, test } from 'vitest'
-import { editFile, page, untilUpdated } from '~utils'
-
-test('should render', async () => {
- expect(await page.textContent('h1')).toMatch(
- 'Hello Vite + React + @emotion/react'
- )
-})
-
-test('should update', async () => {
- expect(await page.textContent('button')).toMatch('count is: 0')
- await page.click('button')
- expect(await page.textContent('button')).toMatch('count is: 1')
-})
-
-test('should hmr', async () => {
- editFile('App.jsx', (code) =>
- code.replace('Vite + React + @emotion/react', 'Updated')
- )
- await untilUpdated(() => page.textContent('h1'), 'Hello Updated')
- // preserve state
- expect(await page.textContent('button')).toMatch('count is: 1')
-})
-
-test('should update button style', async () => {
- function getButtonBorderStyle() {
- return page.evaluate(() => {
- return window.getComputedStyle(document.querySelector('button')).border
- })
- }
-
- await page.evaluate(() => {
- return document.querySelector('button').style
- })
-
- expect(await getButtonBorderStyle()).toMatch('2px solid rgb(0, 0, 0)')
-
- editFile('App.jsx', (code) =>
- code.replace('border: 2px solid #000', 'border: 4px solid red')
- )
-
- await untilUpdated(getButtonBorderStyle, '4px solid rgb(255, 0, 0)')
-
- // preserve state
- expect(await page.textContent('button')).toMatch('count is: 1')
-})
diff --git a/playground/react-emotion/index.html b/playground/react-emotion/index.html
deleted file mode 100644
index f0015ceb9829a3..00000000000000
--- a/playground/react-emotion/index.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
diff --git a/playground/react-emotion/package.json b/playground/react-emotion/package.json
deleted file mode 100644
index 1167cf3e26e7f0..00000000000000
--- a/playground/react-emotion/package.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "name": "test-react-emotion",
- "private": true,
- "version": "0.0.0",
- "scripts": {
- "dev": "vite",
- "build": "vite build",
- "debug": "node --inspect-brk ../../packages/vite/bin/vite",
- "preview": "vite preview"
- },
- "dependencies": {
- "@emotion/react": "^11.10.5",
- "react": "^18.2.0",
- "react-dom": "^18.2.0",
- "react-switch": "^7.0.0"
- },
- "devDependencies": {
- "@babel/plugin-proposal-pipeline-operator": "^7.18.9",
- "@emotion/babel-plugin": "^11.10.5",
- "@vitejs/plugin-react": "^3.0.0-alpha.0"
- },
- "babel": {
- "presets": [
- "@babel/preset-env"
- ]
- }
-}
diff --git a/playground/react-emotion/vite.config.ts b/playground/react-emotion/vite.config.ts
deleted file mode 100644
index 197e04f870d835..00000000000000
--- a/playground/react-emotion/vite.config.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import react from '@vitejs/plugin-react'
-import { defineConfig } from 'vite'
-
-export default defineConfig({
- plugins: [
- react({
- jsxImportSource: '@emotion/react',
- babel: {
- plugins: ['@emotion/babel-plugin']
- }
- })
- ],
- clearScreen: false,
- build: {
- // to make tests faster
- minify: false
- }
-})
diff --git a/playground/react-env/App.jsx b/playground/react-env/App.jsx
deleted file mode 100644
index 216b2989b5106f..00000000000000
--- a/playground/react-env/App.jsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { useState } from 'react'
-
-function App() {
- const [count, setCount] = useState(0)
- return (
-
-
-
- )
-}
-
-export default App
diff --git a/playground/react-env/__tests__/react.spec.ts b/playground/react-env/__tests__/react.spec.ts
deleted file mode 100644
index 12686328dc816e..00000000000000
--- a/playground/react-env/__tests__/react.spec.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { expect, test } from 'vitest'
-import { page } from '~utils'
-
-test('should work', async () => {
- expect(await page.textContent('h1')).toMatch('Hello Vite + React')
-})
diff --git a/playground/react-env/index.html b/playground/react-env/index.html
deleted file mode 100644
index f0015ceb9829a3..00000000000000
--- a/playground/react-env/index.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
diff --git a/playground/react-env/package.json b/playground/react-env/package.json
deleted file mode 100644
index 3232076cfa0e4c..00000000000000
--- a/playground/react-env/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "test-react-env",
- "private": true,
- "version": "0.0.0",
- "scripts": {
- "dev": "vite",
- "build": "vite build",
- "debug": "node --inspect-brk ../../packages/vite/bin/vite",
- "preview": "vite preview"
- },
- "dependencies": {
- "react": "^18.2.0",
- "react-dom": "^18.2.0"
- },
- "devDependencies": {
- "@vitejs/plugin-react": "^3.0.0-alpha.0"
- }
-}
diff --git a/playground/react-env/vite.config.ts b/playground/react-env/vite.config.ts
deleted file mode 100644
index 4c1003b0e4687a..00000000000000
--- a/playground/react-env/vite.config.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import react from '@vitejs/plugin-react'
-import type { UserConfig } from 'vite'
-
-// Overriding the NODE_ENV set by vitest
-process.env.NODE_ENV = ''
-
-const config: UserConfig = {
- plugins: [react()],
- mode: 'staging',
- build: {
- // to make tests faster
- minify: false
- }
-}
-
-export default config
diff --git a/playground/react-sourcemap/App.jsx b/playground/react-sourcemap/App.jsx
deleted file mode 100644
index ec47ca46ad212e..00000000000000
--- a/playground/react-sourcemap/App.jsx
+++ /dev/null
@@ -1,8 +0,0 @@
-console.log('App.jsx 1') // for sourcemap
-function App() {
- return foo
-}
-
-console.log('App.jsx 2') // for sourcemap
-
-export default App
diff --git a/playground/react-sourcemap/__tests__/react-sourcemap.spec.ts b/playground/react-sourcemap/__tests__/react-sourcemap.spec.ts
deleted file mode 100644
index e5527ca71ea693..00000000000000
--- a/playground/react-sourcemap/__tests__/react-sourcemap.spec.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { expect, test } from 'vitest'
-import { isBuild, serverLogs } from '~utils'
-
-test.runIf(isBuild)('should not output sourcemap warning', () => {
- serverLogs.forEach((log) => {
- expect(log).not.toMatch('Sourcemap is likely to be incorrect')
- })
-})
diff --git a/playground/react-sourcemap/index.html b/playground/react-sourcemap/index.html
deleted file mode 100644
index d3ca9807c608ba..00000000000000
--- a/playground/react-sourcemap/index.html
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/playground/react-sourcemap/main.jsx b/playground/react-sourcemap/main.jsx
deleted file mode 100644
index 705d3340097aeb..00000000000000
--- a/playground/react-sourcemap/main.jsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react'
-import ReactDOM from 'react-dom/client'
-import App from './App.jsx'
-
-ReactDOM.createRoot(document.getElementById('app')).render(
- React.createElement(App)
-)
-
-console.log('main.jsx') // for sourcemap
diff --git a/playground/react-sourcemap/package.json b/playground/react-sourcemap/package.json
deleted file mode 100644
index 7d51945d203bf0..00000000000000
--- a/playground/react-sourcemap/package.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "test-react-sourcemap",
- "private": true,
- "version": "0.0.0",
- "scripts": {
- "dev": "vite",
- "dev:classic": "USE_CLASSIC=1 vite",
- "build": "vite build",
- "build:classic": "USE_CLASSIC=1 vite build",
- "debug": "node --inspect-brk ../../packages/vite/bin/vite",
- "preview": "vite preview"
- },
- "dependencies": {
- "react": "^18.2.0",
- "react-dom": "^18.2.0"
- },
- "devDependencies": {
- "@vitejs/plugin-react": "^3.0.0-alpha.0"
- }
-}
diff --git a/playground/react-sourcemap/vite.config.ts b/playground/react-sourcemap/vite.config.ts
deleted file mode 100644
index d8a2cc46b419b9..00000000000000
--- a/playground/react-sourcemap/vite.config.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import react from '@vitejs/plugin-react'
-import type { UserConfig } from 'vite'
-
-const config: UserConfig = {
- plugins: [
- react({
- jsxRuntime: process.env.USE_CLASSIC === '1' ? 'classic' : 'automatic'
- })
- ],
- build: {
- sourcemap: true
- }
-}
-
-export default config
diff --git a/playground/react/App.jsx b/playground/react/App.jsx
deleted file mode 100644
index 83f4cc07ea4a07..00000000000000
--- a/playground/react/App.jsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import { useState } from 'react'
-import Button from 'jsx-entry'
-import Dummy from './components/Dummy?qs-should-not-break-plugin-react'
-import Parent from './hmr/parent'
-import { CountProvider } from './context/CountProvider'
-import { ContextButton } from './context/ContextButton'
-
-function App() {
- const [count, setCount] = useState(0)
- return (
-
-
- Hello Vite + React
-
- setCount((count) => count + 1)}
- >
- count is: {count}
-
-
-
-
-
-
- Edit App.jsx
and save to test HMR updates.
-
-
- Learn React
-
-
-
-
-
-
button
-
- )
-}
-
-function AppWithProviders() {
- return (
-
-
-
- )
-}
-
-export default AppWithProviders
diff --git a/playground/react/__tests__/react.spec.ts b/playground/react/__tests__/react.spec.ts
deleted file mode 100644
index 26eb59b5d79b7e..00000000000000
--- a/playground/react/__tests__/react.spec.ts
+++ /dev/null
@@ -1,96 +0,0 @@
-import { expect, test } from 'vitest'
-import {
- editFile,
- isBuild,
- isServe,
- page,
- untilBrowserLogAfter,
- untilUpdated
-} from '~utils'
-
-test('should render', async () => {
- expect(await page.textContent('h1')).toMatch('Hello Vite + React')
-})
-
-test('should update', async () => {
- expect(await page.textContent('#state-button')).toMatch('count is: 0')
- await page.click('#state-button')
- expect(await page.textContent('#state-button')).toMatch('count is: 1')
-})
-
-test('should hmr', async () => {
- editFile('App.jsx', (code) => code.replace('Vite + React', 'Updated'))
- await untilUpdated(() => page.textContent('h1'), 'Hello Updated')
- // preserve state
- expect(await page.textContent('#state-button')).toMatch('count is: 1')
-})
-
-test.runIf(isServe)(
- 'should have annotated jsx with file location metadata',
- async () => {
- const meta = await page.evaluate(() => {
- const button = document.querySelector('#state-button')
- const key = Object.keys(button).find(
- (key) => key.indexOf('__reactFiber') === 0
- )
- return button[key]._debugSource
- })
- // If the evaluate call doesn't crash, and the returned metadata has
- // the expected fields, we're good.
- expect(Object.keys(meta).sort()).toEqual([
- 'columnNumber',
- 'fileName',
- 'lineNumber'
- ])
- }
-)
-
-if (!isBuild) {
- // #9869
- test('should only hmr files with exported react components', async () => {
- await untilBrowserLogAfter(
- () =>
- editFile('hmr/no-exported-comp.jsx', (code) =>
- code.replace('An Object', 'Updated')
- ),
- [
- '[vite] invalidate /hmr/no-exported-comp.jsx',
- '[vite] hot updated: /hmr/no-exported-comp.jsx',
- '[vite] hot updated: /hmr/parent.jsx',
- 'Parent rendered'
- ],
- true
- )
- await untilUpdated(() => page.textContent('#parent'), 'Updated')
- })
-
- // #3301
- test('should hmr react context', async () => {
- expect(await page.textContent('#context-button')).toMatch(
- 'context-based count is: 0'
- )
- await page.click('#context-button')
- expect(await page.textContent('#context-button')).toMatch(
- 'context-based count is: 1'
- )
-
- await untilBrowserLogAfter(
- () =>
- editFile('context/CountProvider.jsx', (code) =>
- code.replace('context provider', 'context provider updated')
- ),
- [
- '[vite] invalidate /context/CountProvider.jsx',
- '[vite] hot updated: /context/CountProvider.jsx',
- '[vite] hot updated: /App.jsx',
- '[vite] hot updated: /context/ContextButton.jsx',
- 'Parent rendered'
- ],
- true
- )
- await untilUpdated(
- () => page.textContent('#context-provider'),
- 'context provider updated'
- )
- })
-}
diff --git a/playground/react/components/Dummy.jsx b/playground/react/components/Dummy.jsx
deleted file mode 100644
index 27ec3c21de30fd..00000000000000
--- a/playground/react/components/Dummy.jsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export default function Dummy() {
- return <>>
-}
diff --git a/playground/react/context/ContextButton.jsx b/playground/react/context/ContextButton.jsx
deleted file mode 100644
index 92c6d0bd26f968..00000000000000
--- a/playground/react/context/ContextButton.jsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { useContext } from 'react'
-import { CountContext } from './CountProvider'
-
-export function ContextButton() {
- const { count, setCount } = useContext(CountContext)
- return (
- setCount((count) => count + 1)}>
- context-based count is: {count}
-
- )
-}
diff --git a/playground/react/context/CountProvider.jsx b/playground/react/context/CountProvider.jsx
deleted file mode 100644
index 223ad25f04f056..00000000000000
--- a/playground/react/context/CountProvider.jsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { createContext, useState } from 'react'
-export const CountContext = createContext()
-
-export const CountProvider = ({ children }) => {
- const [count, setCount] = useState(0)
- return (
-
- {children}
- context provider
-
- )
-}
diff --git a/playground/react/hmr/no-exported-comp.jsx b/playground/react/hmr/no-exported-comp.jsx
deleted file mode 100644
index 7784bcb50603a9..00000000000000
--- a/playground/react/hmr/no-exported-comp.jsx
+++ /dev/null
@@ -1,7 +0,0 @@
-// This un-exported react component should not cause this file to be treated
-// as an HMR boundary
-const Unused = () => An unused react component
-
-export const Foo = {
- is: 'An Object'
-}
diff --git a/playground/react/hmr/parent.jsx b/playground/react/hmr/parent.jsx
deleted file mode 100644
index ff8698281c83c7..00000000000000
--- a/playground/react/hmr/parent.jsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Foo } from './no-exported-comp'
-
-export default function Parent() {
- console.log('Parent rendered')
-
- return {Foo.is}
-}
diff --git a/playground/react/index.html b/playground/react/index.html
deleted file mode 100644
index f0015ceb9829a3..00000000000000
--- a/playground/react/index.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
diff --git a/playground/react/jsx-entry/Button.jsx b/playground/react/jsx-entry/Button.jsx
deleted file mode 100644
index 4f7f2b91a7dd8b..00000000000000
--- a/playground/react/jsx-entry/Button.jsx
+++ /dev/null
@@ -1,5 +0,0 @@
-const Button = ({ children }) => {
- return {children}
-}
-
-export default Button
diff --git a/playground/react/jsx-entry/package.json b/playground/react/jsx-entry/package.json
deleted file mode 100644
index 4bfa33570ce162..00000000000000
--- a/playground/react/jsx-entry/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "name": "jsx-entry",
- "private": true,
- "version": "0.0.0",
- "main": "Button.jsx"
-}
diff --git a/playground/react/package.json b/playground/react/package.json
deleted file mode 100644
index e9a9f242a46248..00000000000000
--- a/playground/react/package.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "name": "test-react",
- "private": true,
- "version": "0.0.0",
- "scripts": {
- "dev": "vite",
- "build": "vite build",
- "debug": "node --inspect-brk ../../packages/vite/bin/vite",
- "preview": "vite preview"
- },
- "dependencies": {
- "jsx-entry": "file:./jsx-entry",
- "react": "^18.2.0",
- "react-dom": "^18.2.0"
- },
- "devDependencies": {
- "@vitejs/plugin-react": "^3.0.0-alpha.0"
- },
- "babel": {
- "presets": [
- "@babel/preset-env"
- ]
- }
-}
diff --git a/playground/react/vite.config.ts b/playground/react/vite.config.ts
deleted file mode 100644
index cd4aaee2d3432c..00000000000000
--- a/playground/react/vite.config.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import react from '@vitejs/plugin-react'
-import type { UserConfig } from 'vite'
-
-const config: UserConfig = {
- mode: 'development',
- plugins: [react()],
- build: {
- // to make tests faster
- minify: false
- }
-}
-
-export default config
diff --git a/playground/ssr-react/__tests__/serve.ts b/playground/ssr-react/__tests__/serve.ts
deleted file mode 100644
index df23d4f0661c4c..00000000000000
--- a/playground/ssr-react/__tests__/serve.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-// this is automatically detected by playground/vitestSetup.ts and will replace
-// the default e2e test serve behavior
-
-import path from 'node:path'
-import kill from 'kill-port'
-import { hmrPorts, isBuild, ports, rootDir } from '~utils'
-
-export const port = ports['ssr-react']
-
-export async function serve(): Promise<{ close(): Promise }> {
- if (isBuild) {
- // build first
- const { build } = await import('vite')
- // client build
- await build({
- root: rootDir,
- logLevel: 'silent', // exceptions are logged by Vitest
- build: {
- target: 'esnext',
- minify: false,
- ssrManifest: true,
- outDir: 'dist/client'
- }
- })
- // server build
- await build({
- root: rootDir,
- logLevel: 'silent',
- build: {
- target: 'esnext',
- ssr: 'src/entry-server.jsx',
- outDir: 'dist/server',
- rollupOptions: {
- output: {
- entryFileNames: 'entry-server.js'
- }
- }
- }
- })
- }
-
- await kill(port)
-
- const { createServer } = await import(path.resolve(rootDir, 'server.js'))
- const { app, vite } = await createServer(
- rootDir,
- isBuild,
- hmrPorts['ssr-react']
- )
-
- return new Promise((resolve, reject) => {
- try {
- const server = app.listen(port, () => {
- resolve({
- // for test teardown
- async close() {
- await new Promise((resolve) => {
- server.close(resolve)
- })
- if (vite) {
- await vite.close()
- }
- }
- })
- })
- } catch (e) {
- reject(e)
- }
- })
-}
diff --git a/playground/ssr-react/__tests__/ssr-react.spec.ts b/playground/ssr-react/__tests__/ssr-react.spec.ts
deleted file mode 100644
index 111a52aa5537ae..00000000000000
--- a/playground/ssr-react/__tests__/ssr-react.spec.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import fetch from 'node-fetch'
-import { expect, test } from 'vitest'
-import { port } from './serve'
-import {
- browserLogs,
- editFile,
- page,
- untilBrowserLogAfter,
- untilUpdated
-} from '~utils'
-
-const url = `http://localhost:${port}`
-
-test('/env', async () => {
- await untilBrowserLogAfter(() => page.goto(url + '/env'), 'hydrated')
-
- expect(await page.textContent('h1')).toMatch('default message here')
-
- // raw http request
- const envHtml = await (await fetch(url + '/env')).text()
- expect(envHtml).toMatch('API_KEY_qwertyuiop')
-})
-
-test('/about', async () => {
- await untilBrowserLogAfter(() => page.goto(url + '/about'), 'hydrated')
-
- expect(await page.textContent('h1')).toMatch('About')
- // should not have hydration mismatch
- browserLogs.forEach((msg) => {
- expect(msg).not.toMatch('Expected server HTML')
- })
-
- // raw http request
- const aboutHtml = await (await fetch(url + '/about')).text()
- expect(aboutHtml).toMatch('About')
-})
-
-test('/', async () => {
- await untilBrowserLogAfter(() => page.goto(url), 'hydrated')
-
- expect(await page.textContent('h1')).toMatch('Home')
- // should not have hydration mismatch
- browserLogs.forEach((msg) => {
- expect(msg).not.toMatch('Expected server HTML')
- })
-
- // raw http request
- const html = await (await fetch(url)).text()
- expect(html).toMatch('Home')
-})
-
-test('hmr', async () => {
- await page.goto(url)
- editFile('src/pages/Home.jsx', (code) =>
- code.replace('Home', 'changed')
- )
- await untilUpdated(() => page.textContent('h1'), 'changed')
-})
-
-test('client navigation', async () => {
- await untilBrowserLogAfter(() => page.goto(url), 'hydrated')
-
- await untilUpdated(() => page.textContent('a[href="/about"]'), 'About')
- await page.click('a[href="/about"]')
- await untilUpdated(() => page.textContent('h1'), 'About')
- editFile('src/pages/About.jsx', (code) =>
- code.replace('About', 'changed')
- )
- await untilUpdated(() => page.textContent('h1'), 'changed')
-})
-
-test(`circular dependencies modules doesn't throw`, async () => {
- await page.goto(url)
- expect(await page.textContent('.circ-dep-init')).toMatch(
- 'circ-dep-init-a circ-dep-init-b'
- )
-})
diff --git a/playground/ssr-react/index.html b/playground/ssr-react/index.html
deleted file mode 100644
index 1c891c04355068..00000000000000
--- a/playground/ssr-react/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
- Vite App
-
-
-
-
-
-
diff --git a/playground/ssr-react/package.json b/playground/ssr-react/package.json
deleted file mode 100644
index f9419fcc53b731..00000000000000
--- a/playground/ssr-react/package.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "name": "test-ssr-react",
- "private": true,
- "version": "0.0.0",
- "type": "module",
- "scripts": {
- "dev": "node server",
- "build": "npm run build:client && npm run build:server",
- "build:client": "vite build --outDir dist/client",
- "build:server": "vite build --ssr src/entry-server.jsx --outDir dist/server",
- "generate": "vite build --outDir dist/static && npm run build:server && node prerender",
- "serve": "NODE_ENV=production node server",
- "debug": "node --inspect-brk server"
- },
- "dependencies": {
- "react": "^18.2.0",
- "react-dom": "^18.2.0",
- "react-router-dom": "^6.4.3"
- },
- "devDependencies": {
- "@vitejs/plugin-react": "^3.0.0-alpha.0",
- "compression": "^1.7.4",
- "express": "^4.18.2",
- "serve-static": "^1.15.0"
- }
-}
diff --git a/playground/ssr-react/prerender.js b/playground/ssr-react/prerender.js
deleted file mode 100644
index 8a18a492ab138c..00000000000000
--- a/playground/ssr-react/prerender.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// Pre-render the app into static HTML.
-// run `yarn generate` and then `dist/static` can be served as a static site.
-
-import fs from 'node:fs'
-import path from 'node:path'
-import { fileURLToPath } from 'node:url'
-
-const __dirname = path.dirname(fileURLToPath(import.meta.url))
-const toAbsolute = (p) => path.resolve(__dirname, p)
-
-const template = fs.readFileSync(toAbsolute('dist/static/index.html'), 'utf-8')
-const { render } = await import('./dist/server/entry-server.js')
-
-// determine routes to pre-render from src/pages
-const routesToPrerender = fs
- .readdirSync(toAbsolute('src/pages'))
- .map((file) => {
- const name = file.replace(/\.jsx$/, '').toLowerCase()
- return name === 'home' ? `/` : `/${name}`
- })
-
-;(async () => {
- // pre-render each route...
- for (const url of routesToPrerender) {
- const context = {}
- const appHtml = await render(url, context)
-
- const html = template.replace(``, appHtml)
-
- const filePath = `dist/static${url === '/' ? '/index' : url}.html`
- fs.writeFileSync(toAbsolute(filePath), html)
- console.log('pre-rendered:', filePath)
- }
-})()
diff --git a/playground/ssr-react/server.js b/playground/ssr-react/server.js
deleted file mode 100644
index 2f878092c8eb1b..00000000000000
--- a/playground/ssr-react/server.js
+++ /dev/null
@@ -1,103 +0,0 @@
-import fs from 'node:fs'
-import path from 'node:path'
-import { fileURLToPath } from 'node:url'
-import express from 'express'
-
-const __dirname = path.dirname(fileURLToPath(import.meta.url))
-
-const isTest = process.env.VITEST
-
-process.env.MY_CUSTOM_SECRET = 'API_KEY_qwertyuiop'
-
-export async function createServer(
- root = process.cwd(),
- isProd = process.env.NODE_ENV === 'production',
- hmrPort
-) {
- const resolve = (p) => path.resolve(__dirname, p)
-
- const indexProd = isProd
- ? fs.readFileSync(resolve('dist/client/index.html'), 'utf-8')
- : ''
-
- const app = express()
-
- /**
- * @type {import('vite').ViteDevServer}
- */
- let vite
- if (!isProd) {
- vite = await (
- await import('vite')
- ).createServer({
- root,
- logLevel: isTest ? 'error' : 'info',
- server: {
- middlewareMode: true,
- watch: {
- // During tests we edit the files too fast and sometimes chokidar
- // misses change events, so enforce polling for consistency
- usePolling: true,
- interval: 100
- },
- hmr: {
- port: hmrPort
- }
- },
- appType: 'custom'
- })
- // use vite's connect instance as middleware
- app.use(vite.middlewares)
- } else {
- app.use((await import('compression')).default())
- app.use(
- (await import('serve-static')).default(resolve('dist/client'), {
- index: false
- })
- )
- }
-
- app.use('*', async (req, res) => {
- try {
- const url = req.originalUrl
-
- let template, render
- if (!isProd) {
- // always read fresh template in dev
- template = fs.readFileSync(resolve('index.html'), 'utf-8')
- template = await vite.transformIndexHtml(url, template)
- render = (await vite.ssrLoadModule('/src/entry-server.jsx')).render
- } else {
- template = indexProd
- // @ts-ignore
- render = (await import('./dist/server/entry-server.js')).render
- }
-
- const context = {}
- const appHtml = render(url, context)
-
- if (context.url) {
- // Somewhere a `` was rendered
- return res.redirect(301, context.url)
- }
-
- const html = template.replace(``, appHtml)
-
- res.status(200).set({ 'Content-Type': 'text/html' }).end(html)
- } catch (e) {
- !isProd && vite.ssrFixStacktrace(e)
- console.log(e.stack)
- res.status(500).end(e.stack)
- }
- })
-
- return { app, vite }
-}
-
-if (!isTest) {
- createServer().then(({ app }) =>
- app.listen(5173, () => {
- console.log('http://localhost:5173')
- })
- )
-}
diff --git a/playground/ssr-react/src/App.jsx b/playground/ssr-react/src/App.jsx
deleted file mode 100644
index 6be6af9a8fb0ab..00000000000000
--- a/playground/ssr-react/src/App.jsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import { Link, Route, Routes } from 'react-router-dom'
-
-// Auto generates routes from files under ./pages
-// https://vitejs.dev/guide/features.html#glob-import
-const pages = import.meta.glob('./pages/*.jsx', { eager: true })
-
-const routes = Object.keys(pages).map((path) => {
- const name = path.match(/\.\/pages\/(.*)\.jsx$/)[1]
- return {
- name,
- path: name === 'Home' ? '/' : `/${name.toLowerCase()}`,
- component: pages[path].default
- }
-})
-
-export function App() {
- return (
- <>
-
-
- {routes.map(({ name, path }) => {
- return (
-
- {name}
-
- )
- })}
-
-
-
- {routes.map(({ path, component: RouteComp }) => {
- return }>
- })}
-
- >
- )
-}
diff --git a/playground/ssr-react/src/add.js b/playground/ssr-react/src/add.js
deleted file mode 100644
index a0e419e9cfcacf..00000000000000
--- a/playground/ssr-react/src/add.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import { multiply } from './multiply'
-
-export function add(a, b) {
- return a + b
-}
-
-export function addAndMultiply(a, b, c) {
- return multiply(add(a, b), c)
-}
diff --git a/playground/ssr-react/src/circular-dep-init/README.md b/playground/ssr-react/src/circular-dep-init/README.md
deleted file mode 100644
index 864d16ae8c495b..00000000000000
--- a/playground/ssr-react/src/circular-dep-init/README.md
+++ /dev/null
@@ -1 +0,0 @@
-This test aim to find out wherever the modules with circular dependencies are correctly initialized
diff --git a/playground/ssr-react/src/circular-dep-init/circular-dep-init.js b/playground/ssr-react/src/circular-dep-init/circular-dep-init.js
deleted file mode 100644
index 8867d64ec45091..00000000000000
--- a/playground/ssr-react/src/circular-dep-init/circular-dep-init.js
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './module-a'
-export { getValueAB } from './module-b'
diff --git a/playground/ssr-react/src/circular-dep-init/module-a.js b/playground/ssr-react/src/circular-dep-init/module-a.js
deleted file mode 100644
index 335b3ac26ab3b5..00000000000000
--- a/playground/ssr-react/src/circular-dep-init/module-a.js
+++ /dev/null
@@ -1 +0,0 @@
-export const valueA = 'circ-dep-init-a'
diff --git a/playground/ssr-react/src/circular-dep-init/module-b.js b/playground/ssr-react/src/circular-dep-init/module-b.js
deleted file mode 100644
index cb16d7e9be4a30..00000000000000
--- a/playground/ssr-react/src/circular-dep-init/module-b.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { valueA } from './circular-dep-init'
-
-export const valueB = 'circ-dep-init-b'
-export const valueAB = valueA.concat(` ${valueB}`)
-
-export function getValueAB() {
- return valueAB
-}
diff --git a/playground/ssr-react/src/entry-client.jsx b/playground/ssr-react/src/entry-client.jsx
deleted file mode 100644
index 703199443d9cca..00000000000000
--- a/playground/ssr-react/src/entry-client.jsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import ReactDOM from 'react-dom/client'
-import { BrowserRouter } from 'react-router-dom'
-import { App } from './App'
-
-ReactDOM.hydrateRoot(
- document.getElementById('app'),
-
-
-
-)
-console.log('hydrated')
diff --git a/playground/ssr-react/src/entry-server.jsx b/playground/ssr-react/src/entry-server.jsx
deleted file mode 100644
index ea1b86aebd4716..00000000000000
--- a/playground/ssr-react/src/entry-server.jsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import ReactDOMServer from 'react-dom/server'
-import { StaticRouter } from 'react-router-dom/server'
-import { App } from './App'
-
-export function render(url, context) {
- return ReactDOMServer.renderToString(
-
-
-
- )
-}
diff --git a/playground/ssr-react/src/forked-deadlock/README.md b/playground/ssr-react/src/forked-deadlock/README.md
deleted file mode 100644
index 798c8c429ee9e4..00000000000000
--- a/playground/ssr-react/src/forked-deadlock/README.md
+++ /dev/null
@@ -1,51 +0,0 @@
-This test aim to check for a particular type of circular dependency that causes tricky deadlocks, **deadlocks with forked imports stack**
-
-```
-A -> B means: B is imported by A and B has A in its stack
-A ... B means: A is waiting for B to ssrLoadModule()
-
-H -> X ... Y
-H -> X -> Y ... B
-H -> A ... B
-H -> A -> B ... X
-```
-
-### Forked deadlock description:
-
-```
-[X] is waiting for [Y] to resolve
- ↑ ↳ is waiting for [A] to resolve
- │ ↳ is waiting for [B] to resolve
- │ ↳ is waiting for [X] to resolve
- └────────────────────────────────────────────────────────────────────────┘
-```
-
-This may seems a traditional deadlock, but the thing that makes this special is the import stack of each module:
-
-```
-[X] stack:
- [H]
-```
-
-```
-[Y] stack:
- [X]
- [H]
-```
-
-```
-[A] stack:
- [H]
-```
-
-```
-[B] stack:
- [A]
- [H]
-```
-
-Even if `[X]` is imported by `[B]`, `[B]` is not in `[X]`'s stack because it's imported by `[H]` in first place then it's stack is only composed by `[H]`. `[H]` **forks** the imports **stack** and this make hard to be found.
-
-### Fix description
-
-Vite, when imports `[X]`, should check whether `[X]` is already pending and if it is, it must check that, when it was imported in first place, the stack of `[X]` doesn't have any module in common with the current module; in this case `[B]` has the module `[H]` is common with `[X]` and i can assume that a deadlock is going to happen.
diff --git a/playground/ssr-react/src/forked-deadlock/common-module.js b/playground/ssr-react/src/forked-deadlock/common-module.js
deleted file mode 100644
index c73a3ee4b970c8..00000000000000
--- a/playground/ssr-react/src/forked-deadlock/common-module.js
+++ /dev/null
@@ -1,10 +0,0 @@
-import { stuckModuleExport } from './stuck-module'
-import { deadlockfuseModuleExport } from './deadlock-fuse-module'
-
-/**
- * module H
- */
-export function commonModuleExport() {
- stuckModuleExport()
- deadlockfuseModuleExport()
-}
diff --git a/playground/ssr-react/src/forked-deadlock/deadlock-fuse-module.js b/playground/ssr-react/src/forked-deadlock/deadlock-fuse-module.js
deleted file mode 100644
index 4f31763ba2343f..00000000000000
--- a/playground/ssr-react/src/forked-deadlock/deadlock-fuse-module.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { fuseStuckBridgeModuleExport } from './fuse-stuck-bridge-module'
-
-/**
- * module A
- */
-export function deadlockfuseModuleExport() {
- fuseStuckBridgeModuleExport()
-}
diff --git a/playground/ssr-react/src/forked-deadlock/fuse-stuck-bridge-module.js b/playground/ssr-react/src/forked-deadlock/fuse-stuck-bridge-module.js
deleted file mode 100644
index 211ad7c3bc9f92..00000000000000
--- a/playground/ssr-react/src/forked-deadlock/fuse-stuck-bridge-module.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { stuckModuleExport } from './stuck-module'
-
-/**
- * module C
- */
-export function fuseStuckBridgeModuleExport() {
- stuckModuleExport()
-}
diff --git a/playground/ssr-react/src/forked-deadlock/middle-module.js b/playground/ssr-react/src/forked-deadlock/middle-module.js
deleted file mode 100644
index 0632eedeabd7a5..00000000000000
--- a/playground/ssr-react/src/forked-deadlock/middle-module.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { deadlockfuseModuleExport } from './deadlock-fuse-module'
-
-/**
- * module Y
- */
-export function middleModuleExport() {
- void deadlockfuseModuleExport
-}
diff --git a/playground/ssr-react/src/forked-deadlock/stuck-module.js b/playground/ssr-react/src/forked-deadlock/stuck-module.js
deleted file mode 100644
index 50b4d28063dc70..00000000000000
--- a/playground/ssr-react/src/forked-deadlock/stuck-module.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { middleModuleExport } from './middle-module'
-
-/**
- * module X
- */
-export function stuckModuleExport() {
- middleModuleExport()
-}
diff --git a/playground/ssr-react/src/multiply.js b/playground/ssr-react/src/multiply.js
deleted file mode 100644
index 94f43efbff58bd..00000000000000
--- a/playground/ssr-react/src/multiply.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import { add } from './add'
-
-export function multiply(a, b) {
- return a * b
-}
-
-export function multiplyAndAdd(a, b, c) {
- return add(multiply(a, b), c)
-}
diff --git a/playground/ssr-react/src/pages/About.jsx b/playground/ssr-react/src/pages/About.jsx
deleted file mode 100644
index 0fe4de69078504..00000000000000
--- a/playground/ssr-react/src/pages/About.jsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { addAndMultiply } from '../add'
-import { multiplyAndAdd } from '../multiply'
-
-export default function About() {
- return (
- <>
- About
- {addAndMultiply(1, 2, 3)}
- {multiplyAndAdd(1, 2, 3)}
- >
- )
-}
diff --git a/playground/ssr-react/src/pages/Env.jsx b/playground/ssr-react/src/pages/Env.jsx
deleted file mode 100644
index 1102990f11c8cb..00000000000000
--- a/playground/ssr-react/src/pages/Env.jsx
+++ /dev/null
@@ -1,7 +0,0 @@
-export default function Env() {
- let msg = 'default message here'
- try {
- msg = process.env.MY_CUSTOM_SECRET || msg
- } catch {}
- return {msg}
-}
diff --git a/playground/ssr-react/src/pages/Home.jsx b/playground/ssr-react/src/pages/Home.jsx
deleted file mode 100644
index d1f4944810cc98..00000000000000
--- a/playground/ssr-react/src/pages/Home.jsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import { addAndMultiply } from '../add'
-import { multiplyAndAdd } from '../multiply'
-import { commonModuleExport } from '../forked-deadlock/common-module'
-import { getValueAB } from '../circular-dep-init/circular-dep-init'
-
-export default function Home() {
- commonModuleExport()
-
- return (
- <>
- Home
- {addAndMultiply(1, 2, 3)}
- {multiplyAndAdd(1, 2, 3)}
- {getValueAB()}
- >
- )
-}
diff --git a/playground/ssr-react/vite.config.js b/playground/ssr-react/vite.config.js
deleted file mode 100644
index 676c52ac687f59..00000000000000
--- a/playground/ssr-react/vite.config.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import { defineConfig } from 'vite'
-import react from '@vitejs/plugin-react'
-
-export default defineConfig({
- plugins: [react()],
- build: {
- minify: false
- }
-})
diff --git a/playground/ssr-vue/__tests__/fixtures/ssrModuleLoader-bad.js b/playground/ssr-vue/__tests__/fixtures/ssrModuleLoader-bad.js
deleted file mode 100644
index a51a0519d34003..00000000000000
--- a/playground/ssr-vue/__tests__/fixtures/ssrModuleLoader-bad.js
+++ /dev/null
@@ -1,2 +0,0 @@
-export const bad = 1
-throw new Error('it is an expected error')
diff --git a/playground/ssr-vue/__tests__/serve.ts b/playground/ssr-vue/__tests__/serve.ts
deleted file mode 100644
index e03810017bc04e..00000000000000
--- a/playground/ssr-vue/__tests__/serve.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-// this is automatically detected by playground/vitestSetup.ts and will replace
-// the default e2e test serve behavior
-
-import path from 'node:path'
-import kill from 'kill-port'
-import type { ViteDevServer } from 'vite'
-import { hmrPorts, isBuild, ports, rootDir } from '~utils'
-
-export const port = ports['ssr-vue']
-
-export let viteServer: ViteDevServer
-
-export async function serve(): Promise<{ close(): Promise }> {
- if (isBuild) {
- // build first
- const { build } = await import('vite')
- // client build
- await build({
- base: '/test/',
- root: rootDir,
- logLevel: 'silent', // exceptions are logged by Vitest
- build: {
- target: 'esnext',
- minify: false,
- ssrManifest: true,
- outDir: 'dist/client'
- }
- })
- // server build
- await build({
- base: '/test/',
- root: rootDir,
- logLevel: 'silent',
- build: {
- target: 'esnext',
- ssr: 'src/entry-server.js',
- outDir: 'dist/server'
- }
- })
- }
-
- await kill(port)
-
- const { createServer } = await import(path.resolve(rootDir, 'server.js'))
- const { app, vite } = await createServer(
- rootDir,
- isBuild,
- hmrPorts['ssr-vue']
- )
- viteServer = vite
-
- return new Promise((resolve, reject) => {
- try {
- const server = app.listen(port, () => {
- resolve({
- // for test teardown
- async close() {
- await new Promise((resolve) => {
- server.close(resolve)
- })
- if (vite) {
- await vite.close()
- }
- }
- })
- })
- } catch (e) {
- reject(e)
- }
- })
-}
diff --git a/playground/ssr-vue/__tests__/ssr-vue.spec.ts b/playground/ssr-vue/__tests__/ssr-vue.spec.ts
deleted file mode 100644
index 19f684e2ca48d0..00000000000000
--- a/playground/ssr-vue/__tests__/ssr-vue.spec.ts
+++ /dev/null
@@ -1,247 +0,0 @@
-import { resolve } from 'node:path'
-import { fileURLToPath } from 'node:url'
-import fetch from 'node-fetch'
-import { expect, test, vi } from 'vitest'
-import { port } from './serve'
-import {
- browserLogs,
- editFile,
- getColor,
- isBuild,
- page,
- untilBrowserLogAfter,
- untilUpdated,
- viteServer
-} from '~utils'
-
-const url = `http://localhost:${port}/test/`
-
-test('vuex can be import succeed by named import', async () => {
- // wait networkidle for dynamic optimize vuex
- await page.goto(url + 'store', { waitUntil: 'networkidle' })
- expect(await page.textContent('h1')).toMatch('bar')
-
- // raw http request
- const storeHtml = await (await fetch(url + 'store')).text()
- expect(storeHtml).toMatch('bar')
-})
-
-test('/about', async () => {
- await untilBrowserLogAfter(() => page.goto(url + 'about'), 'hydrated')
-
- expect(await page.textContent('h1')).toMatch('About')
- // should not have hydration mismatch
- browserLogs.forEach((msg) => {
- expect(msg).not.toMatch('mismatch')
- })
-
- // fetch sub route
- const aboutHtml = await (await fetch(url + 'about')).text()
- expect(aboutHtml).toMatch('About')
- if (isBuild) {
- // assert correct preload directive generation for async chunks and CSS
- expect(aboutHtml).not.toMatch(
- /link rel="modulepreload".*?href="\/test\/assets\/Home-\w{8}\.js"/
- )
- expect(aboutHtml).not.toMatch(
- /link rel="stylesheet".*?href="\/test\/assets\/Home-\w{8}\.css"/
- )
- expect(aboutHtml).toMatch(
- /link rel="modulepreload".*?href="\/test\/assets\/About-\w{8}\.js"/
- )
- expect(aboutHtml).toMatch(
- /link rel="stylesheet".*?href="\/test\/assets\/About-\w{8}\.css"/
- )
- }
-})
-
-test('/external', async () => {
- await untilBrowserLogAfter(() => page.goto(url + 'external'), 'hydrated')
-
- expect(await page.textContent('div')).toMatch(
- 'Example external component content'
- )
- // should not have hydration mismatch
- browserLogs.forEach((msg) => {
- expect(msg).not.toMatch('mismatch')
- })
-
- // fetch sub route
- const externalHtml = await (await fetch(url + 'external')).text()
- expect(externalHtml).toMatch('Example external component content')
- if (isBuild) {
- // assert correct preload directive generation for async chunks and CSS
- expect(externalHtml).not.toMatch(
- /link rel="modulepreload".*?href="\/test\/assets\/Home-\w{8}\.js"/
- )
- expect(externalHtml).not.toMatch(
- /link rel="stylesheet".*?href="\/test\/assets\/Home-\w{8}\.css"/
- )
- expect(externalHtml).toMatch(
- /link rel="modulepreload".*?href="\/test\/assets\/External-\w{8}\.js"/
- )
- }
-})
-
-test('/', async () => {
- await untilBrowserLogAfter(() => page.goto(url), 'hydrated')
-
- expect(await page.textContent('h1')).toMatch('Home')
- // should not have hydration mismatch
- browserLogs.forEach((msg) => {
- expect(msg).not.toMatch('mismatch')
- })
-
- const html = await (await fetch(url)).text()
- expect(html).toMatch('Home')
- if (isBuild) {
- // assert correct preload directive generation for async chunks and CSS
- expect(html).toMatch(
- /link rel="modulepreload".*?href="\/test\/assets\/Home-\w{8}\.js"/
- )
- expect(html).toMatch(
- /link rel="stylesheet".*?href="\/test\/assets\/Home-\w{8}\.css"/
- )
- // JSX component preload registration
- expect(html).toMatch(
- /link rel="modulepreload".*?href="\/test\/assets\/Foo-\w{8}\.js"/
- )
- expect(html).toMatch(
- /link rel="stylesheet".*?href="\/test\/assets\/Foo-\w{8}\.css"/
- )
- expect(html).not.toMatch(
- /link rel="modulepreload".*?href="\/test\/assets\/About-\w{8}\.js"/
- )
- expect(html).not.toMatch(
- /link rel="stylesheet".*?href="\/test\/assets\/About-\w{8}\.css"/
- )
- }
-})
-
-test('css', async () => {
- await page.goto(url)
- if (isBuild) {
- expect(await getColor('h1')).toBe('green')
- expect(await getColor('.jsx')).toBe('blue')
- } else {
- // During dev, the CSS is loaded from async chunk and we may have to wait
- // when the test runs concurrently.
- await untilUpdated(() => getColor('h1'), 'green')
- await untilUpdated(() => getColor('.jsx'), 'blue')
- }
-})
-
-test('asset', async () => {
- await page.goto(url)
- // should have no 404s
- browserLogs.forEach((msg) => {
- expect(msg).not.toMatch('404')
- })
- const img = await page.$('img')
- expect(await img.getAttribute('src')).toMatch(
- isBuild ? /\/test\/assets\/logo-\w{8}\.png/ : '/src/assets/logo.png'
- )
-})
-
-test('jsx', async () => {
- await page.goto(url)
- expect(await page.textContent('.jsx')).toMatch('from JSX')
-})
-
-test('virtual module', async () => {
- await page.goto(url)
- expect(await page.textContent('.virtual')).toMatch('hi')
-})
-
-test('nested virtual module', async () => {
- await page.goto(url)
- expect(await page.textContent('.nested-virtual')).toMatch('[success]')
-})
-
-test('hydration', async () => {
- await untilBrowserLogAfter(() => page.goto(url), 'hydrated')
-
- expect(await page.textContent('button')).toMatch('0')
- await page.click('button')
- expect(await page.textContent('button')).toMatch('1')
-})
-
-test(
- 'hmr',
- async () => {
- // This is test is flaky in Mac CI, but can't be reproduced locally. Wait until
- // network idle to avoid the issue. TODO: This may be caused by a bug when
- // modifying a file while loading, we should remove this guard
- await page.goto(url, { waitUntil: 'networkidle' })
- editFile('src/pages/Home.vue', (code) => code.replace('Home', 'changed'))
- await untilUpdated(() => page.textContent('h1'), 'changed')
- },
- { retry: 3 }
-)
-
-test('client navigation', async () => {
- await untilBrowserLogAfter(() => page.goto(url), 'hydrated')
-
- await untilUpdated(() => page.textContent('a[href="/test/about"]'), 'About')
- await page.click('a[href="/test/about"]')
- await untilUpdated(() => page.textContent('h1'), 'About')
- editFile('src/pages/About.vue', (code) => code.replace('About', 'changed'))
- await untilUpdated(() => page.textContent('h1'), 'changed')
- await page.click('a[href="/test/"]')
- await untilUpdated(() => page.textContent('a[href="/test/"]'), 'Home')
-})
-
-test('import.meta.url', async () => {
- await page.goto(url)
- expect(await page.textContent('.protocol')).toEqual('file:')
-})
-
-test.runIf(isBuild)('dynamic css file should be preloaded', async () => {
- await page.goto(url)
- const homeHtml = await (await fetch(url)).text()
- const re =
- /link rel="modulepreload".*?href="\/test\/assets\/(Home-\w{8}\.js)"/
- const filename = re.exec(homeHtml)[1]
- const manifest = (
- await import(
- resolve(
- process.cwd(),
- './playground-temp/ssr-vue/dist/client/ssr-manifest.json'
- )
- )
- ).default
- const depFile = manifest[filename]
- for (const file of depFile) {
- expect(homeHtml).toMatch(file)
- }
-})
-
-test.runIf(!isBuild)(
- 'always throw error when evaluating an wrong SSR module',
- async () => {
- const __filename = fileURLToPath(import.meta.url)
- const badjs = resolve(__filename, '../fixtures/ssrModuleLoader-bad.js')
- const THROW_MESSAGE = 'it is an expected error'
-
- const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
- const expectedErrors = []
- for (const _ of [0, 1]) {
- try {
- console.log(viteServer)
- await viteServer.ssrLoadModule(badjs, { fixStacktrace: true })
- } catch (e) {
- expectedErrors.push(e)
- }
- }
- expect(expectedErrors).toHaveLength(2)
- expect(expectedErrors[0]).toBe(expectedErrors[1])
- expectedErrors.forEach((error) => {
- expect(error?.message).toContain(THROW_MESSAGE)
- })
- expect(spy).toBeCalledTimes(1)
- const [firstParameter] = spy.mock.calls[0]
- expect(firstParameter).toContain('Error when evaluating SSR module')
- expect(firstParameter).toContain(THROW_MESSAGE)
- spy.mockClear()
- }
-)
diff --git a/playground/ssr-vue/dep-import-type/deep/index.d.ts b/playground/ssr-vue/dep-import-type/deep/index.d.ts
deleted file mode 100644
index 39df3b83f7e9b8..00000000000000
--- a/playground/ssr-vue/dep-import-type/deep/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export interface Foo {}
diff --git a/playground/ssr-vue/dep-import-type/package.json b/playground/ssr-vue/dep-import-type/package.json
deleted file mode 100644
index 935f28eb7f7157..00000000000000
--- a/playground/ssr-vue/dep-import-type/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "name": "dep-import-type",
- "private": true,
- "version": "0.0.0",
- "main": "index.js"
-}
diff --git a/playground/ssr-vue/example-external-component/ExampleExternalComponent.vue b/playground/ssr-vue/example-external-component/ExampleExternalComponent.vue
deleted file mode 100644
index 55f3cea40e0399..00000000000000
--- a/playground/ssr-vue/example-external-component/ExampleExternalComponent.vue
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Example external component content
-
diff --git a/playground/ssr-vue/example-external-component/index.js b/playground/ssr-vue/example-external-component/index.js
deleted file mode 100644
index 8fc72c3aee0652..00000000000000
--- a/playground/ssr-vue/example-external-component/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import ExampleExternalComponent from './ExampleExternalComponent.vue'
-
-export default ExampleExternalComponent
diff --git a/playground/ssr-vue/example-external-component/package.json b/playground/ssr-vue/example-external-component/package.json
deleted file mode 100644
index f1fd45bc5655ad..00000000000000
--- a/playground/ssr-vue/example-external-component/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "example-external-component",
- "private": true,
- "version": "0.0.0",
- "type": "module",
- "main": "index.js"
-}
diff --git a/playground/ssr-vue/index.html b/playground/ssr-vue/index.html
deleted file mode 100644
index 17b46a2f7a2267..00000000000000
--- a/playground/ssr-vue/index.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
- Vite App
-
-
-
-
-
-
-
diff --git a/playground/ssr-vue/package.json b/playground/ssr-vue/package.json
deleted file mode 100644
index 88fbb46811d20a..00000000000000
--- a/playground/ssr-vue/package.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "name": "test-ssr-vue",
- "private": true,
- "version": "0.0.0",
- "type": "module",
- "scripts": {
- "dev": "node server",
- "build": "npm run build:client && npm run build:server",
- "build:noExternal": "npm run build:client && npm run build:server:noExternal",
- "build:client": "vite build --ssrManifest --outDir dist/client",
- "build:server": "vite build --ssr src/entry-server.js --outDir dist/server",
- "build:server:noExternal": "vite build --config vite.config.noexternal.js --ssr src/entry-server.js --outDir dist/server",
- "generate": "vite build --ssrManifest --outDir dist/static && npm run build:server && node prerender",
- "serve": "NODE_ENV=production node server",
- "debug": "node --inspect-brk server"
- },
- "dependencies": {
- "example-external-component": "file:example-external-component",
- "pinia": "^2.0.27",
- "vue": "^3.2.45",
- "vue-router": "^4.1.6"
- },
- "devDependencies": {
- "@vitejs/plugin-vue": "^4.0.0-alpha.0",
- "@vitejs/plugin-vue-jsx": "^3.0.0-alpha.0",
- "compression": "^1.7.4",
- "dep-import-type": "link:./dep-import-type",
- "express": "^4.18.2",
- "serve-static": "^1.15.0"
- }
-}
diff --git a/playground/ssr-vue/prerender.js b/playground/ssr-vue/prerender.js
deleted file mode 100644
index 97f42835a3eda6..00000000000000
--- a/playground/ssr-vue/prerender.js
+++ /dev/null
@@ -1,42 +0,0 @@
-// Pre-render the app into static HTML.
-// run `npm run generate` and then `dist/static` can be served as a static site.
-
-import fs from 'node:fs'
-import path from 'node:path'
-import url from 'node:url'
-
-const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
-
-const toAbsolute = (p) => path.resolve(__dirname, p)
-
-const manifest = JSON.parse(
- fs.readFileSync(toAbsolute('dist/static/ssr-manifest.json'), 'utf-8')
-)
-const template = fs.readFileSync(toAbsolute('dist/static/index.html'), 'utf-8')
-const { render } = await import('./dist/server/entry-server.js')
-
-// determine routes to pre-render from src/pages
-const routesToPrerender = fs
- .readdirSync(toAbsolute('src/pages'))
- .map((file) => {
- const name = file.replace(/\.vue$/, '').toLowerCase()
- return name === 'home' ? `/` : `/${name}`
- })
-
-;(async () => {
- // pre-render each route...
- for (const url of routesToPrerender) {
- const [appHtml, preloadLinks] = await render(url, manifest)
-
- const html = template
- .replace(``, preloadLinks)
- .replace(``, appHtml)
-
- const filePath = `dist/static${url === '/' ? '/index' : url}.html`
- fs.writeFileSync(toAbsolute(filePath), html)
- console.log('pre-rendered:', filePath)
- }
-
- // done, delete ssr manifest
- fs.unlinkSync(toAbsolute('dist/static/ssr-manifest.json'))
-})()
diff --git a/playground/ssr-vue/server.js b/playground/ssr-vue/server.js
deleted file mode 100644
index 18cedbce9c5ea3..00000000000000
--- a/playground/ssr-vue/server.js
+++ /dev/null
@@ -1,105 +0,0 @@
-// @ts-check
-import fs from 'node:fs'
-import path from 'node:path'
-import { fileURLToPath } from 'node:url'
-import express from 'express'
-
-const isTest = process.env.VITEST
-
-export async function createServer(
- root = process.cwd(),
- isProd = process.env.NODE_ENV === 'production',
- hmrPort
-) {
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
- const resolve = (p) => path.resolve(__dirname, p)
-
- const indexProd = isProd
- ? fs.readFileSync(resolve('dist/client/index.html'), 'utf-8')
- : ''
-
- const manifest = isProd
- ? JSON.parse(
- fs.readFileSync(resolve('dist/client/ssr-manifest.json'), 'utf-8')
- )
- : {}
-
- const app = express()
-
- /**
- * @type {import('vite').ViteDevServer}
- */
- let vite
- if (!isProd) {
- vite = await (
- await import('vite')
- ).createServer({
- base: '/test/',
- root,
- logLevel: isTest ? 'error' : 'info',
- server: {
- middlewareMode: true,
- watch: {
- // During tests we edit the files too fast and sometimes chokidar
- // misses change events, so enforce polling for consistency
- usePolling: true,
- interval: 100
- },
- hmr: {
- port: hmrPort
- }
- },
- appType: 'custom'
- })
- // use vite's connect instance as middleware
- app.use(vite.middlewares)
- } else {
- app.use((await import('compression')).default())
- app.use(
- '/test/',
- (await import('serve-static')).default(resolve('dist/client'), {
- index: false
- })
- )
- }
-
- app.use('*', async (req, res) => {
- try {
- const url = req.originalUrl.replace('/test/', '/')
-
- let template, render
- if (!isProd) {
- // always read fresh template in dev
- template = fs.readFileSync(resolve('index.html'), 'utf-8')
- template = await vite.transformIndexHtml(url, template)
- render = (await vite.ssrLoadModule('/src/entry-server.js')).render
- } else {
- template = indexProd
- // @ts-ignore
- render = (await import('./dist/server/entry-server.js')).render
- }
-
- const [appHtml, preloadLinks] = await render(url, manifest)
-
- const html = template
- .replace(``, preloadLinks)
- .replace(``, appHtml)
-
- res.status(200).set({ 'Content-Type': 'text/html' }).end(html)
- } catch (e) {
- vite && vite.ssrFixStacktrace(e)
- console.log(e.stack)
- res.status(500).end(e.stack)
- }
- })
-
- return { app, vite }
-}
-
-if (!isTest) {
- createServer().then(({ app }) =>
- app.listen(6173, () => {
- console.log('http://localhost:6173')
- })
- )
-}
diff --git a/playground/ssr-vue/src/App.vue b/playground/ssr-vue/src/App.vue
deleted file mode 100644
index d824089ef249e4..00000000000000
--- a/playground/ssr-vue/src/App.vue
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
Home |
-
About
-
-
-
-
-
-
-
-
-
-
-
diff --git a/playground/ssr-vue/src/assets/button.css b/playground/ssr-vue/src/assets/button.css
deleted file mode 100644
index 8e1ebc58c0891f..00000000000000
--- a/playground/ssr-vue/src/assets/button.css
+++ /dev/null
@@ -1,15 +0,0 @@
-.btn {
- background-color: #65b587;
- border-radius: 8px;
- border-style: none;
- box-sizing: border-box;
- cursor: pointer;
- display: inline-block;
- font-size: 14px;
- font-weight: 500;
- height: 40px;
- line-height: 20px;
- list-style: none;
- outline: none;
- padding: 10px 16px;
-}
diff --git a/playground/ssr-vue/src/assets/fonts/Inter-Italic.woff b/playground/ssr-vue/src/assets/fonts/Inter-Italic.woff
deleted file mode 100644
index e7da6663fe5e47..00000000000000
Binary files a/playground/ssr-vue/src/assets/fonts/Inter-Italic.woff and /dev/null differ
diff --git a/playground/ssr-vue/src/assets/fonts/Inter-Italic.woff2 b/playground/ssr-vue/src/assets/fonts/Inter-Italic.woff2
deleted file mode 100644
index 8559dfde38986e..00000000000000
Binary files a/playground/ssr-vue/src/assets/fonts/Inter-Italic.woff2 and /dev/null differ
diff --git a/playground/ssr-vue/src/assets/logo.png b/playground/ssr-vue/src/assets/logo.png
deleted file mode 100644
index f3d2503fc2a44b..00000000000000
Binary files a/playground/ssr-vue/src/assets/logo.png and /dev/null differ
diff --git a/playground/ssr-vue/src/components/Foo.jsx b/playground/ssr-vue/src/components/Foo.jsx
deleted file mode 100644
index 427815b2d252d2..00000000000000
--- a/playground/ssr-vue/src/components/Foo.jsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import { defineComponent } from 'vue'
-import './foo.css'
-
-// named exports w/ variable declaration: ok
-export const Foo = defineComponent({
- name: 'foo',
- setup() {
- return () => from JSX
- }
-})
diff --git a/playground/ssr-vue/src/components/ImportType.vue b/playground/ssr-vue/src/components/ImportType.vue
deleted file mode 100644
index 144d36bc34e7ec..00000000000000
--- a/playground/ssr-vue/src/components/ImportType.vue
+++ /dev/null
@@ -1,8 +0,0 @@
-
- import type should be removed without side-effect
-
-
-
diff --git a/playground/ssr-vue/src/components/button.js b/playground/ssr-vue/src/components/button.js
deleted file mode 100644
index 3b39f53fd96c47..00000000000000
--- a/playground/ssr-vue/src/components/button.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import { createVNode, defineComponent } from 'vue'
-import '../assets/button.css'
-
-export default defineComponent({
- setup() {
- return () => {
- return createVNode(
- 'div',
- {
- class: 'btn'
- },
- 'dynamicBtn'
- )
- }
- }
-})
diff --git a/playground/ssr-vue/src/components/foo.css b/playground/ssr-vue/src/components/foo.css
deleted file mode 100644
index f8baa0d15b90d3..00000000000000
--- a/playground/ssr-vue/src/components/foo.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.jsx {
- color: blue;
-}
diff --git a/playground/ssr-vue/src/entry-client.js b/playground/ssr-vue/src/entry-client.js
deleted file mode 100644
index a99b84f2f69a80..00000000000000
--- a/playground/ssr-vue/src/entry-client.js
+++ /dev/null
@@ -1,10 +0,0 @@
-import { createApp } from './main'
-
-const { app, router } = createApp()
-
-// wait until router is ready before mounting to ensure hydration match
-router.isReady().then(() => {
- app.mount('#app')
-
- console.log('hydrated')
-})
diff --git a/playground/ssr-vue/src/entry-server.js b/playground/ssr-vue/src/entry-server.js
deleted file mode 100644
index e44c9abd3eb114..00000000000000
--- a/playground/ssr-vue/src/entry-server.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import { basename } from 'node:path'
-import { renderToString } from 'vue/server-renderer'
-import { createApp } from './main'
-
-export async function render(url, manifest) {
- const { app, router } = createApp()
-
- // set the router to the desired URL before rendering
- await router.push(url)
- await router.isReady()
-
- // passing SSR context object which will be available via useSSRContext()
- // @vitejs/plugin-vue injects code into a component's setup() that registers
- // itself on ctx.modules. After the render, ctx.modules would contain all the
- // components that have been instantiated during this render call.
- const ctx = {}
- const html = await renderToString(app, ctx)
-
- // the SSR manifest generated by Vite contains module -> chunk/asset mapping
- // which we can then use to determine what files need to be preloaded for this
- // request.
- const preloadLinks = renderPreloadLinks(ctx.modules, manifest)
- return [html, preloadLinks]
-}
-
-function renderPreloadLinks(modules, manifest) {
- let links = ''
- const seen = new Set()
- modules.forEach((id) => {
- const files = manifest[id]
- if (files) {
- files.forEach((file) => {
- if (!seen.has(file)) {
- seen.add(file)
- const filename = basename(file)
- if (manifest[filename]) {
- for (const depFile of manifest[filename]) {
- links += renderPreloadLink(depFile)
- seen.add(depFile)
- }
- }
- links += renderPreloadLink(file)
- }
- })
- }
- })
- return links
-}
-
-function renderPreloadLink(file) {
- if (file.endsWith('.js')) {
- return ` `
- } else if (file.endsWith('.css')) {
- return ` `
- } else if (file.endsWith('.woff')) {
- return ` `
- } else if (file.endsWith('.woff2')) {
- return ` `
- } else if (file.endsWith('.gif')) {
- return ` `
- } else if (file.endsWith('.jpg') || file.endsWith('.jpeg')) {
- return ` `
- } else if (file.endsWith('.png')) {
- return ` `
- } else {
- // TODO
- return ''
- }
-}
diff --git a/playground/ssr-vue/src/main.js b/playground/ssr-vue/src/main.js
deleted file mode 100644
index d2dd1e002147fe..00000000000000
--- a/playground/ssr-vue/src/main.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import { createPinia } from 'pinia'
-import { createSSRApp } from 'vue'
-import App from './App.vue'
-import { createRouter } from './router'
-
-// SSR requires a fresh app instance per request, therefore we export a function
-// that creates a fresh app instance. If using Vuex, we'd also be creating a
-// fresh store here.
-export function createApp() {
- const app = createSSRApp(App)
- const pinia = createPinia()
- app.use(pinia)
- const router = createRouter()
- app.use(router)
- return { app, router }
-}
diff --git a/playground/ssr-vue/src/pages/About.vue b/playground/ssr-vue/src/pages/About.vue
deleted file mode 100644
index ea6510808fd943..00000000000000
--- a/playground/ssr-vue/src/pages/About.vue
+++ /dev/null
@@ -1,30 +0,0 @@
-
- {{ msg }}
- {{ url }}
- CommonButton
-
-
-
-
-
diff --git a/playground/ssr-vue/src/pages/External.vue b/playground/ssr-vue/src/pages/External.vue
deleted file mode 100644
index ffdcd03b85be84..00000000000000
--- a/playground/ssr-vue/src/pages/External.vue
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
diff --git a/playground/ssr-vue/src/pages/Home.vue b/playground/ssr-vue/src/pages/Home.vue
deleted file mode 100644
index 7f595e7437e600..00000000000000
--- a/playground/ssr-vue/src/pages/Home.vue
+++ /dev/null
@@ -1,51 +0,0 @@
-
- Home
-
-
-
- count is: {{ state.count }}
-
- msg from virtual module: {{ foo.msg }}
- this will be styled with a font-face
- {{ state.url }}
- {{ state.protocol }}
- msg from nested virtual module: {{ virtualMsg }}
- CommonButton
-
-
-
-
-
-
-
-
diff --git a/playground/ssr-vue/src/pages/Store.vue b/playground/ssr-vue/src/pages/Store.vue
deleted file mode 100644
index 60a19217e55645..00000000000000
--- a/playground/ssr-vue/src/pages/Store.vue
+++ /dev/null
@@ -1,25 +0,0 @@
-
- {{ fooStore.foo }}
-
-
-
-
-
diff --git a/playground/ssr-vue/src/router.js b/playground/ssr-vue/src/router.js
deleted file mode 100644
index 814098102d7899..00000000000000
--- a/playground/ssr-vue/src/router.js
+++ /dev/null
@@ -1,28 +0,0 @@
-import {
- createRouter as _createRouter,
- createMemoryHistory,
- createWebHistory
-} from 'vue-router'
-
-// Auto generates routes from vue files under ./pages
-// https://vitejs.dev/guide/features.html#glob-import
-const pages = import.meta.glob('./pages/*.vue')
-
-const routes = Object.keys(pages).map((path) => {
- const name = path.match(/\.\/pages(.*)\.vue$/)[1].toLowerCase()
- return {
- path: name === '/home' ? '/' : name,
- component: pages[path] // () => import('./pages/*.vue')
- }
-})
-
-export function createRouter() {
- return _createRouter({
- // use appropriate history implementation for server/client
- // import.meta.env.SSR is injected by Vite.
- history: import.meta.env.SSR
- ? createMemoryHistory('/test/')
- : createWebHistory('/test/'),
- routes
- })
-}
diff --git a/playground/ssr-vue/vite.config.js b/playground/ssr-vue/vite.config.js
deleted file mode 100644
index c8be7320c8a9b0..00000000000000
--- a/playground/ssr-vue/vite.config.js
+++ /dev/null
@@ -1,126 +0,0 @@
-import path from 'node:path'
-import { defineConfig } from 'vite'
-import vuePlugin from '@vitejs/plugin-vue'
-import vueJsx from '@vitejs/plugin-vue-jsx'
-
-const virtualFile = '@virtual-file'
-const virtualId = '\0' + virtualFile
-const nestedVirtualFile = '@nested-virtual-file'
-const nestedVirtualId = '\0' + nestedVirtualFile
-
-const base = '/test/'
-
-// preserve this to test loading __filename & __dirname in ESM as Vite polyfills them.
-// if Vite incorrectly load this file, node.js would error out.
-globalThis.__vite_test_filename = __filename
-globalThis.__vite_test_dirname = __dirname
-
-export default defineConfig(({ command, ssrBuild }) => ({
- base,
- plugins: [
- vuePlugin(),
- vueJsx(),
- {
- name: 'virtual',
- resolveId(id) {
- if (id === '@foo') {
- return id
- }
- },
- load(id, options) {
- const ssrFromOptions = options?.ssr ?? false
- if (id === '@foo') {
- // Force a mismatch error if ssrBuild is different from ssrFromOptions
- return `export default { msg: '${
- command === 'build' && !!ssrBuild !== ssrFromOptions
- ? `defineConfig ssrBuild !== ssr from load options`
- : 'hi'
- }' }`
- }
- }
- },
- {
- name: 'virtual-module',
- resolveId(id) {
- if (id === virtualFile) {
- return virtualId
- } else if (id === nestedVirtualFile) {
- return nestedVirtualId
- }
- },
- load(id) {
- if (id === virtualId) {
- return `export { msg } from "@nested-virtual-file";`
- } else if (id === nestedVirtualId) {
- return `export const msg = "[success] from conventional virtual file"`
- }
- }
- },
- // Example of a plugin that injects a helper from a virtual module that can
- // be used in renderBuiltUrl
- (function () {
- const queryRE = /\?.*$/s
- const hashRE = /#.*$/s
- const cleanUrl = (url) => url.replace(hashRE, '').replace(queryRE, '')
- let config
-
- const virtualId = '\0virtual:ssr-vue-built-url'
- return {
- name: 'built-url',
- enforce: 'post',
- configResolved(_config) {
- config = _config
- },
- resolveId(id) {
- if (id === virtualId) {
- return id
- }
- },
- load(id) {
- if (id === virtualId) {
- return {
- code: `export const __ssr_vue_processAssetPath = (url) => '${base}' + url`,
- moduleSideEffects: 'no-treeshake'
- }
- }
- },
- transform(code, id) {
- const cleanId = cleanUrl(id)
- if (
- config.build.ssr &&
- (cleanId.endsWith('.js') || cleanId.endsWith('.vue')) &&
- !code.includes('__ssr_vue_processAssetPath')
- ) {
- return {
- code:
- `import { __ssr_vue_processAssetPath } from '${virtualId}';__ssr_vue_processAssetPath;` +
- code,
- sourcemap: null // no sourcemap support to speed up CI
- }
- }
- }
- }
- })()
- ],
- experimental: {
- renderBuiltUrl(filename, { hostType, type, ssr }) {
- if (ssr && type === 'asset' && hostType === 'js') {
- return {
- runtime: `__ssr_vue_processAssetPath(${JSON.stringify(filename)})`
- }
- }
- }
- },
- build: {
- minify: false
- },
- ssr: {
- noExternal: [
- // this package has uncompiled .vue files
- 'example-external-component'
- ]
- },
- optimizeDeps: {
- exclude: ['example-external-component']
- }
-}))
diff --git a/playground/ssr-vue/vite.config.noexternal.js b/playground/ssr-vue/vite.config.noexternal.js
deleted file mode 100644
index 48a740c16cb1bf..00000000000000
--- a/playground/ssr-vue/vite.config.noexternal.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import config from './vite.config.js'
-/**
- * @type {import('vite').UserConfig}
- */
-export default Object.assign(config, {
- ssr: {
- noExternal: /./
- },
- resolve: {
- // necessary because vue.ssrUtils is only exported on cjs modules
- alias: [
- {
- find: '@vue/runtime-dom',
- replacement: '@vue/runtime-dom/dist/runtime-dom.cjs.js'
- },
- {
- find: '@vue/runtime-core',
- replacement: '@vue/runtime-core/dist/runtime-core.cjs.js'
- }
- ]
- },
- optimizeDeps: {
- exclude: ['example-external-component']
- }
-})
diff --git a/playground/test-utils.ts b/playground/test-utils.ts
index a1bb4ad31dc30d..80e04bffb8bd02 100644
--- a/playground/test-utils.ts
+++ b/playground/test-utils.ts
@@ -26,8 +26,6 @@ export const ports = {
'ssr-html': 9601,
'ssr-noexternal': 9602,
'ssr-pug': 9603,
- 'ssr-react': 9604,
- 'ssr-vue': 9605,
'ssr-webworker': 9606,
'css/postcss-caching': 5005,
'css/postcss-plugins-different-dir': 5006,
@@ -38,9 +36,7 @@ export const hmrPorts = {
'ssr-deps': 24681,
'ssr-html': 24682,
'ssr-noexternal': 24683,
- 'ssr-pug': 24684,
- 'ssr-react': 24685,
- 'ssr-vue': 24686
+ 'ssr-pug': 24684
}
const hexToNameMap: Record = {}
diff --git a/playground/vue-jsx/Comp.tsx b/playground/vue-jsx/Comp.tsx
deleted file mode 100644
index fe8add4d428a2c..00000000000000
--- a/playground/vue-jsx/Comp.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { defineComponent, ref } from 'vue'
-
-const Default = defineComponent(() => {
- const count = ref(3)
- const inc = () => count.value++
-
- return () => (
-
- default tsx {count.value}
-
- )
-})
-
-export default Default
diff --git a/playground/vue-jsx/Comps.jsx b/playground/vue-jsx/Comps.jsx
deleted file mode 100644
index e5cc405a77581b..00000000000000
--- a/playground/vue-jsx/Comps.jsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { defineComponent, ref } from 'vue'
-
-export const Named = defineComponent(() => {
- const count = ref(0)
- const inc = () => count.value++
-
- return () => (
-
- named {count.value}
-
- )
-})
-
-const NamedSpec = defineComponent(() => {
- const count = ref(1)
- const inc = () => count.value++
-
- return () => (
-
- named specifier {count.value}
-
- )
-})
-export { NamedSpec }
-
-export default defineComponent(() => {
- const count = ref(2)
- const inc = () => count.value++
-
- return () => (
-
- default {count.value}
-
- )
-})
diff --git a/playground/vue-jsx/OtherExt.tesx b/playground/vue-jsx/OtherExt.tesx
deleted file mode 100644
index 7ae585a014c566..00000000000000
--- a/playground/vue-jsx/OtherExt.tesx
+++ /dev/null
@@ -1,9 +0,0 @@
-import { defineComponent } from 'vue'
-
-const Default = defineComponent(() => {
- return () => (
- Other Ext
- )
-})
-
-export default Default
diff --git a/playground/vue-jsx/Query.jsx b/playground/vue-jsx/Query.jsx
deleted file mode 100644
index 60de93eafb7b1c..00000000000000
--- a/playground/vue-jsx/Query.jsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { defineComponent, ref } from 'vue'
-
-export default defineComponent(() => {
- const count = ref(6)
- const inc = () => count.value++
-
- return () => (
-
- import with query transform fail
-
- )
-})
diff --git a/playground/vue-jsx/Script.vue b/playground/vue-jsx/Script.vue
deleted file mode 100644
index 2689ed2dfe6ffb..00000000000000
--- a/playground/vue-jsx/Script.vue
+++ /dev/null
@@ -1,14 +0,0 @@
-
diff --git a/playground/vue-jsx/SrcImport.jsx b/playground/vue-jsx/SrcImport.jsx
deleted file mode 100644
index dc775be205af73..00000000000000
--- a/playground/vue-jsx/SrcImport.jsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { defineComponent, ref } from 'vue'
-
-export default defineComponent(() => {
- const count = ref(5)
- const inc = () => count.value++
-
- return () => (
-
- src import {count.value}
-
- )
-})
diff --git a/playground/vue-jsx/SrcImport.vue b/playground/vue-jsx/SrcImport.vue
deleted file mode 100644
index 89f6fb3eb77e2b..00000000000000
--- a/playground/vue-jsx/SrcImport.vue
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/playground/vue-jsx/TsImport.vue b/playground/vue-jsx/TsImport.vue
deleted file mode 100644
index c63923d51947fa..00000000000000
--- a/playground/vue-jsx/TsImport.vue
+++ /dev/null
@@ -1,8 +0,0 @@
-
- Ts Import
- {{ foo }}
-
-
-
diff --git a/playground/vue-jsx/TsImportFile.ts b/playground/vue-jsx/TsImportFile.ts
deleted file mode 100644
index 62761d5733b432..00000000000000
--- a/playground/vue-jsx/TsImportFile.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const foo = 'success'
diff --git a/playground/vue-jsx/__tests__/vue-jsx.spec.ts b/playground/vue-jsx/__tests__/vue-jsx.spec.ts
deleted file mode 100644
index 7518f4bddd7c71..00000000000000
--- a/playground/vue-jsx/__tests__/vue-jsx.spec.ts
+++ /dev/null
@@ -1,117 +0,0 @@
-import { describe, expect, test } from 'vitest'
-import { editFile, isServe, page, untilUpdated } from '~utils'
-
-test('should render', async () => {
- expect(await page.textContent('.named')).toMatch('0')
- expect(await page.textContent('.named-specifier')).toMatch('1')
- expect(await page.textContent('.default')).toMatch('2')
- expect(await page.textContent('.default-tsx')).toMatch('3')
- expect(await page.textContent('.script')).toMatch('4')
- expect(await page.textContent('.src-import')).toMatch('5')
- expect(await page.textContent('.jsx-with-query')).toMatch('6')
- expect(await page.textContent('.other-ext')).toMatch('Other Ext')
- expect(await page.textContent('.ts-import')).toMatch('success')
-})
-
-test('should update', async () => {
- await page.click('.named')
- expect(await page.textContent('.named')).toMatch('1')
- await page.click('.named-specifier')
- expect(await page.textContent('.named-specifier')).toMatch('2')
- await page.click('.default')
- expect(await page.textContent('.default')).toMatch('3')
- await page.click('.default-tsx')
- expect(await page.textContent('.default-tsx')).toMatch('4')
- await page.click('.script')
- expect(await page.textContent('.script')).toMatch('5')
- await page.click('.src-import')
- expect(await page.textContent('.src-import')).toMatch('6')
- await page.click('.jsx-with-query')
- expect(await page.textContent('.jsx-with-query')).toMatch('7')
-})
-
-describe.runIf(isServe)('vue-jsx server', () => {
- test('hmr: named export', async () => {
- editFile('Comps.jsx', (code) =>
- code.replace('named {count', 'named updated {count')
- )
- await untilUpdated(() => page.textContent('.named'), 'named updated 0')
-
- // affect all components in same file
- expect(await page.textContent('.named-specifier')).toMatch('1')
- expect(await page.textContent('.default')).toMatch('2')
- // should not affect other components from different file
- expect(await page.textContent('.default-tsx')).toMatch('4')
- })
-
- test('hmr: named export via specifier', async () => {
- editFile('Comps.jsx', (code) =>
- code.replace('named specifier {count', 'named specifier updated {count')
- )
- await untilUpdated(
- () => page.textContent('.named-specifier'),
- 'named specifier updated 1'
- )
-
- // affect all components in same file
- expect(await page.textContent('.default')).toMatch('2')
- // should not affect other components on the page
- expect(await page.textContent('.default-tsx')).toMatch('4')
- })
-
- test('hmr: default export', async () => {
- editFile('Comps.jsx', (code) =>
- code.replace('default {count', 'default updated {count')
- )
- await untilUpdated(() => page.textContent('.default'), 'default updated 2')
-
- // should not affect other components on the page
- expect(await page.textContent('.default-tsx')).toMatch('4')
- })
-
- test('hmr: named export via specifier', async () => {
- // update another component
- await page.click('.named')
- expect(await page.textContent('.named')).toMatch('1')
-
- editFile('Comp.tsx', (code) =>
- code.replace('default tsx {count', 'default tsx updated {count')
- )
- await untilUpdated(
- () => page.textContent('.default-tsx'),
- 'default tsx updated 3'
- )
-
- // should not affect other components on the page
- expect(await page.textContent('.named')).toMatch('1')
- })
-
- test('hmr: script in .vue', async () => {
- editFile('Script.vue', (code) =>
- code.replace('script {count', 'script updated {count')
- )
- await untilUpdated(() => page.textContent('.script'), 'script updated 4')
-
- expect(await page.textContent('.src-import')).toMatch('6')
- })
-
- test('hmr: src import in .vue', async () => {
- await page.click('.script')
- editFile('SrcImport.jsx', (code) =>
- code.replace('src import {count', 'src import updated {count')
- )
- await untilUpdated(
- () => page.textContent('.src-import'),
- 'src import updated 5'
- )
-
- expect(await page.textContent('.script')).toMatch('5')
- })
-
- test('hmr: setup jsx in .vue', async () => {
- editFile('setup-syntax-jsx.vue', (code) =>
- code.replace('let count = ref(100)', 'let count = ref(1000)')
- )
- await untilUpdated(() => page.textContent('.setup-jsx'), '1000')
- })
-})
diff --git a/playground/vue-jsx/index.html b/playground/vue-jsx/index.html
deleted file mode 100644
index a285a008c13a9e..00000000000000
--- a/playground/vue-jsx/index.html
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/playground/vue-jsx/main.jsx b/playground/vue-jsx/main.jsx
deleted file mode 100644
index f13e60c45367c0..00000000000000
--- a/playground/vue-jsx/main.jsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { createApp } from 'vue'
-import { Named, NamedSpec, default as Default } from './Comps'
-import { default as TsxDefault } from './Comp'
-import OtherExt from './OtherExt.tesx'
-import JsxScript from './Script.vue'
-import JsxSrcImport from './SrcImport.vue'
-import JsxSetupSyntax from './setup-syntax-jsx.vue'
-// eslint-disable-next-line
-import JsxWithQuery from './Query.jsx?query=true'
-import TsImport from './TsImport.vue'
-
-function App() {
- return (
- <>
-
-
-
-
-
-
-
-
-
-
- >
- )
-}
-
-createApp(App).mount('#app')
diff --git a/playground/vue-jsx/package.json b/playground/vue-jsx/package.json
deleted file mode 100644
index b0d1496799223e..00000000000000
--- a/playground/vue-jsx/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "test-vue-jsx",
- "private": true,
- "version": "0.0.0",
- "scripts": {
- "dev": "vite",
- "build": "vite build",
- "debug": "node --inspect-brk ../../packages/vite/bin/vite",
- "preview": "vite preview"
- },
- "dependencies": {
- "vue": "^3.2.45"
- },
- "devDependencies": {
- "@vitejs/plugin-vue": "^4.0.0-alpha.0",
- "@vitejs/plugin-vue-jsx": "^3.0.0-alpha.0"
- }
-}
diff --git a/playground/vue-jsx/setup-syntax-jsx.vue b/playground/vue-jsx/setup-syntax-jsx.vue
deleted file mode 100644
index 0b16be7e773280..00000000000000
--- a/playground/vue-jsx/setup-syntax-jsx.vue
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- {{ count }}
-
-
diff --git a/playground/vue-jsx/vite.config.js b/playground/vue-jsx/vite.config.js
deleted file mode 100644
index 2f4ea255c95094..00000000000000
--- a/playground/vue-jsx/vite.config.js
+++ /dev/null
@@ -1,42 +0,0 @@
-const vueJsxPlugin = require('@vitejs/plugin-vue-jsx')
-const vuePlugin = require('@vitejs/plugin-vue')
-
-/**
- * @type {import('vite').UserConfig}
- */
-module.exports = {
- plugins: [
- vueJsxPlugin({
- include: [/\.tesx$/, /\.[jt]sx$/]
- }),
- vuePlugin(),
- {
- name: 'jsx-query-plugin',
- transform(code, id) {
- if (id.includes('?query=true')) {
- return `
-import { createVNode as _createVNode } from "vue";
-import { defineComponent, ref } from 'vue';
-export default defineComponent(() => {
- const count = ref(6);
-
- const inc = () => count.value++;
-
- return () => _createVNode("button", {
- "class": "jsx-with-query",
- "onClick": inc
- }, [count.value]);
-});
-`
- }
- }
- }
- ],
- build: {
- // to make tests faster
- minify: false
- },
- optimizeDeps: {
- disabled: true
- }
-}
diff --git a/playground/vue-legacy/Main.vue b/playground/vue-legacy/Main.vue
deleted file mode 100644
index a582c2e6aa6d62..00000000000000
--- a/playground/vue-legacy/Main.vue
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
Main.vue
-
-
- {{ css }}
-
-
-
-
diff --git a/playground/vue-legacy/__tests__/vue-legacy.spec.ts b/playground/vue-legacy/__tests__/vue-legacy.spec.ts
deleted file mode 100644
index 908e04567ca35b..00000000000000
--- a/playground/vue-legacy/__tests__/vue-legacy.spec.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { test } from 'vitest'
-import { getBg, untilUpdated } from '~utils'
-
-test('vue legacy assets', async () => {
- await untilUpdated(() => getBg('.main'), 'assets/asset', true)
-})
-
-test('async vue legacy assets', async () => {
- await untilUpdated(() => getBg('.module'), 'assets/asset', true)
-})
diff --git a/playground/vue-legacy/assets/asset.png b/playground/vue-legacy/assets/asset.png
deleted file mode 100644
index 1b3356a746b8bb..00000000000000
Binary files a/playground/vue-legacy/assets/asset.png and /dev/null differ
diff --git a/playground/vue-legacy/env.d.ts b/playground/vue-legacy/env.d.ts
deleted file mode 100644
index 31dca6bb40c906..00000000000000
--- a/playground/vue-legacy/env.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module '*.png'
diff --git a/playground/vue-legacy/index.html b/playground/vue-legacy/index.html
deleted file mode 100644
index 0f7b79435ed47d..00000000000000
--- a/playground/vue-legacy/index.html
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
diff --git a/playground/vue-legacy/inline.css b/playground/vue-legacy/inline.css
deleted file mode 100644
index 2207a25763ca6d..00000000000000
--- a/playground/vue-legacy/inline.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.inline-css {
- color: #0088ff;
-}
diff --git a/playground/vue-legacy/module.vue b/playground/vue-legacy/module.vue
deleted file mode 100644
index 10c7b42e4c4215..00000000000000
--- a/playground/vue-legacy/module.vue
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
diff --git a/playground/vue-legacy/package.json b/playground/vue-legacy/package.json
deleted file mode 100644
index f6d95702b77038..00000000000000
--- a/playground/vue-legacy/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "test-vue-legacy",
- "private": true,
- "version": "0.0.0",
- "scripts": {
- "dev": "vite",
- "build": "vite build",
- "debug": "node --inspect-brk ../../packages/vite/bin/vite",
- "preview": "vite preview"
- },
- "dependencies": {
- "vue": "^3.2.45"
- },
- "devDependencies": {
- "@vitejs/plugin-vue": "^4.0.0-alpha.0",
- "@vitejs/plugin-legacy": "workspace:*"
- }
-}
diff --git a/playground/vue-legacy/vite.config.ts b/playground/vue-legacy/vite.config.ts
deleted file mode 100644
index 5bb2f0efa06f53..00000000000000
--- a/playground/vue-legacy/vite.config.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import path from 'node:path'
-import fs from 'node:fs'
-import { defineConfig } from 'vite'
-import vuePlugin from '@vitejs/plugin-vue'
-import legacyPlugin from '@vitejs/plugin-legacy'
-
-export default defineConfig({
- base: '',
- resolve: {
- alias: {
- '@': __dirname
- }
- },
- plugins: [
- legacyPlugin({
- targets: ['defaults', 'not IE 11', 'chrome > 48']
- }),
- vuePlugin()
- ],
- build: {
- minify: false
- },
- // special test only hook
- // for tests, remove `
-