vite-plugin-optimize-persist
Persist dynamically analyzed deps optimization
Last updated 4 years ago by antfu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install vite-plugin-optimize-persist 
SYNC missed versions from official npm registry.

vite-plugin-optimize-persist

NPM version

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.

[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.

// 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

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

Add plugin to your vite.config.ts:

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

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

Sponsors

License

MIT License © 2021 Anthony Fu

Current Tags

  • 0.1.2                                ...           latest (4 years ago)

7 Versions

  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 6
Last Month 7
Dependencies (2)
Dev Dependencies (14)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org | Home |