Main.vue
-
- {{ css }}
-
- 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 from virtual module: {{ foo.msg }}
-this will be styled with a font-face
- -{{ state.protocol }}
-msg from nested virtual module: {{ virtualMsg }}
- -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 () => ( - - ) -}) 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 () => ( - - ) -}) 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 @@ - -{{ 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 ( - <> -{{ count }}
-Main.vue
-
- {{ css }}
-
- module.vue
-