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)
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
- **`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:
### `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`
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
groupName: 'build',
matchPackageNames: [
'vite',
- '@swc/core',
- 'rollup{/,}**',
- 'esbuild{/,}**',
- '@rollup{/,}**',
+ 'rolldown{/,}**',
+ '@rolldown{/,}**',
+ 'oxc{/,}**',
'@vitejs{/,}**',
],
},
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 || ''))
* 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__ */
- **`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`)
// @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'
})
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'
})
}
output.externalLiveBindings = false
- // https://github.com/rollup/rollup/pull/5380
// @ts-expect-error Not supported yet
output.reexportProtoFromExternal = false
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)
}
if (Object.keys(replacements).length) {
- return [replacePlugin(replacements)]
+ return [
+ replacePlugin(replacements, {
+ preventAssignment: true,
+ }),
+ ]
} else {
return []
}
}
},
treeshake: {
- // https://github.com/rolldown/rolldown/issues/1917
moduleSideEffects: false,
},
}
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`)
+ }
})
}
// 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)
]
// 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')
}
/**
- * @returns {[import('rollup').Plugin, Record<string, string>]}
+ * @returns {[import('rolldown').Plugin, Record<string, string>]}
*/
export function inlineEnums() {
if (!existsSync(ENUM_CACHE_PATH)) {
// 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',
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'
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