From 666560037ac5ae3555676a1902603f04063b8981 Mon Sep 17 00:00:00 2001 From: dalaoshu <165626830+shulaoda@users.noreply.github.com> Date: Thu, 29 Jan 2026 10:17:41 +0800 Subject: [PATCH 1/5] feat: update rolldown to 1.0.0-rc.2 (#21512) Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fd92cd1f..1a156435 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@voidzero-dev/vitepress-theme": "^4.3.0", "feed": "^5.2.0", "markdown-it-image-size": "^15.0.1", - "oxc-minify": "^0.110.0", + "oxc-minify": "^0.111.0", "vitepress": "^2.0.0-alpha.15", "vitepress-plugin-group-icons": "^1.7.1", "vitepress-plugin-llms": "^1.10.0", From f243df1218a19dbe0ea5f1655655d588f5a180a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0?= Date: Thu, 29 Jan 2026 11:53:18 +0900 Subject: [PATCH 2/5] refactor: use `import.meta.dirname` everywhere (#21509) --- .vitepress/config.ts | 2 +- guide/api-environment-frameworks.md | 5 +---- guide/api-javascript.md | 10 ++-------- guide/build.md | 21 ++++++--------------- guide/ssr.md | 6 +----- 5 files changed, 11 insertions(+), 33 deletions(-) diff --git a/.vitepress/config.ts b/.vitepress/config.ts index 60c87668..0680f80f 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -79,7 +79,7 @@ function inlineScript(file: string): HeadConfig { 'script', {}, fs.readFileSync( - path.resolve(__dirname, `./inlined-scripts/${file}`), + path.resolve(import.meta.dirname, `./inlined-scripts/${file}`), 'utf-8', ), ] diff --git a/guide/api-environment-frameworks.md b/guide/api-environment-frameworks.md index fd8171b2..089ce3f3 100644 --- a/guide/api-environment-frameworks.md +++ b/guide/api-environment-frameworks.md @@ -52,11 +52,8 @@ Given a Vite server configured in middleware mode as described by the [SSR setup ```js import fs from 'node:fs' import path from 'node:path' -import { fileURLToPath } from 'node:url' import { createServer } from 'vite' -const __dirname = path.dirname(fileURLToPath(import.meta.url)) - const viteServer = await createServer({ server: { middlewareMode: true }, appType: 'custom', @@ -75,7 +72,7 @@ app.use('*', async (req, res, next) => { const url = req.originalUrl // 1. Read index.html - const indexHtmlPath = path.resolve(__dirname, 'index.html') + const indexHtmlPath = path.resolve(import.meta.dirname, 'index.html') let template = fs.readFileSync(indexHtmlPath, 'utf-8') // 2. Apply Vite HTML transforms. This injects the Vite HMR client, diff --git a/guide/api-javascript.md b/guide/api-javascript.md index a3a87f9e..d12433f6 100644 --- a/guide/api-javascript.md +++ b/guide/api-javascript.md @@ -13,15 +13,12 @@ async function createServer(inlineConfig?: InlineConfig): Promise **Example Usage:** ```ts twoslash -import { fileURLToPath } from 'node:url' import { createServer } from 'vite' -const __dirname = fileURLToPath(new URL('.', import.meta.url)) - const server = await createServer({ // any valid user config options, plus `mode` and `configFile` configFile: false, - root: __dirname, + root: import.meta.dirname, server: { port: 1337, }, @@ -210,13 +207,10 @@ async function build( ```ts twoslash [vite.config.js] import path from 'node:path' -import { fileURLToPath } from 'node:url' import { build } from 'vite' -const __dirname = fileURLToPath(new URL('.', import.meta.url)) - await build({ - root: path.resolve(__dirname, './project'), + root: path.resolve(import.meta.dirname, './project'), base: '/foo/', build: { rollupOptions: { diff --git a/guide/build.md b/guide/build.md index 58bb662a..3a28937e 100644 --- a/guide/build.md +++ b/guide/build.md @@ -118,24 +118,21 @@ During build, all you need to do is to specify multiple `.html` files as entry p ```js twoslash [vite.config.js] import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import { defineConfig } from 'vite' -const __dirname = dirname(fileURLToPath(import.meta.url)) - export default defineConfig({ build: { rolldownOptions: { input: { - main: resolve(__dirname, 'index.html'), - nested: resolve(__dirname, 'nested/index.html'), + main: resolve(import.meta.dirname, 'index.html'), + nested: resolve(import.meta.dirname, 'nested/index.html'), }, }, }, }) ``` -If you specify a different root, remember that `__dirname` will still be the folder of your `vite.config.js` file when resolving the input paths. Therefore, you will need to add your `root` entry to the arguments for `resolve`. +If you specify a different root, remember that `import.meta.dirname` will still be the folder of your `vite.config.js` file when resolving the input paths. Therefore, you will need to add your `root` entry to the arguments for `resolve`. Note that for HTML files, Vite ignores the name given to the entry in the `rolldownOptions.input` object and instead respects the resolved id of the file when generating the HTML asset in the dist folder. This ensures a consistent structure with the way the dev server works. @@ -149,15 +146,12 @@ When it is time to bundle your library for distribution, use the [`build.lib` co ```js twoslash [vite.config.js (single entry)] import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import { defineConfig } from 'vite' -const __dirname = dirname(fileURLToPath(import.meta.url)) - export default defineConfig({ build: { lib: { - entry: resolve(__dirname, 'lib/main.js'), + entry: resolve(import.meta.dirname, 'lib/main.js'), name: 'MyLib', // the proper extensions will be added fileName: 'my-lib', @@ -180,17 +174,14 @@ export default defineConfig({ ```js twoslash [vite.config.js (multiple entries)] import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import { defineConfig } from 'vite' -const __dirname = dirname(fileURLToPath(import.meta.url)) - export default defineConfig({ build: { lib: { entry: { - 'my-lib': resolve(__dirname, 'lib/main.js'), - secondary: resolve(__dirname, 'lib/secondary.js'), + 'my-lib': resolve(import.meta.dirname, 'lib/main.js'), + secondary: resolve(import.meta.dirname, 'lib/secondary.js'), }, name: 'MyLib', }, diff --git a/guide/ssr.md b/guide/ssr.md index 00190cfa..85c2569a 100644 --- a/guide/ssr.md +++ b/guide/ssr.md @@ -68,12 +68,9 @@ When building an SSR app, you likely want to have full control over your main se ```js{15-18} twoslash [server.js] import fs from 'node:fs' import path from 'node:path' -import { fileURLToPath } from 'node:url' import express from 'express' import { createServer as createViteServer } from 'vite' -const __dirname = path.dirname(fileURLToPath(import.meta.url)) - async function createServer() { const app = express() @@ -111,7 +108,6 @@ The next step is implementing the `*` handler to serve server-rendered HTML: // @noErrors import fs from 'node:fs' import path from 'node:path' -import { fileURLToPath } from 'node:url' /** @type {import('express').Express} */ var app @@ -125,7 +121,7 @@ app.use('*all', async (req, res, next) => { try { // 1. Read index.html let template = fs.readFileSync( - path.resolve(__dirname, 'index.html'), + path.resolve(import.meta.dirname, 'index.html'), 'utf-8', ) From 5e46e13e5e13fce657bc6a9f819e03f18745a00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0?= Date: Thu, 29 Jan 2026 12:33:57 +0900 Subject: [PATCH 3/5] fix(legacy): use `prebuilt-chunk` for polyfill chunks (#21498) --- guide/migration.md | 1 - 1 file changed, 1 deletion(-) diff --git a/guide/migration.md b/guide/migration.md index 9a0a2856..e61d6412 100644 --- a/guide/migration.md +++ b/guide/migration.md @@ -342,7 +342,6 @@ The following options are deprecated and will be removed in the future: These breaking changes are expected to only affect a minority of use cases: - **[TODO: this will be fixed before stable release]** https://github.com/rolldown/rolldown/issues/5726 (affects nuxt, qwik) -- **[TODO: this will be fixed before stable release]** Legacy chunks are emitted as an asset file instead of a chunk file due to the lack of prebuilt chunk emit feature ([rolldown#4304](https://github.com/rolldown/rolldown/issues/4034)). This means the chunk related options does not apply to legacy chunks and the manifest file will not include legacy chunks as a chunk file. - **[TODO: this will be fixed before stable release]** `@vite-ignore` comment edge case ([rolldown-vite#426](https://github.com/vitejs/rolldown-vite/issues/426)) - [Extglobs](https://github.com/micromatch/picomatch/blob/master/README.md#extglobs) are not supported yet ([rolldown-vite#365](https://github.com/vitejs/rolldown-vite/issues/365)) - `define` does not share reference for objects: When you pass an object as a value to `define`, each variable will have a separate copy of the object. See [Oxc Transformer document](https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement#define) for more details. From f8fb0fa785eaa4c64b211a9efedaeb9a6da44e96 Mon Sep 17 00:00:00 2001 From: waynzh Date: Fri, 30 Jan 2026 10:53:24 +0800 Subject: [PATCH 4/5] docs(cn): resolve conflicts --- .vitepress/config.ts | 6 ------ guide/api-environment-frameworks.md | 5 ----- guide/build.md | 6 +----- guide/migration.md | 17 ----------------- 4 files changed, 1 insertion(+), 33 deletions(-) diff --git a/.vitepress/config.ts b/.vitepress/config.ts index f295bffa..9dc9022f 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -43,15 +43,9 @@ function inlineScript(file: string): HeadConfig { 'script', {}, fs.readFileSync( -<<<<<<< HEAD - path.resolve(__dirname, `./inlined-scripts/${file}`), - 'utf-8' - ) -======= path.resolve(import.meta.dirname, `./inlined-scripts/${file}`), 'utf-8', ), ->>>>>>> 5e46e13e5e13fce657bc6a9f819e03f18745a00c ] } diff --git a/guide/api-environment-frameworks.md b/guide/api-environment-frameworks.md index 45e7fe97..16411bcc 100644 --- a/guide/api-environment-frameworks.md +++ b/guide/api-environment-frameworks.md @@ -71,13 +71,8 @@ const serverEnvironment = viteServer.environments.server app.use('*', async (req, res, next) => { const url = req.originalUrl -<<<<<<< HEAD // 1. 读取 index.html - const indexHtmlPath = path.resolve(__dirname, 'index.html') -======= - // 1. Read index.html const indexHtmlPath = path.resolve(import.meta.dirname, 'index.html') ->>>>>>> 5e46e13e5e13fce657bc6a9f819e03f18745a00c let template = fs.readFileSync(indexHtmlPath, 'utf-8') // 2. 应用 Vite HTML 转换。这将注入 Vite HMR 客户端, diff --git a/guide/build.md b/guide/build.md index 0d31c030..fd774bcd 100644 --- a/guide/build.md +++ b/guide/build.md @@ -132,11 +132,7 @@ export default defineConfig({ }) ``` -<<<<<<< HEAD -如果你指定了另一个根目录,请记住,在解析输入路径时,`__dirname` 的值将仍然是 `vite.config.js` 文件所在的目录。因此,你需要把对应入口文件的 `root` 的路径添加到 `resolve` 的参数中。 -======= -If you specify a different root, remember that `import.meta.dirname` will still be the folder of your `vite.config.js` file when resolving the input paths. Therefore, you will need to add your `root` entry to the arguments for `resolve`. ->>>>>>> 5e46e13e5e13fce657bc6a9f819e03f18745a00c +如果你指定了另一个根目录,请记住,在解析输入路径时,`import.meta.dirname` 的值将仍然是 `vite.config.js` 文件所在的目录。因此,你需要把对应入口文件的 `root` 的路径添加到 `resolve` 的参数中。 请注意,在 HTML 文件中,Vite 忽略了 `rolldownOptions.input` 对象中给定的入口名称,而是在生成 dist 文件夹中的 HTML 资源文件时,使用了文件已解析的路径 ID。这确保了与开发服务器的工作方式保持一致的结构。 diff --git a/guide/migration.md b/guide/migration.md index dace30b2..195b9639 100644 --- a/guide/migration.md +++ b/guide/migration.md @@ -341,9 +341,7 @@ const plugin = { 还有其他一些只影响少数用户的破坏性更改。 -<<<<<<< HEAD - **[TODO: 这将在稳定版发布前修复]** https://github.com/rolldown/rolldown/issues/5726 (affects nuxt, qwik) -- **[TODO: 这将在稳定版发布前修复]** 由于缺少预构建块输出功能([rolldown#4304](https://github.com/rolldown/rolldown/issues/4034)),旧版块现在作为资源文件而不是块文件输出。这意味着块相关选项不适用于旧版块,清单文件也不会将旧版块包含为块文件。 - **[TODO: 这将在稳定版发布前修复]** `@vite-ignore` 注释边缘情况 ([rolldown-vite#426](https://github.com/vitejs/rolldown-vite/issues/426)) - [Extglobs](https://github.com/micromatch/picomatch/blob/master/README.md#extglobs) 尚未得到支持 ([rolldown-vite#365](https://github.com/vitejs/rolldown-vite/issues/365)) - `define` 不共享对象引用:当你传递一个对象作为 `define` 的值时,每个变量都会有一个单独的对象副本。详见 [Oxc 转换器文档](https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement#define)。 @@ -356,21 +354,6 @@ const plugin = { - 使用 plugin-legacy 转换到低于 ES5 的版本不受支持 ([rolldown-vite#452](https://github.com/vitejs/rolldown-vite/issues/452)) - 向 `build.target` 选项传递同一浏览器的多个版本现在会报错:esbuild 会选择最新的版本,这可能不是你的本意。 - Rolldown 缺少支持:以下功能不受 Rolldown 支持,Vite 也不再支持这些功能。 -======= -- **[TODO: this will be fixed before stable release]** https://github.com/rolldown/rolldown/issues/5726 (affects nuxt, qwik) -- **[TODO: this will be fixed before stable release]** `@vite-ignore` comment edge case ([rolldown-vite#426](https://github.com/vitejs/rolldown-vite/issues/426)) -- [Extglobs](https://github.com/micromatch/picomatch/blob/master/README.md#extglobs) are not supported yet ([rolldown-vite#365](https://github.com/vitejs/rolldown-vite/issues/365)) -- `define` does not share reference for objects: When you pass an object as a value to `define`, each variable will have a separate copy of the object. See [Oxc Transformer document](https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement#define) for more details. -- `bundle` object changes (`bundle` is an object passed in `generateBundle` / `writeBundle` hooks, returned by `build` function): - - Assigning to `bundle[foo]` is not supported. This is discouraged by Rollup as well. Please use `this.emitFile()` instead. - - the reference is not shared across the hooks ([rolldown-vite#410](https://github.com/vitejs/rolldown-vite/issues/410)) - - `structuredClone(bundle)` errors with `DataCloneError: # could not be cloned`. This is not supported anymore. Please clone it with `structuredClone({ ...bundle })`. ([rolldown-vite#128](https://github.com/vitejs/rolldown-vite/issues/128)) -- All parallel hooks in Rollup works as sequential hooks. See [Rolldown's documentation](https://rolldown.rs/apis/plugin-api#sequential-hook-execution) for more details. -- `"use strict";` is not injected sometimes. See [Rolldown's documentation](https://rolldown.rs/in-depth/directives) for more details. -- Transforming to lower than ES5 with plugin-legacy is not supported ([rolldown-vite#452](https://github.com/vitejs/rolldown-vite/issues/452)) -- Passing the same browser with multiple versions of it to `build.target` option now errors: esbuild selects the latest version of it, which was probably not what you intended. -- Missing support by Rolldown: The following features are not supported by Rolldown and is no longer supported by Vite. ->>>>>>> 5e46e13e5e13fce657bc6a9f819e03f18745a00c - `build.rollupOptions.output.format: 'system'` ([rolldown#2387](https://github.com/rolldown/rolldown/issues/2387)) - `build.rollupOptions.output.format: 'amd'` ([rolldown#2387](https://github.com/rolldown/rolldown/issues/2528)) - 完整的 TypeScript 遗留命名空间支持 ([oxc-project/oxc#14227](https://github.com/oxc-project/oxc/issues/14227)) From fbfaad7180dfe66672073199c86e3db7ef4b853e Mon Sep 17 00:00:00 2001 From: waynzh Date: Fri, 30 Jan 2026 10:57:41 +0800 Subject: [PATCH 5/5] chore: update --- package.json | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/package.json b/package.json index 70aab719..fbd60e4c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,4 @@ { -<<<<<<< HEAD "name": "vite-docs-cn", "version": "8.0.0-beta.10", "description": "Vite.js documentation Chinese translation.", @@ -40,27 +39,4 @@ "gitHooks": { "commit-msg": "node scripts/verifyCommit.js" } -======= - "name": "@vitejs/monorepo-docs", - "private": true, - "type": "module", - "scripts": { - "docs": "vitepress dev", - "docs-build": "vitepress build", - "docs-serve": "vitepress serve" - }, - "devDependencies": { - "@shikijs/vitepress-twoslash": "^3.21.0", - "@types/express": "^5.0.6", - "@voidzero-dev/vitepress-theme": "^4.3.0", - "feed": "^5.2.0", - "markdown-it-image-size": "^15.0.1", - "oxc-minify": "^0.111.0", - "vitepress": "^2.0.0-alpha.15", - "vitepress-plugin-group-icons": "^1.7.1", - "vitepress-plugin-llms": "^1.10.0", - "vue": "^3.5.27", - "vue-tsc": "^3.2.4" - } ->>>>>>> 5e46e13e5e13fce657bc6a9f819e03f18745a00c }