# @varlet/import-resolver

> varlet import resolver for unplugin-vue-components and unplugin-auto-import

Latest version **3.20.12** (published 2026-11-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @varlet/import-resolver
pnpm add @varlet/import-resolver
yarn add @varlet/import-resolver
bun add @varlet/import-resolver
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.20.12 |
| Published | 2026-11-22 |
| First published | 2024-02-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5345 |
| Author | haoziqaq |
| Maintainers | haozijunqaq, beadre, clencat, binbinji, wegi8 |
| Keywords | varlet, resolver, import, unplugin-vue-components, unplugin-auto-import |

## Links

- npm: https://www.npmjs.com/package/@varlet/import-resolver
- Repository: https://github.com/varletjs/varlet
- Homepage: https://github.com/varletjs/varlet#readme
- Issues: https://github.com/varletjs/varlet/issues
- npm.io page: https://npm.io/package/@varlet/import-resolver

## Dependencies (1)

- [@varlet/shared](https://npm.io/package/@varlet/shared.md) 3.20.12

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 3.20.12 (latest) — 2026-11-22
- 3.18.0-alpha.1781276267923 (alpha) — 2026-06-12
- 3.20.11 — 2026-11-13
- 3.20.10 — 2026-11-08
- 3.20.9 — 2026-10-29
- 3.20.8 — 2026-10-25
- 3.20.7 — 2026-10-14
- 3.20.6 — 2026-08-19
- 3.20.5 — 2026-08-19
- 3.20.4 — 2026-08-18
- 3.20.3 — 2026-08-12
- 3.20.2 — 2026-07-31
- 3.20.1 — 2026-07-29
- 3.20.0 — 2026-07-28
- 3.19.3 — 2026-07-07
- … 194 more at https://npm.io/package/@varlet/import-resolver/versions

## README

# Varlet Auto Import Resolver

English | [简体中文](./README.zh-CN.md)

`@varlet/import-resolver` is a resolver for [unplugin-vue-components](https://github.com/unplugin/unplugin-vue-components) that enables on-demand importing of Varlet components.

## Features

- Supports `Vite`, `Webpack`, `Vue CLI`, `Rollup`, `esbuild`, and more.
- Automatically imports the corresponding CSS styles for the components.
- Supports SSR (Server-Side Rendering).

## Automatic Import

via plugin
[unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) and
[unplugin-auto-import](https://github.com/antfu/unplugin-auto-import)
Implement components to automatically import on demand, This is our most recommended way.

### Install Plugin

```shell
# npm
npm i @varlet/import-resolver unplugin-vue-components unplugin-auto-import -D

# yarn
yarn add @varlet/import-resolver unplugin-vue-components unplugin-auto-import -D

# pnpm
pnpm add @varlet/import-resolver unplugin-vue-components unplugin-auto-import -D
```

### Vite

```js
// vite.config.js
import vue from '@vitejs/plugin-vue'
import components from 'unplugin-vue-components/vite'
import autoImport from 'unplugin-auto-import/vite'
import { VarletImportResolver } from '@varlet/import-resolver'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    vue(),
    components({
      resolvers: [VarletImportResolver()]
    }),
    autoImport({
      resolvers: [VarletImportResolver({ autoImport: true })]
    })
  ]
})
```

### Vue CLI

```js
// vue.config.js
const Components = require('unplugin-vue-components/webpack')
const AutoImport = require('unplugin-auto-import/webpack')
const { VarletImportResolver } = require('@varlet/import-resolver')

module.exports = {
  configureWebpack: {
    plugins: [
      Components.default({
        resolvers: [VarletImportResolver()]
      }),
      AutoImport.default({
        resolvers: [VarletImportResolver({ autoImport: true })]
      })
    ]
  }
}
```

### Typescript configuration note

In order to get good IDE syntax highlighting,
please make sure that the type declaration files generated by the above two plugins are include by `typescript`,
which can be configured as follows in `tsconfig.json`:

```json
{
  "include": ["auto-imports.d.ts", "components.d.ts"]
}
```

### Manual import

Each component is a `Vue plugin` and consists of `component logic` and `style files`, which are manually imported and used as follows.

```js
import App from './App.vue'
import { createApp } from 'vue'
import { Button } from '@varlet/ui'
import '@varlet/ui/es/button/style/index'

createApp(App).use(Button)
```

OR

```html
<script setup>
import { Button as VarButton } from '@varlet/ui'
import '@varlet/ui/es/button/style/index'
</script>

<template>
  <var-button>Say Hello</var-button>
</template>
```

### Manual import and automatic import comparison

#### Comparison-Manual import

```html
<script setup>
import { Button as VarButton, Snackbar } from '@varlet/ui'
import '@varlet/ui/es/button/style/index'
import '@varlet/ui/es/snackbar/style/index'

function handleClick() {
  Snackbar('Hello!')
}
</script>

<template>
  <var-button @click="handleClick">Say Hello</var-button>
</template>
```

#### Comparison-Automatic import

```html
<script setup>
function handleClick() {
  Snackbar('Hello!')
}
</script>

<template>
  <var-button @click="handleClick">Say Hello</var-button>
</template>
```

---
_Source: https://npm.io/package/@varlet/import-resolver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
