Ver código fonte

build: use rolldown (#13599)

edison 4 meses atrás
pai
commit
2a6ececaaa

+ 5 - 6
.github/contributing.md

@@ -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

+ 3 - 4
.github/renovate.json5

@@ -28,10 +28,9 @@
       groupName: 'build',
       matchPackageNames: [
         'vite',
-        '@swc/core',
-        'rollup{/,}**',
-        'esbuild{/,}**',
-        '@rollup{/,}**',
+        'rolldown{/,}**',
+        '@rolldown{/,}**',
+        'oxc{/,}**',
         '@vitejs{/,}**',
       ],
     },

+ 6 - 5
package.json

@@ -8,7 +8,7 @@
     "build": "node scripts/build.js",
     "build-rollup": "node scripts/build-with-rollup.js",
     "build-dts": "node scripts/build-types.js",
-    "build-dts-tsc": "tsc -p tsconfig.build.json --noCheck && rollup -c rollup.dts.config.js",
+    "build-dts-tsc": "tsc -p tsconfig.build.json --noCheck && rolldown -c rolldown.dts.config.js",
     "clean": "rimraf --glob packages/*/dist temp .eslintcache",
     "size": "run-s \"size-*\" && node scripts/usage-size.js",
     "size-global": "node scripts/build.js vue runtime-dom -f global -p --size",
@@ -94,19 +94,20 @@
     "markdown-table": "^3.0.4",
     "marked": "13.0.3",
     "npm-run-all2": "^7.0.1",
-    "oxc-parser": "^0.35.0",
-    "oxc-transform": "^0.35.0",
+    "oxc-parser": "^0.105.0",
+    "oxc-transform": "^0.105.0",
+    "oxc-minify": "^0.105.0",
     "picocolors": "^1.1.1",
     "prettier": "^3.3.3",
     "pretty-bytes": "^6.1.1",
     "pug": "^3.0.3",
     "puppeteer": "~23.3.0",
     "rimraf": "^6.0.1",
-    "rolldown": "0.14.0-snapshot-d5e797b-20241114003621",
+    "rolldown": "^1.0.0-beta.57",
     "rollup": "^4.25.0",
-    "rollup-plugin-dts": "^6.1.1",
     "rollup-plugin-esbuild": "^6.1.1",
     "rollup-plugin-polyfill-node": "^0.13.0",
+    "rolldown-plugin-dts": "^0.19.2",
     "semver": "^7.6.3",
     "serve": "^14.2.4",
     "serve-handler": "^6.1.6",

+ 1 - 1
packages/compiler-sfc/src/template/transformAssetUrl.ts

@@ -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 || ''))

+ 1 - 1
packages/shared/src/makeMap.ts

@@ -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__ */

+ 1 - 1
packages/vue/README.md

