]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: use rolldown
authordaiwei <daiwei521@126.com>
Mon, 25 Aug 2025 03:16:32 +0000 (11:16 +0800)
committerdaiwei <daiwei521@126.com>
Mon, 25 Aug 2025 03:59:27 +0000 (11:59 +0800)
.github/contributing.md
.github/renovate.json5
packages/compiler-sfc/src/template/transformAssetUrl.ts
packages/shared/src/makeMap.ts
packages/vue/README.md
scripts/aliases.js
scripts/build-types.js
scripts/create-rolldown-config.js
scripts/dev.js
scripts/inline-enums.js
scripts/usage-size.js

index 2554582b887f753e1e57f8d6f7b077138674ae8f..6a0d0852e2abeb52f44057c72419e1a79939822a 100644 (file)
@@ -94,8 +94,7 @@ $ pnpm i # install the dependencies of the project
 A high level overview of tools used:
 
 - [TypeScript](https://www.typescriptlang.org/) as the development language
-- [Vite](https://vitejs.dev/) and [ESBuild](https://esbuild.github.io/) for development bundling
-- [Rollup](https://rollupjs.org) for production bundling
+- [Rolldown](https://rolldown.rs/) for bundling
 - [Vitest](https://vitest.dev/) for unit testing
 - [Prettier](https://prettier.io/) for code formatting
 - [ESLint](https://eslint.org/) for static error prevention (outside of types)
@@ -138,7 +137,7 @@ nr build runtime-core
 nr build runtime --all
 ```
 
-Note that `nr build` uses `rollup-plugin-esbuild` for transpiling typescript and **does not perform type checking**. To run type check on the entire codebase, run `nr check`. Type checks are also automatically run on each commit.
+Note that `nr build` uses [`oxc-transform`](https://oxc.rs/docs/guide/usage/transformer.html) for transpiling typescript and **does not perform type checking**. To run type check on the entire codebase, run `nr check`. Type checks are also automatically run on each commit.
 
 #### Build Formats
 
@@ -155,7 +154,7 @@ Additional formats that only apply to the main `vue` package:
 - **`esm-bundler-runtime`**
 - **`esm-browser-runtime`**
 
-More details about each of these formats can be found in the [`vue` package README](https://github.com/vuejs/core/blob/main/packages/vue/README.md#which-dist-file-to-use) and the [Rollup config file](https://github.com/vuejs/core/blob/main/rollup.config.js).
+More details about each of these formats can be found in the [`vue` package README](https://github.com/vuejs/core/blob/main/packages/vue/README.md#which-dist-file-to-use) and the [Rolldown config file](https://github.com/vuejs/core/blob/main/scripts/create-rolldown-config.js).
 
 For example, to build `runtime-core` with the global build only:
 
@@ -175,7 +174,7 @@ Use the `--sourcemap` or `-s` flag to build with source maps. Note this will mak
 
 ### `nr build-dts`
 
-This command builds the type declarations for all packages. It first generates the raw `.d.ts` files in the `temp` directory, then uses [rollup-plugin-dts](https://github.com/Swatinem/rollup-plugin-dts) to roll the types into a single `.d.ts` file for each package.
+This command builds the type declarations for all packages. It first generates the raw `.d.ts` files in the `temp` directory, then uses [rolldown-plugin-dts](https://github.com/sxzz/rolldown-plugin-dts) to roll the types into a single `.d.ts` file for each package.
 
 ### `nr check`
 
@@ -283,7 +282,7 @@ import { h } from '@vue/runtime-core'
 This is made possible via several configurations:
 
 - For TypeScript, `compilerOptions.paths` in `tsconfig.json`
-- Vitest and Rollup share the same set of aliases from `scripts/aliases.js`
+- Vitest and Rolldown share the same set of aliases from `scripts/aliases.js`
 - For plain Node.js, they are linked using [PNPM Workspaces](https://pnpm.io/workspaces).
 
 ### Package Dependencies
index aad4afa132a4f2cb61e4b9dbd27e44d0310e80a5..3babb862b10c904d965b209ca201fe217579d9d9 100644 (file)
       groupName: 'build',
       matchPackageNames: [
         'vite',
-        '@swc/core',
-        'rollup{/,}**',
-        'esbuild{/,}**',
-        '@rollup{/,}**',
+        'rolldown{/,}**',
+        '@rolldown{/,}**',
+        'oxc{/,}**',
         '@vitejs{/,}**',
       ],
     },
index 6291e21bbba29c9a0bc30b85b5d9b767a91a24bf..0c5568aea2d2b5a9d24e84e2a051dab9176e7c7d 100644 (file)
@@ -124,7 +124,7 @@ export const transformAssetUrl: NodeTransform = (
         const basePath = base.path || '/'
 
         // when packaged in the browser, path will be using the posix-
-        // only version provided by rollup-plugin-node-builtins.
+        // only version provided by @rolldown/plugin-node-polyfills.
         attr.value.content =
           host +
           (path.posix || path).join(basePath, url.path + (url.hash || ''))
index e85efe21e5b33d545ca74452ccb778b0d9f4123a..b9acb49d7ce45301a6acb2e697317ec99ad00d35 100644 (file)
@@ -3,7 +3,7 @@
  * is in that map.
  * IMPORTANT: all calls of this function must be prefixed with
  * \/\*#\_\_PURE\_\_\*\/
- * So that rollup can tree-shake them if necessary.
+ * So that they can be tree-shaken if necessary.
  */
 
 /*! #__NO_SIDE_EFFECTS__ */
index 757ea82f5d7f81a51f8be75f58549c19899287c0..f2bd13eb7f15ee74bb0726257926f6f71c2a6c03 100644 (file)
@@ -22,7 +22,7 @@
 
 - **`vue(.runtime).esm-bundler.js`**:
 
-  - For use with bundlers like `webpack`, `rollup` and `parcel`.
+  - For use with bundlers like `rolldown`, `webpack`, `rollup` and `parcel`.
   - Leaves prod/dev branches with `process.env.NODE_ENV` guards (must be replaced by bundler)
   - Does not ship minified builds (to be done together with the rest of the code after bundling)
   - Imports dependencies (e.g. `@vue/runtime-core`, `@vue/compiler-core`)
index d50498a80aa3b37c53ac897c16c408d4bf714dc0..53604ecf89f75e223465c86327e3c987a93353d9 100644 (file)
@@ -1,5 +1,5 @@
 // @ts-check
-// these aliases are shared between vitest and rollup
+// these aliases are shared between vitest and rolldown
 import { readdirSync, statSync } from 'node:fs'
 import path from 'node:path'
 import { fileURLToPath } from 'node:url'
index b7dd75dd34ea3c52e4f01af5bdd85120eacbb38d..2747f1ba41145c50277040fa4443ffb07a86cac7 100644 (file)
@@ -23,10 +23,7 @@ for (const file of await glob('packages/*/src/**/*.ts')) {
   })
   if (dts.errors.length) {
     dts.errors.forEach(err => {
-      // temporary workaround for https://github.com/oxc-project/oxc/issues/5668
-      if (!err.includes('set value(_: S)')) {
-        console.error(err)
-      }
+      console.error(err)
       errs += err + '\n'
     })
   }
index 443ec87d405ca51dc7357fde187b1a034981f168..95b62549d7a6a3a686b1280b716e76894a8b8030 100644 (file)
@@ -147,7 +147,6 @@ export function createConfigsForPackage({
 
     output.externalLiveBindings = false
 
-    // https://github.com/rollup/rollup/pull/5380
     // @ts-expect-error Not supported yet
     output.reexportProtoFromExternal = false
 
@@ -158,7 +157,7 @@ export function createConfigsForPackage({
     let entryFile = /runtime$/.test(format) ? `src/runtime.ts` : `src/index.ts`
 
     // the compat build needs both default AND named exports. This will cause
-    // Rollup to complain for non-ESM targets, so we use separate entries for
+    // Rolldown to complain for non-ESM targets, so we use separate entries for
     // esm vs. non-esm builds.
     if (isCompatPackage && (isBrowserESMBuild || isBundlerESMBuild)) {
       entryFile = /runtime$/.test(format)
@@ -240,7 +239,11 @@ export function createConfigsForPackage({
       }
 
       if (Object.keys(replacements).length) {
-        return [replacePlugin(replacements)]
+        return [
+          replacePlugin(replacements, {
+            preventAssignment: true,
+          }),
+        ]
       } else {
         return []
       }
@@ -328,7 +331,6 @@ export function createConfigsForPackage({
         }
       },
       treeshake: {
-        // https://github.com/rolldown/rolldown/issues/1917
         moduleSideEffects: false,
       },
     }
index afdba8981d9c378d82c555eb24a7b922488d5bf6..0a178e3b7d5db08891f70f91b9de492ac521ddfa 100644 (file)
@@ -44,11 +44,9 @@ const [config, prodConfig] = createConfigsForPackage({
 
 const configToUse = prod ? prodConfig : config
 
-watch(configToUse).then(watcher => {
-  console.log(`watching: ${configToUse.output.file}`)
-  watcher.on('event', event => {
-    if (event.code === 'BUNDLE_END') {
-      console.log(`rebuilt ${config.output.file} in ${event.duration}ms`)
-    }
-  })
+console.log(`watching: ${configToUse.output.file}`)
+watch(configToUse).on('event', event => {
+  if (event.code === 'BUNDLE_END') {
+    console.log(`rebuilt ${config.output.file} in ${event.duration}ms`)
+  }
 })
index 3ac5d648d2f0b0237ead152fed9613148333a3e0..1c114a5c7c8a47dcc4bb83d114b95ef7dde3cdc4 100644 (file)
@@ -52,7 +52,7 @@ function isStringOrNumberLiteral(exp) {
 }
 
 // this is called in the build script entry once
-// so the data can be shared across concurrent Rollup processes
+// so the data can be shared across concurrent Rolldown processes
 export function scanEnums() {
   /** @type {{ [file: string]: EnumDeclaration[] }} */
   const declarations = Object.create(null)
@@ -72,7 +72,6 @@ export function scanEnums() {
   ]
 
   // 2. parse matched files to collect enum info
-  let i = 0
   for (const relativeFile of files) {
     const file = path.resolve(process.cwd(), relativeFile)
     const content = readFileSync(file, 'utf-8')
@@ -234,7 +233,7 @@ export function scanEnums() {
 }
 
 /**
- * @returns {[import('rollup').Plugin, Record<string, string>]}
+ * @returns {[import('rolldown').Plugin, Record<string, string>]}
  */
 export function inlineEnums() {
   if (!existsSync(ENUM_CACHE_PATH)) {
@@ -249,7 +248,7 @@ export function inlineEnums() {
   //    3.1 files w/ enum declaration: rewrite declaration as object literal
   //    3.2 files using enum: inject into rolldown define
   /**
-   * @type {import('rollup').Plugin}
+   * @type {import('rolldown').Plugin}
    */
   const plugin = {
     name: 'inline-enum',
index 0bb2a727f31514eaa9db1b7a48e862b4f26dbb3a..be1bf35da713e2d7fb692119163c0dd5b0f13c06 100644 (file)
@@ -2,9 +2,8 @@
 import { mkdir, writeFile } from 'node:fs/promises'
 import path from 'node:path'
 import { rolldown } from 'rolldown'
-import nodeResolve from '@rollup/plugin-node-resolve'
 import { minify } from 'oxc-minify'
-import replace from '@rollup/plugin-replace'
+import { replacePlugin } from 'rolldown/experimental'
 import { brotliCompressSync, gzipSync } from 'node:zlib'
 import { parseArgs } from 'node:util'
 import pico from 'picocolors'
@@ -108,28 +107,27 @@ async function generateBundle(preset) {
           if (_id === id) return content
         },
       },
-      nodeResolve(),
-      replace({
-        'process.env.NODE_ENV': '"production"',
-        __VUE_PROD_DEVTOOLS__: 'false',
-        __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
-        __VUE_OPTIONS_API__: 'true',
-        preventAssignment: true,
-        ...preset.replace,
-      }),
+      replacePlugin(
+        {
+          'process.env.NODE_ENV': '"production"',
+          __VUE_PROD_DEVTOOLS__: 'false',
+          __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
+          __VUE_OPTIONS_API__: 'true',
+          ...preset.replace,
+        },
+        { preventAssignment: true },
+      ),
     ],
   })
 
   const generated = await result.generate({})
   const bundled = generated.output[0].code
   const file = preset.name + '.js'
-  const minified = (
-    await minify(file, bundled, {
-      mangle: {
-        toplevel: true,
-      },
-    })
-  ).code
+  const minified = minify(file, bundled, {
+    mangle: {
+      toplevel: true,
+    },
+  }).code
 
   const size = minified.length
   const gzip = gzipSync(minified).length