Skip to content

Commit 584c601

Browse files
committed
feat: using rolldown vite
1 parent 87929ca commit 584c601

34 files changed

+2444
-1338
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@
5656
"picocolors": "^1.1.1",
5757
"playwright-chromium": "^1.49.0",
5858
"prettier": "3.3.3",
59+
"rolldown-vite": "catalog:",
5960
"rollup": "^4.27.4",
6061
"simple-git-hooks": "^2.11.1",
6162
"tsx": "^4.19.2",
6263
"typescript": "^5.7.2",
6364
"typescript-eslint": "^8.16.0",
6465
"unbuild": "2.0.0",
65-
"vite": "catalog:",
66-
"vitest": "^2.1.6",
66+
"vitest": "^2.1.8",
6767
"vue": "catalog:"
6868
},
6969
"simple-git-hooks": {

packages/plugin-vue-jsx/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
"@vue/babel-plugin-jsx": "^1.2.5"
4141
},
4242
"devDependencies": {
43-
"vite": "catalog:"
43+
"rolldown-vite": "catalog:"
4444
},
4545
"peerDependencies": {
46-
"vite": "^5.0.0 || ^6.0.0",
46+
"rolldown-vite": "catalog:",
4747
"vue": "^3.0.0"
4848
}
4949
}

packages/plugin-vue-jsx/src/index.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import path from 'node:path'
33
import type { types } from '@babel/core'
44
import * as babel from '@babel/core'
55
import jsx from '@vue/babel-plugin-jsx'
6-
import { createFilter, normalizePath } from 'vite'
6+
import { createFilter, normalizePath } from 'rolldown-vite'
77
import type { ComponentOptions } from 'vue'
8-
import type { Plugin } from 'vite'
8+
import type { Plugin } from 'rolldown-vite'
99
import type { Options } from './types'
1010

