# vite-plugin-optimize-persist

> Persist dynamically analyzed deps optimization

Latest version **0.1.2** (published 2021-12-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-optimize-persist
pnpm add vite-plugin-optimize-persist
yarn add vite-plugin-optimize-persist
bun add vite-plugin-optimize-persist
```

## 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.1.2 |
| Published | 2021-12-24 |
| First published | 2021-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 161 |
| Author | Anthony Fu |
| Maintainers | antfu |
| Keywords | vite-plugin |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-optimize-persist
- Repository: https://github.com/antfu/vite-plugin-optimize-persist
- Homepage: https://github.com/antfu/vite-plugin-optimize-persist#readme
- Issues: https://github.com/antfu/vite-plugin-optimize-persist/issues
- Funding: https://github.com/sponsors/antfu
- npm.io page: https://npm.io/package/vite-plugin-optimize-persist

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^4.3.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.0.0

## 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.1.2 (latest) — 2021-12-24
- 0.1.1 — 2021-12-05
- 0.1.0 — 2021-10-17
- 0.0.5 — 2021-07-29
- 0.0.4 — 2021-07-29
- 0.0.3 — 2021-07-29
- 0.0.2 — 2021-07-29

## README

# vite-plugin-optimize-persist

[![NPM version](https://img.shields.io/npm/v/vite-plugin-optimize-persist?color=a1b858&label=)](https://www.npmjs.com/package/vite-plugin-optimize-persist)

Persist dynamically analyzed dependencies optimization

## Motivation

Vite's dependencies pre-optimization is cool and can improve the DX a lot. While Vite can smartly detect dynamic dependencies, it's on-demanded natural sometimes make the booting up for complex project quite slow.

```bash
[vite] new dependencies found: @material-ui/icons/Dehaze, @material-ui/core/Box, @material-ui/core/Checkbox, updating...
[vite] ✨ dependencies updated, reloading page...
[vite] new dependencies found: @material-ui/core/Dialog, @material-ui/core/DialogActions, updating...
[vite] ✨ dependencies updated, reloading page...
[vite] new dependencies found: @material-ui/core/Accordion, @material-ui/core/AccordionSummary, updating...
[vite] ✨ dependencies updated, reloading page...
```

As you might know, you can explicitly set the dependencies in `optimizeDeps.include` so they will be optimized once at the server start up for the first time. When you project become more complex, this could be somehow a bit laborious.

With `vite-plugin-optimize-persist`, it will persist the names of the dynamic dependencies in your `package.json` so you and your team does not need to be bother by them for the next time.

```jsonc
// package.json
{
  // ...
  "vite": {
    "optimizeDeps": {
      "include": [
        // managed by `vite-plugin-optimize-persist`
        "@material-ui/core/Accordion",
        "@material-ui/core/AccordionSummary",
        "@material-ui/core/Dialog",
        "@material-ui/core/DialogActions",
        "@material-ui/icons/Dehaze",
        "date-fns/format",
        "lodash/debounce",
        "lodash/map"
      ]
    }
  }
}
```

## Install

```bash
npm i -D vite-plugin-optimize-persist vite-plugin-package-config
```

Add plugin to your `vite.config.ts`:

```ts
// vite.config.ts
import OptimizationPersist from 'vite-plugin-optimize-persist'
import PkgConfig from 'vite-plugin-package-config'

export default {
  plugins: [
    PkgConfig(),
    OptimizationPersist()
  ]
}
```

## Sponsors

<p align="center">
  <a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
    <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
  </a>
</p>

## License

[MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)

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