core
core copied to clipboard
[Bug report]: Bundler vite does not emit cache
Description
bundling a vuepress2 application with vite does not emit a cache directory while bundling with webpack does. I could not see any hint in the docs that this could be intended.
explicetly specifying the cache directory via
- CLI
- config
cache - config passed to vite
did not result in a cache directory either.
Using currently latest vuepress-next: 2.0.0-beta.51
Reproduction
https://github.com/jxn-30/reproduction-vuepress2-vite-no-cache
Used Package Manager
yarn
System Info
unfortunately an error:
TypeError: envinfo.run is not a function
at info (file:///home/jan/reproduction-vuepress2-vite-no-cache/node_modules/@vuepress/cli/dist/index.js:525:32)
at CAC.wrappedCommand (file:///home/jan/reproduction-vuepress2-vite-no-cache/node_modules/@vuepress/cli/dist/index.js:584:39)
at CAC.runMatchedCommand (file:///home/jan/reproduction-vuepress2-vite-no-cache/node_modules/cac/dist/index.mjs:610:34)
at CAC.parse (file:///home/jan/reproduction-vuepress2-vite-no-cache/node_modules/cac/dist/index.mjs:537:12)
at cli (file:///home/jan/reproduction-vuepress2-vite-no-cache/node_modules/@vuepress/cli/dist/index.js:602:11)
at file:///home/jan/reproduction-vuepress2-vite-no-cache/node_modules/vuepress-vite/bin/vuepress.js:8:1
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
at async loadESM (node:internal/process/esm_loader:91:5)
using yarn version 3.2.3 on Kubuntu 22.04.1
So how is this inflecting you? I am not expert at vite, but I do think that Vite does not need a cache dir during build
According to https://vitejs.dev/config/shared-options.html#cachedir, vite should emit a cache in general to increase build performance.
However, when you do a Vuepress build, vites default cache directory node_modules/.vite does not exist too, so something seems to prevent Vite from emitting this cache directory in my eyes.
Edit: Some more information on the Vite FileSystem-Caching can be found on https://vitejs.dev/guide/dep-pre-bundling.html
Thanks for the link, didn't have time to look through vite code, but searching in vuepress, I am not seeing anything edited in our side.
So just to make sure (becuz I did not check that before in vite3), in your other vite project, when you empty cache dir and process vite build, vite is generating cache files to "Pre bundle" deps right? (I don't think this is happening in vite2 at least)
that has been a good point!
Vite seems to only create the cache dir on dev server for development but not when building with vite build. I expect that to be the intended way altough for me that wasn't clear from the vite docs.
Maybe an information to Vuepress docs could be added to https://v2.vuepress.vuejs.org/reference/config.html#cache that this does not apply to builds with vite?
Possible to mention that, but I donot think this is necessary. Anyone familiar with vite should not be stranged at build stage. Alo the cache dir content should not be a focusable thing.
Maybe an information to Vuepress docs could be added to https://v2.vuepress.vuejs.org/reference/config.html#cache that this does not apply to builds with vite?
cc @meteorlxy Necessary?
Well, vite cache is for dev only for sure. I also don't think we need extra explanation in our side.