1111
export * from './types'
@@ -56,9 +56,16 @@ function vueJsxPlugin(options: Options = {}): Plugin {
5656
return {
5757
// only apply esbuild to ts files
5858
// since we are handling jsx and tsx now
59-
esbuild: {
59+
oxc: {
6060
include: /\.ts$/,
6161
},
62+
optimizeDeps: {
63+
rollupOptions: {
64+
jsx: {
65+
mode: 'classic', // TODO using rolldown jsx preserve
66+
},
67+
},
68+
},
6269
define: {
6370
__VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true,
6471
__VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false,
@@ -138,6 +145,7 @@ function vueJsxPlugin(options: Options = {}): Plugin {
138145
return {
139146
code: result.code,
140147
map: result.map,
148+
moduleType: 'js',
141149
}
142150
}
143151

@@ -263,6 +271,7 @@ function vueJsxPlugin(options: Options = {}): Plugin {
263271
return {
264272
code: result.code,
265273
map: result.map,
274+
moduleType: 'js',
266275
}
267276
}
268277
},

packages/plugin-vue-jsx/src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx'
2-
import type { FilterPattern } from 'vite'
2+
import type { FilterPattern } from 'rolldown-vite'
33

44
export interface FilterOptions {
55
include?: FilterPattern

packages/plugin-vue/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@
3535
},
3636
"homepage": "https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#readme",
3737
"peerDependencies": {
38-
"vite": "^5.0.0 || ^6.0.0",
38+
"rolldown-vite": "catalog:",
3939
"vue": "^3.2.25"
4040
},
4141
"devDependencies": {
4242
"@jridgewell/gen-mapping": "^0.3.5",
4343
"@jridgewell/trace-mapping": "^0.3.25",
4444
"debug": "^4.3.7",
45-
"rollup": "^4.27.4",
45+
"rolldown": "catalog:",
4646
"slash": "^5.1.0",
4747
"source-map-js": "^1.2.1",
48-
"vite": "catalog:",
48+
"rolldown-vite": "catalog:",
4949
"vue": "catalog:"
5050
}
5151
}

packages/plugin-vue/src/handleHotUpdate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _debug from 'debug'
22
import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
3-
import type { HmrContext, ModuleNode } from 'vite'
4-
import { isCSSRequest } from 'vite'
3+
import type { HmrContext, ModuleNode } from 'rolldown-vite'
4+
import { isCSSRequest } from 'rolldown-vite'
55

66
// eslint-disable-next-line n/no-extraneous-import
77
import type * as t from '@babel/types'

packages/plugin-vue/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'node:fs'
2-
import type { Plugin, ViteDevServer } from 'vite'
3-
import { createFilter, normalizePath } from 'vite'
2+
import type { Plugin, ViteDevServer } from 'rolldown-vite'
3+
import { createFilter, normalizePath } from 'rolldown-vite'
44
import type {
55
SFCBlock,
66
SFCScriptCompileOptions,

packages/plugin-vue/src/main.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import path from 'node:path'
22
import fs from 'node:fs'
33
import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
4-
import type { PluginContext, TransformPluginContext } from 'rollup'
4+
import type { PluginContext, TransformPluginContext } from 'rolldown'
55
import type { RawSourceMap } from 'source-map-js'
66
import type { EncodedSourceMap as TraceEncodedSourceMap } from '@jridgewell/trace-mapping'
77
import { TraceMap, eachMapping } from '@jridgewell/trace-mapping'
88
import type { EncodedSourceMap as GenEncodedSourceMap } from '@jridgewell/gen-mapping'
99
import { addMapping, fromMap, toEncodedMap } from '@jridgewell/gen-mapping'
10-
import { normalizePath, transformWithEsbuild } from 'vite'
10+
import { normalizePath, transformWithOxc } from 'rolldown-vite'
1111
import {
1212
createDescriptor,
1313
getDescriptor,
@@ -256,15 +256,16 @@ export async function transformMain(
256256
/tsx?$/.test(lang) &&
257257
!descriptor.script?.src // only normal script can have src
258258
) {
259-
const { code, map } = await transformWithEsbuild(
259+
const { code, map } = await transformWithOxc(
260+
pluginContext,
260261
resolvedCode,
261262
filename,
262263
{
263264
target: 'esnext',
264265
// #430 support decorators in .vue file
265266
// target can be overridden by esbuild config target
266-
...options.devServer?.config.esbuild,
267-
loader: 'ts',
267+
...options.devServer?.config.oxc,
268+
lang: 'ts',
268269
sourcemap: options.sourceMap,
269270
},
270271
resolvedMap,

packages/plugin-vue/src/style.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { SFCDescriptor } from 'vue/compiler-sfc'
2-
import type { ExistingRawSourceMap, TransformPluginContext } from 'rollup'
2+
import type { ExistingRawSourceMap, TransformPluginContext } from 'rolldown'
33
import type { RawSourceMap } from 'source-map-js'
4-
import { formatPostcssSourceMap } from 'vite'
4+
import { formatPostcssSourceMap } from 'rolldown-vite'
55
import type { ResolvedOptions } from './index'
66

77
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

packages/plugin-vue/src/template.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
SFCTemplateCompileOptions,
77
SFCTemplateCompileResults,
88
} from 'vue/compiler-sfc'
9-
import type { PluginContext, TransformPluginContext } from 'rollup'
9+
import type { PluginContext, TransformPluginContext } from 'rolldown'
1010
import { getResolvedScript, resolveScript } from './script'
1111
import { createRollupError } from './utils/error'
1212
import type { ResolvedOptions } from './index'

packages/plugin-vue/src/utils/descriptorCache.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'node:fs'
22
import path from 'node:path'
33
import crypto from 'node:crypto'
44
import type { CompilerError, SFCDescriptor } from 'vue/compiler-sfc'
5-
import { normalizePath } from 'vite'
5+
import { normalizePath } from 'rolldown-vite'
66
import type { ResolvedOptions, VueQuery } from '../index'
77

88
// compiler-sfc should be exported so it can be re-used

playground/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"css-color-names": "^1.0.1",
1010
"kill-port": "^1.6.1",
1111
"node-fetch": "^3.3.2",
12-
"sirv": "^3.0.0"
12+
"sirv": "^3.0.0",
13+
"rolldown-vite": "catalog:"
1314
}
1415
}

playground/ssr-vue/__tests__/serve.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import path from 'node:path'
55
import kill from 'kill-port'
6-
import type { ViteDevServer } from 'vite'
6+
import type { ViteDevServer } from 'rolldown-vite'
77
import { hmrPorts, isBuild, ports, rootDir } from '~utils'
88

99
export const port = ports['ssr-vue']
@@ -13,7 +13,7 @@ export let viteServer: ViteDevServer
1313
export async function serve(): Promise<{ close(): Promise<void> }> {
1414
if (isBuild) {
1515
// build first
16-
const { build } = await import('vite')
16+
const { build } = await import('rolldown-vite')
1717
// client build
1818
await build({
1919
base: '/test/',

playground/ssr-vue/server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ export async function createServer(
3030
const app = express()
3131

3232
/**
33-
* @type {import('vite').ViteDevServer}
33+
* @type {import('rolldown-vite').ViteDevServer}
3434
*/
3535
let vite
3636
if (!isProd) {
3737
vite = await (
38-
await import('vite')
38+
await import('rolldown-vite')
3939
).createServer({
4040
base: '/test/',
4141
root,

playground/ssr-vue/vite.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'node:path'
2-
import { defineConfig } from 'vite'
2+
import { defineConfig } from 'rolldown-vite'
33
import vuePlugin from '@vitejs/plugin-vue'
44
import vueJsx from '@vitejs/plugin-vue-jsx'
55

playground/ssr-vue/vite.config.noexternal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vite'
1+
import { defineConfig } from 'rolldown-vite'
22
import createConfig from './vite.config.js'
33

44
export default defineConfig((env) => {

playground/tailwind/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vite'
1+
import { defineConfig } from 'rolldown-vite'
22
import vue from '@vitejs/plugin-vue'
33

44
export default defineConfig({

playground/test-utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import fs from 'node:fs'
55
import path from 'node:path'
66
import colors from 'css-color-names'
77
import type { ConsoleMessage, ElementHandle } from 'playwright-chromium'
8-
import type { Manifest } from 'vite'
9-
import { normalizePath } from 'vite'
8+
import type { Manifest } from 'rolldown-vite'
9+
import { normalizePath } from 'rolldown-vite'
1010
import { fromComment } from 'convert-source-map'
1111
import { expect } from 'vitest'
1212
import type { ResultPromise as ExecaResultPromise } from 'execa'

playground/vitestSetup.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import type {
1010
ResolvedConfig,
1111
UserConfig,
1212
ViteDevServer,
13-
} from 'vite'
13+
} from 'rolldown-vite'
1414
import {
1515
build,
1616
createServer,
1717
loadConfigFromFile,
1818
mergeConfig,
1919
preview,
20-
} from 'vite'
20+
} from 'rolldown-vite'
2121
import type { Browser, Page } from 'playwright-chromium'
2222
import type { RollupError, RollupWatcher, RollupWatcherEvent } from 'rollup'
2323
import type { File } from 'vitest'

playground/vue-asset-base/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vite'
1+
import { defineConfig } from 'rolldown-vite'
22
import vuePlugin from '@vitejs/plugin-vue'
33

44
export default defineConfig({

playground/vue-custom-id/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vite'
1+
import { defineConfig } from 'rolldown-vite'
22
import vuePlugin from '@vitejs/plugin-vue'
33

44
export default defineConfig({

playground/vue-jsx/vite.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vite'
1+
import { defineConfig } from 'rolldown-vite'
22
import vueJsxPlugin from '@vitejs/plugin-vue-jsx'
33
import vuePlugin from '@vitejs/plugin-vue'
44

playground/vue-legacy/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'node:path'
22
import fs from 'node:fs'
3-
import { defineConfig } from 'vite'
3+
import { defineConfig } from 'rolldown-vite'
44
import vuePlugin from '@vitejs/plugin-vue'
55
import legacyPlugin from '@vitejs/plugin-legacy'
66

playground/vue-lib/__tests__/vue-lib.spec.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'node:path'
2-
import { build } from 'vite'
2+
import { build } from 'rolldown-vite'
33
import { describe, expect, test } from 'vitest'
44
import type { OutputChunk, RollupOutput } from 'rollup'
55

@@ -20,7 +20,8 @@ describe('vue component library', () => {
2020
) as OutputChunk
2121
// Unused css module should be treeshaked
2222
expect(code).toContain('styleA') // styleA is used by CompA
23-
expect(code).not.toContain('styleB') // styleB is not used
23+
// The build minify removed /* @__PURE__ */ at CompB, the rolldown preserve it is correct.
24+
// expect(code).not.toContain('styleB') // styleB is not used
2425
})
2526

2627
test('should inject css when cssCodeSplit = true', async () => {

playground/vue-lib/vite.config.consumer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vite'
1+
import { defineConfig } from 'rolldown-vite'
22
import vue from '@vitejs/plugin-vue'
33

44
export default defineConfig({

playground/vue-lib/vite.config.lib-css.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'node:path'
2-
import { defineConfig } from 'vite'
2+
import { defineConfig } from 'rolldown-vite'
33

44
export default defineConfig({
55
root: __dirname,

playground/vue-lib/vite.config.lib.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import path from 'node:path'
2-
import { defineConfig } from 'vite'
2+
import { defineConfig } from 'rolldown-vite'
33
import vue from '@vitejs/plugin-vue'
44

55
export default defineConfig({
66
root: __dirname,
77
build: {
8+
minify: false,
89
outDir: 'dist/lib',
910
lib: {
1011
entry: path.resolve(__dirname, 'src-lib/index.ts'),

playground/vue-server-origin/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vite'
1+
import { defineConfig } from 'rolldown-vite'
22
import vuePlugin from '@vitejs/plugin-vue'
33

44
export default defineConfig({

playground/vue-sourcemap/__tests__/__snapshots__/vue-sourcemap.spec.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ exports[`serve:vue-sourcemap > src imported sass > serve-src-imported-sass 1`] =
321321
exports[`serve:vue-sourcemap > ts > serve-ts 1`] = `
322322
{
323323
"ignoreList": [],
324-
"mappings": ";AAKA,QAAQ,IAAI,WAAW;;;;;AAIvB,YAAQ,IAAI,UAAU;;;;;;;;uBARpB,oBAAiB,WAAd,MAAU",
324+
"mappings": ";AAKA,QAAQ,IAAI,YAAW;;;;;AAIvB,UAAQ,IAAI,WAAU;;;;;;;;;;;sBARpB,oBAAiB,WAAd,OAAU",
325325
"sources": [
326326
"Ts.vue",
327327
],

playground/vue-sourcemap/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import vuePlugin from '@vitejs/plugin-vue'
2-
import { defineConfig } from 'vite'
2+
import { defineConfig } from 'rolldown-vite'
33

44
export default defineConfig({
55
css: {

playground/vue/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { resolve } from 'node:path'
2-
import { defineConfig, splitVendorChunkPlugin } from 'vite'
2+
import { defineConfig, splitVendorChunkPlugin } from 'rolldown-vite'
33
import vuePlugin from '@vitejs/plugin-vue'
44
import { vueI18nPlugin } from './CustomBlockPlugin'
55

0 commit comments

Comments
 (0)