@@ -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`)

Diferenças do arquivo suprimidas por serem muito extensas
+ 474 - 124
pnpm-lock.yaml


+ 24 - 8
rollup.dts.config.js → rolldown.dts.config.js

@@ -3,7 +3,10 @@ import assert from 'node:assert/strict'
 import { parseSync } from 'oxc-parser'
 import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'
 import MagicString from 'magic-string'
-import dts from 'rollup-plugin-dts'
+import { dts } from 'rolldown-plugin-dts'
+import { createRequire } from 'node:module'
+import { fileURLToPath } from 'node:url'
+import path from 'node:path'
 
 if (!existsSync('temp/packages')) {
   console.warn(
@@ -12,14 +15,27 @@ if (!existsSync('temp/packages')) {
   process.exit(1)
 }
 
+const require = createRequire(import.meta.url)
+const __dirname = fileURLToPath(new URL('.', import.meta.url))
+const packagesDir = path.resolve(__dirname, 'packages')
+
 const packages = readdirSync('temp/packages')
 const targets = process.env.TARGETS ? process.env.TARGETS.split(',') : null
 const targetPackages = targets
   ? packages.filter(pkg => targets.includes(pkg))
   : packages
 
+function resolveExternal(/**@type {string}*/ packageName) {
+  const pkg = require(`${packagesDir}/${packageName}/package.json`)
+  return [
+    ...Object.keys(pkg.dependencies || {}),
+    ...Object.keys(pkg.devDependencies || {}),
+    ...Object.keys(pkg.peerDependencies || {}),
+  ]
+}
+
 export default targetPackages.map(
-  /** @returns {import('rollup').RollupOptions} */
+  /** @returns {import('rolldown').BuildOptions} */
   pkg => {
     return {
       input: `./temp/packages/${pkg}/src/index.d.ts`,
@@ -27,9 +43,10 @@ export default targetPackages.map(
         file: `packages/${pkg}/dist/${pkg}.d.ts`,
         format: 'es',
       },
+      external: resolveExternal(pkg),
       plugins: [dts(), patchTypes(pkg), ...(pkg === 'vue' ? [copyMts()] : [])],
       onwarn(warning, warn) {
-        // during dts rollup, everything is externalized by default
+        // during dts rolldown, everything is externalized by default
         if (
           warning.code === 'UNRESOLVED_IMPORT' &&
           !warning.exporter?.startsWith('.')
@@ -43,7 +60,7 @@ export default targetPackages.map(
 )
 
 /**
- * Patch the dts generated by rollup-plugin-dts
+ * Patch the dts generated by rolldown-plugin-dts
  * 1. Convert all types to inline exports
  *    and remove them from the big export {} declaration
  *    otherwise it gets weird in vitepress `defineComponent` call with
@@ -51,15 +68,14 @@ export default targetPackages.map(
  * 2. Append custom augmentations (jsx, macros)
  *
  * @param {string} pkg
- * @returns {import('rollup').Plugin}
+ * @returns {import('rolldown').Plugin}
  */
 function patchTypes(pkg) {
   return {
     name: 'patch-types',
     renderChunk(code, chunk) {
       const s = new MagicString(code)
-      const { program: ast, errors } = parseSync(code, {
-        sourceFilename: 'x.d.ts',
+      const { program: ast, errors } = parseSync('x.d.ts', code, {
         sourceType: 'module',
       })
 
@@ -201,7 +217,7 @@ function patchTypes(pkg) {
  * two separate declaration files, so we need to copy vue.d.ts to vue.d.mts
  * upon build.
  *
- * @returns {import('rollup').Plugin}
+ * @returns {import('rolldown').Plugin}
  */
 function copyMts() {
   return {

+ 1 - 1
scripts/aliases.js

@@ -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'

+ 8 - 11
scripts/build-types.js

@@ -2,7 +2,7 @@ import fs from 'node:fs'
 import path from 'node:path'
 import glob from 'fast-glob'
 import { isolatedDeclaration } from 'oxc-transform'
-import { rollup } from 'rollup'
+import { rolldown } from 'rolldown'
 import picocolors from 'picocolors'
 
 if (fs.existsSync('temp/packages')) {
@@ -17,16 +17,13 @@ for (const file of await glob('packages/*/src/**/*.ts')) {
   if (file.includes('runtime-test')) continue
 
   const ts = fs.readFileSync(file, 'utf-8')
-  const dts = isolatedDeclaration(file, ts, {
+  const dts = await isolatedDeclaration(file, ts, {
     sourcemap: false,
     stripInternal: true,
   })
   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'
     })
   }
@@ -43,16 +40,16 @@ if (errs) {
   write(path.join('temp', 'oxc-iso-decl-errors.txt'), errs)
 }
 
-console.log('bundling dts with rollup-plugin-dts...')
+console.log('bundling dts with rolldown-plugin-dts...')
 
-// bundle with rollup-plugin-dts
-const rollupConfigs = (await import('../rollup.dts.config.js')).default
+// bundle with rolldown-plugin-dts
+const rolldownConfigs = (await import('../rolldown.dts.config.js')).default
 
 start = performance.now()
 
 await Promise.all(
-  rollupConfigs.map(c =>
-    rollup(c).then(bundle => {
+  rolldownConfigs.map(c =>
+    rolldown(c).then(bundle => {
       return bundle.write(c.output).then(() => {
         console.log(picocolors.gray('built: ') + picocolors.blue(c.output.file))
       })

+ 10 - 6
scripts/build.js

@@ -119,18 +119,22 @@ async function buildAll(targets) {
     if (configs) {
       all.push(
         Promise.all(
-          configs.map(c =>
-            rolldown(c).then(bundle => {
+          configs.map(c => {
+            return rolldown(c).then(bundle => {
+              // @ts-expect-error
               return bundle.write(c.output).then(() => {
                 // @ts-expect-error
-                return path.join('packages', t, 'dist', c.output.file)
+                return c.output.file
               })
-            }),
-          ),
+            })
+          }),
         ).then(files => {
+          const from = process.cwd()
           files.forEach(f => {
             count++
-            console.log(pico.gray('built: ') + pico.green(f))
+            console.log(
+              pico.gray('built: ') + pico.green(path.relative(from, f)),
+            )
           })
         }),
       )

+ 26 - 48
scripts/create-rolldown-config.js

@@ -3,12 +3,11 @@ import assert from 'node:assert/strict'
 import { createRequire } from 'node:module'
 import { fileURLToPath } from 'node:url'
 import path from 'node:path'
-import { replacePlugin } from 'rolldown/experimental'
+import { replacePlugin } from 'rolldown/plugins'
 import pico from 'picocolors'
 import polyfillNode from '@rolldown/plugin-node-polyfills'
 import { entries } from './aliases.js'
 import { inlineEnums } from './inline-enums.js'
-import { minify as minifySwc } from '@swc/core'
 
 const require = createRequire(import.meta.url)
 const __dirname = fileURLToPath(new URL('.', import.meta.url))
@@ -59,39 +58,40 @@ export function createConfigsForPackage({
   /** @type {Record<PackageFormat, import('rolldown').OutputOptions>} */
   const outputConfigs = {
     'esm-bundler': {
-      file: `${name}.esm-bundler.js`,
+      file: resolve(`dist/${name}.esm-bundler.js`),
       format: 'es',
     },
     'esm-browser': {
-      file: `${name}.esm-browser.js`,
+      file: resolve(`dist/${name}.esm-browser.js`),
       format: 'es',
     },
     cjs: {
-      file: `${name}.cjs.js`,
+      file: resolve(`dist/${name}.cjs.js`),
       format: 'cjs',
     },
     global: {
-      file: `${name}.global.js`,
+      file: resolve(`dist/${name}.global.js`),
       format: 'iife',
     },
     // runtime-only builds, for main "vue" package only
     'esm-bundler-runtime': {
-      file: `${name}.runtime.esm-bundler.js`,
+      file: resolve(`dist/${name}.runtime.esm-bundler.js`),
       format: 'es',
     },
     'esm-browser-runtime': {
-      file: `${name}.runtime.esm-browser.js`,
+      file: resolve(`dist/${name}.runtime.esm-browser.js`),
       format: 'es',
     },
     'global-runtime': {
-      file: `${name}.runtime.global.js`,
+      file: resolve(`dist/${name}.runtime.global.js`),
       format: 'iife',
     },
   }
 
   const resolvedFormats = (
     formats ||
-    packageOptions.formats || ['esm-bundler', 'cjs']
+    /** @type {PackageFormat[]} */
+    (packageOptions.formats || ['esm-bundler', 'cjs'])
   ).filter(format => outputConfigs[format])
 
   const packageConfigs = prodOnly
@@ -125,8 +125,6 @@ export function createConfigsForPackage({
       process.exit(1)
     }
 
-    output.dir = resolve('dist')
-
     const isProductionBuild = /\.prod\.js$/.test(String(output.file) || '')
     const isBundlerESMBuild = /esm-bundler/.test(format)
     const isBrowserESMBuild = /esm-browser/.test(format)
@@ -149,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
 
@@ -160,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)
@@ -242,7 +239,11 @@ export function createConfigsForPackage({
       }
 
       if (Object.keys(replacements).length) {
-        return [replacePlugin(replacements)]
+        return [
+          replacePlugin(replacements, {
+            preventAssignment: true,
+          }),
+        ]
       } else {
         return []
       }
@@ -258,6 +259,7 @@ export function createConfigsForPackage({
 
       // we are bundling forked consolidate.js in compiler-sfc which dynamically
       // requires a ton of template engines which should be ignored.
+      /** @type {string[]} */
       let cjsIgnores = []
       if (
         pkg.name === '@vue/compiler-sfc' ||
@@ -312,12 +314,13 @@ export function createConfigsForPackage({
       // Global and Browser ESM builds inlines everything so that they can be
       // used alone.
       external: resolveExternal(),
-      define: resolveDefine(),
+      transform: {
+        define: resolveDefine(),
+      },
       platform: format === 'cjs' ? 'node' : 'browser',
       resolve: {
         alias: entries,
       },
-      // @ts-expect-error rollup's Plugin type incompatible w/ rolldown's vendored Plugin type
       plugins: [
         ...(localDev ? [] : [enumPlugin]),
         ...resolveReplace(),
@@ -331,7 +334,6 @@ export function createConfigsForPackage({
         }
       },
       treeshake: {
-        // https://github.com/rolldown/rolldown/issues/1917
         moduleSideEffects: false,
       },
     }
@@ -339,41 +341,17 @@ export function createConfigsForPackage({
 
   function createProductionConfig(/** @type {PackageFormat} */ format) {
     return createConfig(format, {
-      file: `${name}.${format}.prod.js`,
+      file: resolve(`dist/${name}.${format}.prod.js`),
       format: outputConfigs[format].format,
     })
   }
 
   function createMinifiedConfig(/** @type {PackageFormat} */ format) {
-    return createConfig(
-      format,
-      {
-        file: String(outputConfigs[format].file).replace(/\.js$/, '.prod.js'),
-        format: outputConfigs[format].format,
-        // minify: true,
-      },
-      [
-        {
-          name: 'swc-minify',
-          async renderChunk(contents, _, { format }) {
-            const { code } = await minifySwc(contents, {
-              module: format === 'es',
-              format: {
-                comments: false,
-              },
-              compress: {
-                ecma: 2016,
-                pure_getters: true,
-              },
-              safari10: true,
-              mangle: true,
-            })
-            // swc removes banner
-            return { code: banner + code, map: null }
-          },
-        },
-      ],
-    )
+    return createConfig(format, {
+      file: String(outputConfigs[format].file).replace(/\.js$/, '.prod.js'),
+      format: outputConfigs[format].format,
+      minify: true,
+    })
   }
 
   return packageConfigs

+ 5 - 7
scripts/dev.js

@@ -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`)
+  }
 })

