--- url: /guide/eslint-integration.md --- #
ESLint Integration ## Installation ::: code-group ```bash [pnpm] pnpm add -D @vue-macros/eslint-config ``` ```bash [yarn] yarn add -D @vue-macros/eslint-config ``` ```bash [npm] npm i -D @vue-macros/eslint-config ``` ::: ## Configuration ### Flat Configuration ```js [eslint.config.js] import vueMacros from '@vue-macros/eslint-config/flat' export default [ vueMacros, // ...your other configurations ] ``` ### Legacy Configuration ```jsonc [.eslintrc] { "extends": [ "@vue-macros/eslint-config", // ...your other configurations ], } ``` --- --- url: /guide/nuxt-integration.md --- #
Nuxt Integration ### Installation ::: code-group ```bash [npm] npm i -D @vue-macros/nuxt ``` ```bash [yarn] yarn add -D @vue-macros/nuxt ``` ```bash [pnpm] pnpm add -D @vue-macros/nuxt ``` ::: ## Configuration ```ts [nuxt.config.ts] export default { modules: [ '@vue-macros/nuxt', // ... ], macros: { // overrides config options }, } ``` --- :tada: Congratulations! That's all. To learn more about the macros, please visit [All Macros](/macros/) :laughing:. --- --- url: /guide/astro-integration.md --- # Astro Integration ### Installation ::: code-group ```bash [npm] npm i -D @vue-macros/astro ``` ```bash [yarn] yarn add -D @vue-macros/astro ``` ```bash [pnpm] pnpm add -D @vue-macros/astro ``` ::: ## Configuration ```ts [astro.config.mjs] import Vue from '@astrojs/vue' import Macros from '@vue-macros/astro' import { defineConfig } from 'astro/config' export default defineConfig({ integrations: [ Vue(), Macros({ // overrides config options }), ], }) ``` ## TypeScript Support & Volar Support See the corresponding chapter on [Bundler Integration](./bundler-integration.md#typescript-support) --- :tada: Congratulations! That's all. To learn more about the macros, please visit [All Macros](/macros/) :laughing:. --- --- url: /features/better-define.md --- # betterDefine With enabling `betterDefine`, imported types are supported in ` ``` <<< ./better-define.md#basic{ts} [types.ts] ::: ## ⚠️ Limitations ### Complex types Complex types are not supported in some key places. For example: #### What are Complex Types? - All utility types - [Built-in types](https://www.typescriptlang.org/docs/handbook/utility-types.html) - All types from `type-fest` package. - `typeof` keyword. - ... - Index Signature ```ts interface Type { [key: string]: string } ``` - Generics will be ignored directly #### What are Key Places? - The names of props. ```ts // ✅ defineProps<{ foo: ComplexType }>() // ❌ defineProps<{ [ComplexType]: string }>() ``` - The names of emits. ```ts interface Emits { (event: 'something', value: ComplexType): void // ✅ (event: ComplexType): void // ❌ } ``` --- --- url: /features/boolean-prop.md --- # booleanProp Convert `` to ``. Convert `` to ``. | Features | Supported | | :----------: | :----------------: | | Vue 3 | :white_check_mark: | | Nuxt 3 | :white_check_mark: | | Vue 2 | :x: | | Volar Plugin | :white_check_mark: | ## Options ```ts interface Options { /** * @default '!' */ negativePrefix?: string } ``` ## Usage ```vue twoslash ``` ```vue twoslash ``` ## Volar Configuration ```jsonc {3,5} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], "vueMacros": { "booleanProp": true, }, }, } ``` --- --- url: /guide/bundler-integration.md --- # Bundler Integration ## Installation ::: tip Vite and Rollup are fully supported, while other bundlers have limited support. ::: ::: code-group ```bash [npm] npm i -D vue-macros ``` ```bash [yarn] yarn add -D vue-macros ``` ```bash [pnpm] pnpm add -D vue-macros ``` ::: ::: code-group ```ts [Vite] // vite.config.ts import Vue from '@vitejs/plugin-vue' import VueMacros from 'vue-macros/vite' // import VueJsx from '@vitejs/plugin-vue-jsx' // import VueRouter from 'unplugin-vue-router/vite' export default defineConfig({ plugins: [ VueMacros({ plugins: { vue: Vue(), // vueJsx: VueJsx(), // if needed // vueRouter: VueRouter({ // if needed // extensions: ['.vue', '.setup.tsx'] // }) }, // overrides plugin options }), ], }) ``` ```ts [Rollup] // rollup.config.js (Requires Rollup 3+) import Vue from 'unplugin-vue/rollup' import VueMacros from 'vue-macros/rollup' // import VueRouter from 'unplugin-vue-router/rollup' export default { plugins: [ VueMacros({ plugins: { vue: Vue(), // vueJsx: VueJsx(), // if needed // vueRouter: VueRouter({ // if needed // extensions: ['.vue', '.setup.tsx'] // }) }, // overrides plugin options }), ], } ``` ```js [esbuild] // esbuild.config.js import { build } from 'esbuild' // import VueRouter from 'unplugin-vue-router/esbuild' build({ plugins: [ require('vue-macros/esbuild')({ plugins: { vue: require('unplugin-vue/esbuild')(), // vueJsx: VueJsx(), // if needed // vueRouter: VueRouter({ // if needed // extensions: ['.vue', '.setup.tsx'] // }) }, // overrides plugin options }), ], }) ``` ```js [Webpack] // webpack.config.js (Requires Webpack 5+) module.exports = { /* ... */ plugins: [ require('vue-macros/webpack')({ // overrides plugin options }), ], } ``` ```js [Rspack] // rspack.config.js module.exports = { /* ... */ plugins: [ require('vue-macros/rspack')({ // overrides plugin options }), ], } ``` ```js [Rsbuild] // rsbuild.config.js module.exports = { // ... tools: { rspack: { plugins: [ require('vue-macros/rspack')({ // overrides plugin options }), ], }, }, } ``` ```js [Vue CLI] // vue.config.js (Requires Vue CLI 5+) const { defineConfig } = require('@vue/cli-service') const VueMacros = require('vue-macros/webpack') module.exports = defineConfig({ // ... // ⚠️ IMPORTANT parallel: false, configureWebpack: { plugins: [ VueMacros({ // overrides plugin options }), ], }, }) ``` ::: ## Configuration See the [Configurations](./configurations.md) for more details. ```ts twoslash [vue-macros.config.ts] import { defineConfig } from 'vue-macros' export default defineConfig({ // options }) ``` ## TypeScript Support ```json {0} // tsconfig.json { "compilerOptions": { // ... "types": ["vue-macros/macros-global" /* ... */] } } ``` ## Volar Support For detailed configuration, please refer to the description of the specific macro. ```jsonc [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], }, } ``` ### Scoped Plugins `exportExpose`, `exportProps`, and `exportRender` plugins cannot be used at the same time unless providing a scope. ```ts twoslash [vue-macros.config.ts] import { defineConfig } from 'vue-macros' export default defineConfig({ exportExpose: { include: ['**/export-expose/**'], }, exportProps: { include: ['**/export-props/**'], }, exportRender: { include: ['**/export-render/**'], }, }) ``` --- :tada: Congratulations! You have successfully set up Vue Macros. To learn more about the macros, please visit [All Macros](/macros/) :laughing:. --- --- url: /macros/chain-call.md --- # chainCall Extends `defineProps`, support call `withDefaults` as a chain. | Features | Supported | | :----------: | :----------------: | | Vue 3 | :white_check_mark: | | Nuxt 3 | :question: | | Vue 2 | :question: | | TypeScript | :white_check_mark: | | Volar Plugin | :x: | ::: tip - `chainCall` does not support `definePropsRefs` - To fully support TypeScript, you need to import this macro from `vue-macros/macros`. ::: ## Basic Usage ```vue ``` ::: details Compiled Code ```vue twoslash ``` ::: Also support [props destructuring](../features/reactivity-transform.md) and JSX: ```vue ``` ## TypeScript To fully support TypeScript, you need to import this macro from `vue-macros/macros` with specific syntax. ```vue twoslash ``` Works without import assertion, but tsc will report an error: ```ts twoslash // @errors: 2339 defineProps<{ /* ... */ }>().withDefaults({ /* ... */ }) ``` --- --- url: /guide/configurations.md --- # Configurations ## Plugin Options All features are enabled by default except the following. #### Disabled by Default - `exportExpose` - `exportProps` - `exportRender` - `setupSFC` - `booleanProp` - `shortBind` - `defineStyleX` #### Disabled by Default when Vue >= 3.3 - `defineOptions` - `defineSlots` - `hoistStatic` - `shortEmits` You can re-enable them by setting the option to `true`. ```ts twoslash [vue-macros.config.(ts,js,json)] import { defineConfig } from 'vue-macros' export default defineConfig({ root: '/your-project-path', /** * Vue version, 2 or 3. * * optional, detecting automatically. */ version: 3, /** Defaults to true */ defineModels: { // ... }, // Enable features defineOptions: true, // Disable features hoistStatic: false, // ... more features }) ``` Refer to the macros and features page for available options. --- --- url: /macros/define-emit.md --- # defineEmit Declare single emit one by one using `defineEmit`. | Features | Supported | | :----------: | :----------------: | | Vue 3 | :white_check_mark: | | Nuxt 3 | :white_check_mark: | | Vue 2 | :white_check_mark: | | TypeScript | :white_check_mark: | | Volar Plugin | :white_check_mark: | ::: warning `defineEmit` can not be used with `defineEmits` at same time ::: ## API Reference ```ts defineEmit(emitName) defineEmit(emitName, validator) // emitName parameter can be optional, // and will be inferred from variable name const emitName = defineEmit() ``` ## Basic Usage ```vue twoslash ``` ## With Validation ```vue twoslash ``` ## TypeScript ```vue twoslash ``` ## Volar Configuration ```jsonc {3,5} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], "vueMacros": { "defineEmit": true, }, }, } ``` --- --- url: /volar/define-generic.md --- # defineGeneric Declare single generic one by one using `DefineGeneric`. > Especially useful for `setup-sfc`. | Features | Supported | | :----------: | :----------------: | | Volar Plugin | :white_check_mark: | ## Basic Usage ::: code-group ```vue [App.vue] twoslash ``` ::: ## Volar Configuration ```jsonc {3} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], }, } ``` --- --- url: /macros/define-models.md --- # defineModels Declaring and mutate `v-model` props as the same as normal variable using the `defineModels`. | Features | Supported | | :----------: | :----------------: | | Vue 3 | :white_check_mark: | | Nuxt 3 | :white_check_mark: | | Vue 2 | :white_check_mark: | | Volar Plugin | :white_check_mark: | ## Options ```ts VueMacros({ defineModels: { /** * Unified mode, only works for Vue 2 * * Converts `modelValue` to `value` */ unified: false, }, }) ``` ## Basic Usage Requires [`@vueuse/core`](https://www.npmjs.com/package/@vueuse/core), install it by yourself before using. ```vue twoslash ``` ::: warning ❌ Object declaring is not supported. ```vue ``` ::: ## With Model Options ```vue twoslash 3-6 ``` ## With Reactivity Transform ::: warning Assignment expression is only supported in ` ``` ::: details Compiled Code ```vue twoslash ``` ::: ## Volar Configuration ```jsonc {4,6-9} [tsconfig.json] { "vueCompilerOptions": { "target": 3, // or 2.7 for Vue 2 "plugins": ["vue-macros/volar"], "vueMacros": { "defineModels": { // Only works when target is 2.7. "unified": true, }, }, }, } ``` --- --- url: /macros/define-options.md --- # defineOptions Options API can be declared using the `defineOptions` in ` ``` ::: details Compiled Code ```vue twoslash ``` ::: ## JSX in ` ``` ::: details Compiled Code ```vue ``` ::: ## Volar Configuration ```jsonc {3} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], }, } ``` --- --- url: /macros/define-prop.md --- # defineProp Declare single prop one by one using `defineProp`. | Features | Supported | | :----------------: | :----------------: | | Vue 3 | :white_check_mark: | | Nuxt 3 | :white_check_mark: | | Vue 2 | :white_check_mark: | | TypeScript / Volar | :white_check_mark: | ::: warning `defineProp` can not be used in the same file as type-declared `defineProps`. ::: ## Configuration ```ts VueMacros({ defineProp: { /** * 'kevinEdition' | 'johnsonEdition' * @default 'kevinEdition' */ edition: 'kevinEdition', }, }) ``` ## Kevin's Edition (Default) ### API Reference ```ts defineProp(propName) defineProp(propName, options) // propName parameter can be optional, // and will be inferred from variable name const propName = defineProp() ``` ### Basic Usage ```vue twoslash ``` ### With Options ```vue twoslash ``` ### TypeScript ```vue twoslash ``` ### With Reactivity Transform ```vue twoslash ``` ## Johnson's Edition ### API Reference ```ts // the prop name will be inferred from variable name const propName = defineProp() const propName = defineProp(defaultValue) const propName = defineProp(defaultValue, required) const propName = defineProp(defaultValue, required, rest) ``` ### Basic Usage ```vue twoslash ``` ### With Options ```vue twoslash ``` ### TypeScript ```vue twoslash ``` ### With Reactivity Transform ```vue twoslash ``` ### Volar Configuration ```jsonc {3,5} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], "vueMacros": { "defineProp": true, }, // "kevinEdition" | "johnsonEdition" | false "experimentalDefinePropProposal": "kevinEdition", }, } ``` --- --- url: /macros/define-props.md --- # defineProps Correct types of destructured props using `$defineProps`. See also [Vue issue](https://github.com/vuejs/core/issues/6876), [Reactivity Transform RFC](https://github.com/vuejs/rfcs/blob/reactivity-transform/active-rfcs/0000-reactivity-transform.md#defineprops-destructure-details). | Features | Supported | | :-----------------------: | :----------------: | | Vue 3 | :white_check_mark: | | Nuxt 3 | :white_check_mark: | | Vue 2 | :white_check_mark: | | TypeScript / Volar Plugin | :white_check_mark: | ::: warning [Reactivity Transform](../features/reactivity-transform.md) is required. You should enable it first. ::: ## Basic Usage ```vue twoslash ``` ## Volar Configuration ```jsonc {3} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], }, } ``` --- --- url: /macros/define-props-refs.md --- # definePropsRefs Returns refs from `defineProps` instead of a reactive object. It can be destructured without losing reactivity. `toRefs(defineProps())` => `definePropsRefs()` | Features | Supported | | :-----------------------: | :----------------: | | Vue 3 | :white_check_mark: | | Nuxt 3 | :white_check_mark: | | Vue 2 | :white_check_mark: | | TypeScript / Volar Plugin | :white_check_mark: | ## Basic Usage ```vue twoslash {2-3,8} ``` ## With Default Value ```vue twoslash {2-3,8} ``` ## Volar Configuration ```jsonc {3} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], }, } ``` --- --- url: /macros/define-render.md --- # defineRender Defining render function in ` ``` --- --- url: /macros/define-slots.md --- # defineSlots Declaring type of SFC slots in ` ``` ### Full Syntax (Official Version) ```vue twoslash ``` ## Volar Configuration ```jsonc {3} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], }, } ``` --- --- url: /macros/define-stylex.md --- # defineStyleX Define and consume [StyleX](https://stylexjs.com/) styles in ` ``` :::details Compiled Code (with some simplifications) ```vue [App.vue] twoslash ``` ::: ## Conditional Styles Optional and multiple rules are supported. ```vue [App.vue] twoslash ``` :::details Compiled Code (with some simplifications) ```vue [App.vue] twoslash ``` ::: --- --- url: /features/export-expose.md --- # exportExpose Transform export statement as `defineExpose` params in Vue SFC `script-setup`. | Features | Supported | | :----------: | :----------------: | | Vue 3 | :white_check_mark: | | Nuxt 3 | ? | | Vue 2 | :white_check_mark: | | Volar Plugin | :white_check_mark: | ## Usage Support these syntaxes: - local variable/function/class - export with alias - export from other file - namespace export - rename export ### 1. local variable/function/class ```vue twoslash ``` ::: details Compiled Code ```vue twoslash ``` ::: ### 2. export with alias ```vue twoslash ``` ::: details Compiled Code ```vue twoslash ``` ::: ### 3. export from other file ::: code-group ```vue [App.vue] twoslash ``` <<< ./export-expose.md#export-file{ts} [types.ts] ::: ::: details Compiled Code ```vue twoslash ``` ::: ### 4. namespace export ::: code-group ```vue [App.vue] twoslash ``` ```ts [types.ts] export const foo = 'foo' ``` ::: ::: details Compiled Code ```vue twoslash ``` ::: ### 5. rename export ```vue ``` ::: details Compiled Code ```vue ``` ::: ## Limitations Currently does't support these following cases: ```ts // 1. export all ❌ export * from '../types' // 2. export default ❌ const a = 'a' export default a ``` ## Volar Configuration ```jsonc {3,5} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], "vueMacros": { "exportExpose": true, }, }, } ``` --- --- url: /features/export-props.md --- # exportProps [Svelte-like Declaring props](https://svelte.dev/docs#component-format-script-1-export-creates-a-component-prop) for Vue. | Features | Supported | | :----------: | :----------------: | | Vue 3 | :white_check_mark: | | Nuxt 3 | :question: | | Vue 2 | :white_check_mark: | | Volar Plugin | :white_check_mark: | ## Pre-requisite [Reactivity Transform](./reactivity-transform.md) is required to use this feature, but it is enabled by default in Vue Macros. `export let` will be changed to `defineModel`, which is supported in Vue 3.4+. ## Usage Using export syntax to declare props. ```vue twoslash ``` ## Volar Configuration ```jsonc {3,5} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], "vueMacros": { "exportProps": true, }, }, } ``` --- --- url: /features/export-render.md --- # exportRender Transform the default export statement, in ` ``` ## Volar Configuration ```jsonc {3,7} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], "vueMacros": { "exportRender": true, }, }, } ``` --- --- url: /guide/getting-started.md --- # Getting Started Vue Macros is a library that implements unofficial proposals and ideas for Vue, exploring and extending its features and syntax. We assume you are already familiar with the basic usages of Vue before you continue. ## Requirements - Node.js `>= v20.18.0`. - Vue `>= v2.7` or Vue `>= v3.0`. - Some features need Vue `>= v3.2.25`. - VSCode extension [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) and `vue-tsc` are v{{ version }} - Vue Macros will continue to adapt to the latest version as soon as possible, older versions may not be supported. ::: warning WebStorm is not supported. ::: ## Creating a Vue Macros Project ### Installation ::: code-group ```bash [npm] npm i -g @vue-macros/cli ``` ```bash [yarn] yarn global add @vue-macros/cli ``` ```bash [pnpm] pnpm add -g @vue-macros/cli ``` ::: This command will install [@vue-macros/cli](https://github.com/vue-macros/vue-macros-cli), the official Vue Macros scaffolding tool. ### Initialization ::: code-group ```bash [npm] npm create vite@latest my-vue-macros -- --template vue-ts cd my-vue-macros vue-macros init ``` ```bash [yarn] yarn create vite my-vue-macros --template vue-ts cd my-vue-macros vue-macros init ``` ```bash [pnpm] pnpm create vite my-vue-macros --template vue-ts cd my-vue-macros vue-macros init ``` You will be presented with prompts for several optional experimental features. ::: ## Templates - [Vite](https://github.com/vue-macros/vite) - [Nuxt](https://github.com/vue-macros/nuxt) - [Rsbuild](https://github.com/vue-macros/vue3-rsbuild) 🌟 More templates are welcome! ## Nuxt Integration If you're using [Nuxt](https://nuxt.com/), read the [Nuxt Integration](./nuxt-integration.md). ## Bundler Integrations If you're using [Vite](https://vitejs.dev/), [Rollup](https://rollupjs.org/), [esbuild](https://esbuild.github.io/), [Webpack](https://webpack.js.org/), or [Rspack](https://www.rspack.dev/), read the [Bundler Integration](./bundler-integration.md). --- --- url: /features/hoist-static.md --- # hoistStatic With enabling `hoistStatic`, constants declared in macros of ` ``` ::: details Compiled Code ```vue ``` ::: ## Magic Comments ```vue ``` ::: details Compiled Code ```vue ``` ::: --- --- url: /features/jsx-directive.md --- # jsxDirective Vue built-in directives for JSX. | Directive | Vue 3 | Vue 2 | Volar | | :---------: | :----------------: | :----------------: | :----------------: | | `v-if` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `v-else-if` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `v-else` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `v-for` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `v-on` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `v-slot` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `v-html` | :white_check_mark: | :white_check_mark: | / | | `v-once` | :white_check_mark: | :x: | / | | `v-memo` | :white_check_mark: | :x: | / | ## Options ```ts interface Options { /** * @default 'v-' */ prefix?: string /** * @default 'vue' */ lib?: 'vue' | 'react' | 'preact' | 'solid' | string } ``` ## Usage ### `v-if`, `v-else-if`, `v-else` ```vue twoslash ``` ### `v-for` ```vue twoslash ``` ### `v-slot` ::: code-group ```vue [App.vue] twoslash ``` <<< ./jsx-directive.md#v-slot{tsx} [Child.tsx] ::: ### `v-on` ::: warning `v-on` only supports binding to an object of event / listener pairs without an argument. ::: ```tsx
``` ## Dynamic Arguments It is also possible to use a variable in a directive argument by wrapping it with a pair of `$`: `v-model` ::: code-group ```vue [App.vue] twoslash ``` <<< ./jsx-directive.md#v-model{tsx} [Comp.tsx] ::: `v-slot` ::: code-group ```vue [App.vue] twoslash ``` <<< ./jsx-directive.md#v-slot-dynamic{tsx} [Comp.tsx] ::: ## Modifiers Modifiers are special postfixes denoted by a `_`, which indicate that a directive should be bound in some special way. ```tsx
``` ## Volar Configuration ```jsonc {3} [tsconfig.json] { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], }, } ``` --- --- url: /volar/jsx-ref.md --- # jsxRef Automatically infer type for `useRef`. | Features | Supported | | :------: | :----------------: | | Volar | :white_check_mark: | ## Setup Auto Import ::: code-group ```ts [vite.config.ts] import AutoImport from 'unplugin-auto-import/vite' export default defineConfig({ plugins: [ AutoImport({ imports: [ { from: 'vue', imports: [['shallowRef', 'useRef']], }, ], }), ], }) ``` ```ts [nuxt.config.ts] export default defineNuxtConfig({ imports: { presets: [ { from: 'vue', imports: [['shallowRef', 'useRef']], }, ], }, }) ``` ::: ## Basic Usage ::: code-group ```vue [App.vue] twoslash ``` <<< ./jsx-ref.md#comp{ts} [Comp.ts] ::: ## Volar Configuration ```jsonc [tsconfig.json] {3,6} { "vueCompilerOptions": { "plugins": ["vue-macros/volar"], "vueMacros": { "jsxRef": { "alias": ["useRef"], }, }, }, } ``` --- --- url: /guide/migration-v3.md --- # Migration from v2 to v3 ## Unified Version Management Initially, we used [`changesets`](https://github.com/changesets/changesets) to manage the versions of all packages in the monorepo. However, after two years of experimentation, we decided to adopt a single-version strategy in v3, where all sub-packages share the same version number, similar to Vue and Babel. This decision stemmed from our observation that when a sub-package underwent a major change or minor update, the version number of the main package did not adequately reflect these changes. For example, when `@vue-macros/define-prop` introduced a breaking change, how should `unplugin-vue-macros` release a new version? Should it be a minor or a patch release? When users updated `unplugin-vue-macros`, they couldn’t easily determine whether the update was due to changes in `@vue-macros/define-prop`. Therefore, after Anthony proposed [Epoch Semantic Versioning](https://antfu.me/posts/epoch-semver), we decided to adopt a more frequent major version update strategy, with all packages sharing the same version number and maintaining a single unified changelog. ## Main Package Rename We have renamed the main package from `unplugin-vue-macros` to **`vue-macros`**. After the official release of v3, `unplugin-vue-macros` will be marked as deprecated. As a result, you will need to update your `package.json` and the import statements for Vue Macros: ```diff // package.json { "devDependencies": { - "unplugin-vue-macros": "^2.14.5" + "vue-macros": "^3.0.0" } } ``` ```diff - import { $ref } from 'unplugin-vue-macros/macros' + import { $ref } from 'vue-macros/macros' - import VueMacros from 'unplugin-vue-macros/vite' + import VueMacros from 'vue-macros/vite' ``` ## Dropping Vue 2 Support Vue 2 reached its end of life (EOL) at the end of 2023, so we have decided to drop support for Vue 2 in v3. If you are still using Vue 2, we recommend continuing with v2 or considering our [paid support plan](https://github.com/vue-macros/vue-macros/issues/373). ## Node.js Compatibility Changes In v3, we have dropped support for Node.js versions below 20.18. This means the minimum Node.js version requirement for v3 is `20.18.0`. Additionally, we have removed CommonJS (CJS) outputs and now only provide ECMAScript modules (ESM). ## Dropping Webpack 4 Support Since Webpack 4 cannot run in Node.js 18 or later environments, we have also dropped support for Webpack 4 and Vue CLI 4. We recommend upgrading to modern build tools like Vite or Rspack. --- --- url: /features/named-template.md --- # namedTemplate ::: warning Not actively maintained now. Try [createReusableTemplate](https://vueuse.org/core/createReusableTemplate/) instead. ::: With enabling `namedTemplate`, `