# vite-plugin-auto-modules

> Automatically use modules from a folder

Latest version **0.0.4** (published 2023-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-auto-modules
pnpm add vite-plugin-auto-modules
yarn add vite-plugin-auto-modules
bun add vite-plugin-auto-modules
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2023-11-23 |
| First published | 2023-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Cyole |
| Maintainers | cyole |
| Keywords | vite, vue, modules, auto, auto-modules |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-auto-modules
- Repository: https://github.com/cyole/vite-plugin-auto-modules
- Homepage: https://github.com/cyole/vite-plugin-auto-modules#readme
- Issues: https://github.com/cyole/vite-plugin-auto-modules/issues
- Funding: https://github.com/sponsors/cyole
- npm.io page: https://npm.io/package/vite-plugin-auto-modules

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2023-11-23
- 0.0.3 — 2023-11-23
- 0.0.2 — 2023-11-23
- 0.0.1 — 2023-11-23

## README

# vite-plugin-auto-modules

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![JSDocs][jsdocs-src]][jsdocs-href]
[![License][license-src]][license-href]

> A Vite plugin that automatically use modules from a folder.

## Getting Started

Installation

```bash
pnpm install vite-plugin-auto-modules -D
```

Add to `vite.config.ts`

```ts
import { defineConfig } from 'vite'
import AutoModules from 'vite-plugin-auto-modules'

export default defineConfig({
  plugins: [
    AutoModules({
      // options
    })
  ]
})
```

## Usage

main.ts

```ts 
import { createApp } from 'vue'
import { installModules } from 'virtual:auto-modules'
import App from './App.vue'

const app = createApp(App)

// install modules
installModules(app)

app.mount('#app')
```

Place a `.ts` file with the following template in the `moduleDir` folder, it will be installed automatically.

```ts
import type { UserModule } from 'vite-plugin-auto-modules'

export const install: UserModule = (app) => {
  // do something
}
```

## Client Types

If you want to use the types of the client, you need to add the following configuration to `tsconfig.json`.

```json
{
  "compilerOptions": {
    "types": ["vite-plugin-auto-modules/client"]
  }
}
```

## Configuration

```ts
export interface Config {
  /**
   * @default "/src/modules"
   */
  moduleDir?: string
}
```

## License

[MIT](./LICENSE) License © 2023-PRESENT [Cyole](https://github.com/cyole)


<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/vite-plugin-auto-modules?style=flat&colorA=080f12&colorB=1fa669
[npm-version-href]: https://npmjs.com/package/vite-plugin-auto-modules
[npm-downloads-src]: https://img.shields.io/npm/dm/vite-plugin-auto-modules?style=flat&colorA=080f12&colorB=1fa669
[npm-downloads-href]: https://npmjs.com/package/vite-plugin-auto-modules
[bundle-src]: https://img.shields.io/bundlephobia/minzip/vite-plugin-auto-modules?style=flat&colorA=080f12&colorB=1fa669&label=minzip
[bundle-href]: https://bundlephobia.com/result?p=vite-plugin-auto-modules
[license-src]: https://img.shields.io/github/license/cyole/vite-plugin-auto-modules.svg?style=flat&colorA=080f12&colorB=1fa669
[license-href]: https://github.com/cyole/vite-plugin-auto-modules/blob/main/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
[jsdocs-href]: https://www.jsdocs.io/package/vite-plugin-auto-modules

---
_Source: https://npm.io/package/vite-plugin-auto-modules · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