+ 29 - 23
scripts/inline-enums.js

@@ -40,8 +40,19 @@ function evaluate(exp) {
   return new Function(`return ${exp}`)()
 }
 
+/**
+ * @param {import('oxc-parser').Expression | import('oxc-parser').PrivateIdentifier} exp
+ * @returns { exp is import('oxc-parser').StringLiteral | import('oxc-parser').NumericLiteral }
+ */
+function isStringOrNumberLiteral(exp) {
+  return (
+    exp.type === 'Literal' &&
+    (typeof exp.value === 'string' || typeof exp.value === 'number')
+  )
+}
+
 // 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)
@@ -61,13 +72,10 @@ 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')
-    const res = parseSync(content, {
-      // plugins: ['typescript'],
-      sourceFilename: file,
+    const res = parseSync(file, content, {
       sourceType: 'module',
     })
 
@@ -99,9 +107,16 @@ export function scanEnums() {
         /** @type {Array<EnumMember>} */
         const members = []
 
-        for (let i = 0; i < decl.members.length; i++) {
-          const e = decl.members[i]
-          const key = e.id.type === 'Identifier' ? e.id.name : e.id.value
+        for (let i = 0; i < decl.body.members.length; i++) {
+          const e = decl.body.members[i]
+          const key =
+            e.id.type === 'Identifier'
+              ? e.id.name
+              : e.id.type === 'Literal'
+                ? e.id.value
+                : ''
+          if (key === '') continue
+
           const fullKey = /** @type {const} */ (`${id}.${key}`)
           const saveValue = (/** @type {string | number} */ value) => {
             // We need allow same name enum in different file.
@@ -120,23 +135,17 @@ export function scanEnums() {
           if (init) {
             /** @type {string | number} */
             let value
-            if (
-              init.type === 'StringLiteral' ||
-              init.type === 'NumericLiteral'
-            ) {
+            if (isStringOrNumberLiteral(init)) {
               value = init.value
             }
             // e.g. 1 << 2
             else if (init.type === 'BinaryExpression') {
               const resolveValue = (
-                /** @type {import('@babel/types').Expression | import('@babel/types').PrivateName} */ node,
+                /** @type {import('oxc-parser').Expression | import('oxc-parser').PrivateIdentifier} */ node,
               ) => {
                 assert.ok(typeof node.start === 'number')
                 assert.ok(typeof node.end === 'number')
-                if (
-                  node.type === 'NumericLiteral' ||
-                  node.type === 'StringLiteral'
-                ) {
+                if (isStringOrNumberLiteral(node)) {
                   return node.value
                 } else if (
                   node.type === 'MemberExpression' ||
@@ -163,10 +172,7 @@ export function scanEnums() {
               }${resolveValue(init.right)}`
               value = evaluate(exp)
             } else if (init.type === 'UnaryExpression') {
-              if (
-                init.argument.type === 'StringLiteral' ||
-                init.argument.type === 'NumericLiteral'
-              ) {
+              if (isStringOrNumberLiteral(init.argument)) {
                 const exp = `${init.operator}${init.argument.value}`
                 value = evaluate(exp)
               } else {
@@ -227,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)) {
@@ -242,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',

+ 20 - 20
scripts/usage-size.js

@@ -1,10 +1,9 @@
 // @ts-check
 import { mkdir, writeFile } from 'node:fs/promises'
 import path from 'node:path'
-import { rollup } from 'rollup'
-import nodeResolve from '@rollup/plugin-node-resolve'
-import { minify } from '@swc/core'
-import replace from '@rollup/plugin-replace'
+import { rolldown } from 'rolldown'
+import { minify } from 'oxc-minify'
+import { replacePlugin } from 'rolldown/experimental'
 import { brotliCompressSync, gzipSync } from 'node:zlib'
 import { parseArgs } from 'node:util'
 import pico from 'picocolors'
@@ -95,7 +94,7 @@ async function generateBundle(preset) {
   const id = 'virtual:entry'
   const content = `export { ${preset.imports.join(', ')} } from '${entry}'`
 
-  const result = await rollup({
+  const result = await rolldown({
     input: id,
     plugins: [
       {
@@ -108,33 +107,34 @@ 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 minified = (
-    await minify(bundled, {
-      module: true,
+  const file = preset.name + '.js'
+  const minified = minify(file, bundled, {
+    mangle: {
       toplevel: true,
-    })
-  ).code
+    },
+  }).code
 
   const size = minified.length
   const gzip = gzipSync(minified).length
   const brotli = brotliCompressSync(minified).length
 
   if (write) {
-    await writeFile(path.resolve(sizeDir, preset.name + '.js'), bundled)
+    await writeFile(path.resolve(sizeDir, file), bundled)
   }
 
   return {

+ 2 - 1
tsconfig.json

@@ -36,7 +36,8 @@
     "packages/vue/jsx-runtime",
     "packages/runtime-dom/types/jsx.d.ts",
     "scripts/*",
-    "rollup.*.js"
+    "rollup.*.js",
+    "rolldown.dts.config.js"
   ],
   "exclude": ["packages-private/sfc-playground/src/vue-dev-proxy*"]
 }

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff