Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,21 @@ Supported Resolvers:
- [Ant Design Vue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/antdv.ts)
- [Arco Design Vue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/arco.ts)
- [BootstrapVue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/bootstrap-vue.ts)
- [BootstrapVueNext](https://bootstrap-vue-next.github.io/bootstrap-vue-next/docs)
- [Element Plus](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/element-plus.ts)
- [Headless UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/headless-ui.ts)
- [IDux](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/idux.ts)
- [Inkline](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/inkline.ts)
- [Ionic](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/ionic.ts)
- [Layui Vue](https://www.layui-vue.com/zh-CN/guide/getStarted)
- [Naive UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/naive-ui.ts)
- [Prime Vue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/prime-vue.ts)
- [Prime Vue](https://primevue.dev/autoimport/)
- [Quasar](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/quasar.ts)
- [TDesign](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/tdesign.ts)
- [TDesign](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/auto-import-resolver/README.md)
- [`@tdesign-vue-next/auto-import-resolver`](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/auto-import-resolver/README.md) - TDesign's own auto-import resolver
- [Vant](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/vant.ts)
- [Vant](https://github.com/youzan/vant/blob/main/packages/vant-auto-import-resolver/README.md)
- [`@vant/auto-import-resolver`](https://github.com/youzan/vant/blob/main/packages/vant-auto-import-resolver/README.md) - Vant's own auto-import resolver
- [Varlet UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/varlet-ui.ts)
- [Varlet UI](https://github.com/varletjs/varlet/blob/dev/packages/varlet-import-resolver/README.md)
- [`@varlet/import-resolver`](https://github.com/varletjs/varlet/blob/dev/packages/varlet-import-resolver/README.md) - Varlet's own auto-import resolver
- [VEUI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/veui.ts)
- [View UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/view-ui.ts)
Expand Down
3 changes: 3 additions & 0 deletions src/core/resolvers/bootstrap-vue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ComponentResolver } from '../../types'
import { warnOnce } from '../utils'

export interface BootstrapVueResolverOptions {
/**
Expand Down Expand Up @@ -94,6 +95,8 @@ export function BootstrapVueResolver(_options: BootstrapVueResolverOptions = {})
* @deprecated use `import { BootstrapVueNextResolver } from 'bootstrap-vue-next'` instead
*/
export function BootstrapVueNextResolver(_options: BootstrapVueResolverOptions = {}): Array<ComponentResolver> {
warnOnce('BootstrapVueNextResolver is deprecated. Use `import { BootstrapVueNextResolver } from \'bootstrap-vue-next\'` instead.')

const options = { directives: true, ..._options }
const resolvers: Array<ComponentResolver> = [{
type: 'component',
Expand Down
5 changes: 4 additions & 1 deletion src/core/resolvers/layui-vue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FilterPattern } from 'unplugin-utils'
import type { ComponentInfo, ComponentResolver, SideEffectsInfo } from '../../types'
import { isExclude } from '../utils'
import { isExclude, warnOnce } from '../utils'

const matchComponents = [
{
Expand Down Expand Up @@ -159,10 +159,13 @@ function resolveComponent(importName: string, options: LayuiVueResolverOptions):
*
* @link http://www.layui-vue.com/ for layui-vue
*
* @deprecated use `import { LayuiVueResolver } from '@layui/unplugin-vue-components/resolvers'` instead
*/
export function LayuiVueResolver(
options: LayuiVueResolverOptions = {},
): ComponentResolver {
warnOnce('LayuiVueResolver is deprecated. Use `import { LayuiVueResolver } from \'@layui/unplugin-vue-components/resolvers\'` instead.')

return {
type: 'component',
resolve: (name: string) => {
Expand Down
5 changes: 5 additions & 0 deletions src/core/resolvers/prime-vue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ComponentResolver, SideEffectsInfo } from '../../types'
import { warnOnce } from '../utils'

// @keep-sorted
const components = [
Expand Down Expand Up @@ -143,8 +144,12 @@ export interface PrimeVueResolverOptions {
* Resolver for PrimeVue - If you're using a component with the same tag as an native HTML element (e.g. button) the component must be in uppercase
*
* @link https://github.com/primefaces/primevue
*
* @deprecated use `import { PrimeVueResolver } from '@primevue/auto-import-resolver'` instead
*/
export function PrimeVueResolver(options: PrimeVueResolverOptions = {}): ComponentResolver {
warnOnce('PrimeVueResolver is deprecated. Use `import { PrimeVueResolver } from \'@primevue/auto-import-resolver\'` instead.')

return {
type: 'component',
resolve: (name: string) => {
Expand Down
11 changes: 10 additions & 1 deletion src/core/resolvers/tdesign.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FilterPattern } from 'unplugin-utils'
import type { ComponentResolver } from '../../types'
import { isExclude } from '../utils'
import { isExclude, warnOnce } from '../utils'

export interface TDesignResolverOptions {
/**
Expand Down Expand Up @@ -28,7 +28,16 @@ export interface TDesignResolverOptions {
exclude?: FilterPattern
}

/**
* Resolver for TDesign
*
* @link https://github.com/Tencent/tdesign-vue-next
*
* @deprecated use `import { TDesignResolver } from '@tdesign-vue-next/auto-import-resolver'` instead
*/
export function TDesignResolver(options: TDesignResolverOptions = {}): ComponentResolver {
warnOnce('TDesignResolver is deprecated. Use `import { TDesignResolver } from \'@tdesign-vue-next/auto-import-resolver\'` instead.')

const pluginList = ['DialogPlugin', 'LoadingPlugin', 'MessagePlugin', 'NotifyPlugin']
return {
type: 'component',
Expand Down
6 changes: 5 additions & 1 deletion src/core/resolvers/vant.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ComponentResolver, SideEffectsInfo } from '../../types'
import { isSSR, kebabCase } from '../utils'
import { isSSR, kebabCase, warnOnce } from '../utils'

const moduleType = isSSR ? 'lib' : 'es'

Expand Down Expand Up @@ -31,8 +31,12 @@ function getSideEffects(dirName: string, options: VantResolverOptions): SideEffe
* Resolver for Vant
*
* @link https://github.com/youzan/vant
*
* @deprecated use `import { VantResolver } from '@vant/auto-import-resolver'` instead
*/
export function VantResolver(options: VantResolverOptions = {}): ComponentResolver {
warnOnce('VantResolver is deprecated. Use `import { VantResolver } from \'@vant/auto-import-resolver\'` instead.')

return {
type: 'component',
resolve: (name: string) => {
Expand Down
6 changes: 5 additions & 1 deletion src/core/resolvers/varlet-ui.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ComponentResolver, ComponentResolveResult } from '../../types'
import { kebabCase } from '../utils'
import { kebabCase, warnOnce } from '../utils'

export interface VarletUIResolverOptions {
/**
Expand Down Expand Up @@ -74,8 +74,12 @@ export function getResolved(name: string, options: VarletUIResolverOptions): Com
* Resolver for VarletUI
*
* @link https://github.com/varletjs/varlet
*
* @deprecated use `import { VarletImportResolver } from '@varlet/import-resolver'` instead
*/
export function VarletUIResolver(options: VarletUIResolverOptions = {}): ComponentResolver[] {
warnOnce('VarletUIResolver is deprecated. Use `import { VarletImportResolver } from \'@varlet/import-resolver\'` instead.')

return [
{
type: 'component',
Expand Down
10 changes: 10 additions & 0 deletions src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ import { DISABLE_COMMENT } from './constants'

export const isSSR = Boolean(process.env.SSR || process.env.SSG || process.env.VITE_SSR || process.env.VITE_SSG)

const warnedMessages = new Set<string>()

export function warnOnce(message: string): void {
if (warnedMessages.has(message))
return

warnedMessages.add(message)
console.warn(`[unplugin-vue-components] ${message}`)
}

export interface ResolveComponent {
filename: string
namespace?: string
Expand Down
Loading