{"_id":"@daotl/unplugin-vue-components","_rev":"1-cfb97b449205e63b2158dc5f50c2f0a2","name":"@daotl/unplugin-vue-components","dist-tags":{"latest":"0.19.6"},"versions":{"0.19.6":{"name":"@daotl/unplugin-vue-components","version":"0.19.6","packageManager":"pnpm@7.1.5","description":"Components auto importing for Vue","homepage":"https://github.com/antfu/unplugin-vue-components","bugs":{"url":"https://github.com/antfu/unplugin-vue-components/issues"},"license":"MIT","author":{"name":"antfu","email":"anthonyfu117@hotmail.com"},"repository":{"type":"git","url":"git+https://github.com/antfu/unplugin-vue-components.git"},"funding":"https://github.com/sponsors/antfu","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs"},"./*":"./*","./nuxt":{"require":"./dist/nuxt.js","import":"./dist/nuxt.mjs"},"./resolvers":{"require":"./dist/resolvers.js","import":"./dist/resolvers.mjs"},"./rollup":{"require":"./dist/rollup.js","import":"./dist/rollup.mjs"},"./types":{"require":"./dist/types.js","import":"./dist/types.mjs"},"./vite":{"require":"./dist/vite.js","import":"./dist/vite.mjs"},"./webpack":{"require":"./dist/webpack.js","import":"./dist/webpack.mjs"},"./esbuild":{"require":"./dist/esbuild.js","import":"./dist/esbuild.mjs"}},"typesVersions":{"*":{"*":["./dist/*"]}},"scripts":{"build":"tsup && esno scripts/postbuild.ts","dev":"tsup --watch src","example:build":"npm -C examples/vite-vue3 run build","example:dev":"npm -C examples/vite-vue3 run dev","prepublishOnly":"npm run build","lint":"eslint .","release":"bumpp --commit --tag --push","test":"vitest","test:update":"vitest --u"},"peerDependencies":{"@babel/parser":"^7.15.8","@babel/traverse":"^7.15.4","vue":"2 || 3"},"peerDependenciesMeta":{"@babel/parser":{"optional":true},"@babel/traverse":{"optional":true}},"dependencies":{"@antfu/utils":"^0.5.1","@rollup/pluginutils":"^4.2.1","chokidar":"^3.5.3","debug":"^4.3.4","fast-glob":"^3.2.11","local-pkg":"^0.4.1","magic-string":"^0.26.1","minimatch":"^5.0.1","resolve":"^1.22.0","unplugin":"^0.6.3"},"devDependencies":{"@antfu/eslint-config":"^0.23.0","@babel/parser":"^7.17.10","@babel/traverse":"^7.17.10","@babel/types":"^7.17.10","@types/debug":"^4.1.7","@types/minimatch":"^3.0.5","@types/node":"^17.0.31","@types/resolve":"^1.20.2","@typescript-eslint/eslint-plugin":"^5.22.0","bumpp":"^7.1.1","compare-versions":"^4.1.3","element-plus":"^2.2.0","eslint":"^8.15.0","esno":"^0.14.1","pathe":"^0.3.0","rollup":"^2.72.1","tsup":"5.12.7","typescript":"^4.6.4","vite":"^2.9.8","vitest":"^0.12.1","vue":"3.2.33"},"engines":{"node":">=14"},"gitHead":"c68fccc7b28bd61128eed07b7562316ddec2ece1","_id":"@daotl/unplugin-vue-components@0.19.6","_nodeVersion":"16.15.0","_npmVersion":"8.5.5","dist":{"integrity":"sha512-nkTQAF9RHIj31LkOKuKsTFuL3YX3Vmi5A1Q5iIDtXRskv94qQFCcvhckW82KLWD4iEvn+KpcDkp1n2Nu0KPZew==","shasum":"9cf627c56c07624aef5e9c02ce1e9f127b08607d","tarball":"https://registry.npmjs.org/@daotl/unplugin-vue-components/-/unplugin-vue-components-0.19.6.tgz","fileCount":33,"unpackedSize":165910,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCJUWHtREhHsltzK5K/wt6tj3HNSVSAdg5L1PH7e5urwQIhAPerIDzZfMz5T1KA0aw50BQ3RJcIGdeWRN8NmTRxTdDn"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJip1hOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp1sBAAiu8GaCogAR9taS5c5HQYNbQ1UzzlltpRQL3x901GKPkjoaps\r\n0CE1OL4d4XuhTjerXWUbRuqFivQVwAN+Ln88RblEFxGlCQu/qZiTF/zFtb1n\r\nwzq7G/qkeakq2gUM/P6NcFpoJbx5iG6lWX1il3ScgTVBf2kOAj86/LVH6tQt\r\nedKQZ4TbDT/eu5XbJpDPb6CUdX9HRtaF79P3U0DHT3Qzqve/Wpf2lPnigONL\r\n4i2YEXqyhVn6NYeoHfbAmiiXYmfrrRYE/AeQBBspyPtO5fnV2ymtvov/YY8p\r\nUrr6E57nuo1h/7LfPKY2A/NScUmrPTwVOf+gBeLWtb5AO1seUGJwyawThBwB\r\nSChbOV2xwYraWUpeAsUkwN2WJnO7YiJe19/SDMzEzBSc8ArbIC9Vec3XaLO7\r\nynARSwIdcm6J1kosutVystuqDFJBczvF01AxmAyWiEfjmI0okdFDl2crbcpU\r\ndVc9jjAA5I3mVn1MvO8KEz74GvzPV8zbH07/Hbpv0B9xopNhjPAxpyC6i2nv\r\nP3QJUd9bt5uhKxOGqG7hCoCY64pU7TkMi8kqZuQI/FyR6MDhpjT22kuJ+s0n\r\ncRqRi+bLiDXb7vwb91x2QzZ0yIKGRgwIx2RLLyoBYZXBpXv9gyVr1lo30MfO\r\nwqvQP9xEaq68aawsozH8UpfX8fyYLVHYrPw=\r\n=W8+y\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"nex","email":"nexzhu@gmail.com"},"directories":{},"maintainers":[{"name":"nex","email":"nexzhu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/unplugin-vue-components_0.19.6_1655134285978_0.5522920383232921"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-13T15:31:25.913Z","0.19.6":"2022-06-13T15:31:26.283Z","modified":"2023-05-18T09:55:29.931Z"},"maintainers":[{"email":"zwjCheer@163.com","name":"zwj_cheer"},{"email":"nexzhu@gmail.com","name":"nex"}],"description":"Components auto importing for Vue","homepage":"https://github.com/antfu/unplugin-vue-components","repository":{"type":"git","url":"git+https://github.com/antfu/unplugin-vue-components.git"},"author":{"name":"antfu","email":"anthonyfu117@hotmail.com"},"bugs":{"url":"https://github.com/antfu/unplugin-vue-components/issues"},"license":"MIT","readme":"# unplugin-vue-components\n\n[![NPM version](https://img.shields.io/npm/v/unplugin-vue-components?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-vue-components)\n\nOn-demand components auto importing for Vue.\n\n###### Features\n\n- 💚 Supports both Vue 2 and Vue 3 out-of-the-box.\n- ✨ Supports both components and directives.\n- ⚡️ Supports Vite, Webpack, Vue CLI, Rollup, esbuild and more, powered by <a href=\"https://github.com/unjs/unplugin\">unplugin</a>.\n- 🏝 Tree-shakable, only registers the components you use.\n- 🪐 Folder names as namespaces.\n- 🦾 Full TypeScript support.\n- 🌈 [Built-in resolvers](#importing-from-ui-libraries) for popular UI libraries.\n- 😃 Works perfectly with [unplugin-icons](https://github.com/antfu/unplugin-icons).\n\n<br>\n\n<p align=\"center\">\n  <a href=\"https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg\">\n    <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>\n  </a>\n</p>\n\n<br>\n\n## Installation\n\n```bash\nnpm i unplugin-vue-components -D\n```\n\n> **`vite-plugin-components` has been renamed to `unplugin-vue-components`**, see the [migration guide](#migrate-from-vite-plugin-components).\n\n<details>\n<summary>Vite</summary><br>\n\n```ts\n// vite.config.ts\nimport Components from 'unplugin-vue-components/vite'\n\nexport default defineConfig({\n  plugins: [\n    Components({ /* options */ }),\n  ],\n})\n```\n\n<br></details>\n\n<details>\n<summary>Rollup</summary><br>\n\n```ts\n// rollup.config.js\nimport Components from 'unplugin-vue-components/rollup'\n\nexport default {\n  plugins: [\n    Components({ /* options */ }),\n  ],\n}\n```\n\n<br></details>\n\n\n<details>\n<summary>Webpack</summary><br>\n\n```ts\n// webpack.config.js\nmodule.exports = {\n  /* ... */\n  plugins: [\n    require('unplugin-vue-components/webpack')({ /* options */ }),\n  ],\n}\n```\n\n<br></details>\n\n<details>\n<summary>Nuxt</summary><br>\n\nYou might not need this plugin for Nuxt. Use [`@nuxt/components`](https://github.com/nuxt/components) instead.\n\n<br></details>\n\n<details>\n<summary>Vue CLI</summary><br>\n\n```ts\n// vue.config.js\nmodule.exports = {\n  configureWebpack: {\n    plugins: [\n      require('unplugin-vue-components/webpack')({ /* options */ }),\n    ],\n  },\n}\n```\n\n<br></details>\n\n<details>\n<summary>esbuild</summary><br>\n\n```ts\n// esbuild.config.js\nimport { build } from 'esbuild'\n\nbuild({\n  /* ... */\n  plugins: [\n    require('unplugin-vue-components/esbuild')({\n      /* options */\n    }),\n  ],\n})\n```\n\n<br></details>\n\n## Usage\n\nUse components in templates as you would usually do, it will import components on demand, and there is no `import` and `component registration` required anymore! If you register the parent component asynchronously (or lazy route), the auto-imported components will be code-split along with their parent.\n\nIt will automatically turn this\n\n```html\n<template>\n  <div>\n    <HelloWorld msg=\"Hello Vue 3.0 + Vite\" />\n  </div>\n</template>\n\n<script>\nexport default {\n  name: 'App'\n}\n</script>\n```\n\ninto this\n\n```html\n<template>\n  <div>\n    <HelloWorld msg=\"Hello Vue 3.0 + Vite\" />\n  </div>\n</template>\n\n<script>\nimport HelloWorld from './src/components/HelloWorld.vue'\n\nexport default {\n  name: 'App',\n  components: {\n    HelloWorld\n  }\n}\n</script>\n```\n\n## TypeScript\n\nTo get TypeScript support for auto-imported components, there is [a PR](https://github.com/vuejs/core/pull/3399) to Vue 3 extending the interface of global components. Currently, [Volar](https://github.com/johnsoncodehk/volar) has supported this usage already. If you are using Volar, you can change the config as following to get the support.\n\n```ts\nComponents({\n  dts: true, // enabled by default if `typescript` is installed\n})\n```\n\nOnce the setup is done, a `components.d.ts` will be generated and updates automatically with the type definitions. Feel free to commit it into git or not as you want.\n\n> **Make sure you also add `components.d.ts` to your `tsconfig.json` under `includes`.**\n\n## Importing from UI Libraries\n\nWe have several built-in resolvers for popular UI libraries like **Vuetify**, **Ant Design Vue**, and **Element Plus**, where you can enable them by:\n\nSupported Resolvers:\n\n- [Ant Design Vue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/antdv.ts)\n- [Arco Design Vue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/arco.ts)\n- [Element Plus](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/element-plus.ts)\n- [Element UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/element-ui.ts)\n- [Headless UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/headless-ui.ts)\n- [IDux](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/idux.ts)\n- [Inkline](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/inkline.ts)\n- [Naive UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/naive-ui.ts)\n- [Prime Vue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/prime-vue.ts)\n- [Vant](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/vant.ts)\n- [VEUI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/veui.ts)\n- [Varlet UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/varlet-ui.ts)\n- [View UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/view-ui.ts)\n- [Vuetify](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/vuetify.ts)\n- [VueUse Components](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/vueuse.ts)\n- [Quasar](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/quasar.ts)\n- [TDesign](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/tdesign.ts)\n\n```ts\n// vite.config.js\nimport Components from 'unplugin-vue-components/vite'\nimport {\n  AntDesignVueResolver,\n  ElementPlusResolver,\n  VantResolver,\n} from 'unplugin-vue-components/resolvers'\n\n// your plugin installation\nComponents({\n  resolvers: [\n    AntDesignVueResolver(),\n    ElementPlusResolver(),\n    VantResolver(),\n  ],\n})\n```\n\nYou can also write your own resolver quickly:\n\n```ts\nComponents({\n  resolvers: [\n    // example of importing Vant\n    (componentName) => {\n      // where `componentName` is always CapitalCase\n      if (componentName.startsWith('Van'))\n        return { name: componentName.slice(3), from: 'vant' }\n    },\n  ],\n})\n```\n\nIf you successfully configured other UI libraries, please feel free to contribute and help others using them out-of-box. Thanks!\n\n## Types for global registered components\n\nSome libraries might register some global components for you to use anywhere (e.g. Vue Router provides `<RouterLink>` and `<RouterView>`). Since they are global available, there is no need for this plugin to import them. However, those are commonly not TypeScript friendly, and you might need to register their types manually.\n\nThus `unplugin-vue-components` provided a way to only register types for global components.\n\n```ts\nComponents({\n  dts: true,\n  types: [{\n    from: 'vue-router',\n    names: ['RouterLink', 'RouterView'],\n  }],\n})\n```\n\nSo the `RouterLink` and `RouterView` will be presented in `components.d.ts`.\n\nBy default, `unplugin-vue-components` detects supported libraries automatically (e.g. `vue-router`) when they are installed in the workspace. If you want to disable it completely, you can pass an empty array to it:\n\n```ts\nComponents({\n  // Disable type only registration\n  types: [],\n})\n```\n\n## Migrate from `vite-plugin-components`\n\n`package.json`\n\n```diff\n{\n  \"devDependencies\": {\n-   \"vite-plugin-components\": \"*\",\n+   \"unplugin-vue-components\": \"^0.14.0\",\n  }\n}\n```\n\n`vite.config.json`\n\n```diff\n- import Components, { ElementPlusResolver } from 'vite-plugin-components'\n+ import Components from 'unplugin-vue-components/vite'\n+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'\n\nexport default {\n  plugins: [\n    /* ... */\n    Components({\n      /* ... */\n\n      // `customComponentsResolvers` has renamed to `resolver`\n-     customComponentsResolvers: [\n+     resolvers: [\n        ElementPlusResolver(),\n      ],\n\n      // `globalComponentsDeclaration` has renamed to `dts`\n-     globalComponentsDeclaration: true,\n+     dts: true,\n\n      // `customLoaderMatcher` is depreacted, use `include` instead\n-     customLoaderMatcher: id => id.endsWith('.md'),\n+     include: [/\\.vue$/, /\\.vue\\?vue/, /\\.md$/],\n    }),\n  ],\n}\n```\n\n## Configuration\n\nThe following show the default values of the configuration\n\n```ts\nComponents({\n  // relative paths to the directory to search for components.\n  dirs: ['src/components'],\n\n  // valid file extensions for components.\n  extensions: ['vue'],\n  // search for subdirectories\n  deep: true,\n  // resolvers for custom components\n  resolvers: [],\n\n  // generate `components.d.ts` global declarations,\n  // also accepts a path for custom filename\n  // default: `true` if package typescript is installed\n  dts: false,\n\n  // Allow subdirectories as namespace prefix for components.\n  directoryAsNamespace: false,\n  // Subdirectory paths for ignoring namespace prefixes\n  // works when `directoryAsNamespace: true`\n  globalNamespaces: [],\n\n  // auto import for directives\n  // default: `true` for Vue 3, `false` for Vue 2\n  // Babel is needed to do the transformation for Vue 2, it's disabled by default for performance concerns.\n  // To install Babel, run: `npm install -D @babel/parser @babel/traverse`\n  directives: true,\n\n  // Transform path before resolving\n  importPathTransform: v => v,\n\n  // Allow for components to override other components with the same name\n  allowOverrides: false,\n\n  // filters for transforming targets\n  include: [/\\.vue$/, /\\.vue\\?vue/],\n  exclude: [/[\\\\/]node_modules[\\\\/]/, /[\\\\/]\\.git[\\\\/]/, /[\\\\/]\\.nuxt[\\\\/]/],\n})\n```\n\n## Example\n\n[Vitesse](https://github.com/antfu/vitesse) starter template.\n\n## Thanks\n\nThanks to [@brattonross](https://github.com/brattonross), this project is heavily inspired by [vite-plugin-voie](https://github.com/vamplate/vite-plugin-voie).\n\n## License\n\nMIT License © 2020-PRESENT [Anthony Fu](https://github.com/antfu)\n","readmeFilename":"README.md"}