core
core copied to clipboard
[Bug report]: build with vite mode parallel with cause error
Description
Background
Maybe it's look likes a bug. Refer nonzzz/vite-compression-plugin#18
I try to change vuepress it's vite build logic ( from parallel to serial. It works well
Form rollup/rollup#3506 i think we shouldn't parallel run vite build :)
Reproduction
https://github.com/u2sb/www.u2sb.com/tree/vite-compression-plugin
Used Package Manager
pnpm
System Info
$ vuepress build docs --clean-cache --clean-temp
✔ Cleaning temp - done in 20ms
✔ Cleaning cache - done in 2ms
✔ Initializing and preparing data - done in 3.45s
⠹ Compiling with vite
(!) Some chunks are larger than 1024 kBs after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✖ Compiling with vite - failed in 74.95s
Error: ENOENT: no such file or directory, open 'D:\githubDownLoad\www.u2sb.com\docs\.vuepress\.temp\.server\assets\app-77c74ba0.js'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I do think you need to provide detailed inforamation about what our problem is, at least the issue is now thrown at your plugin.
You may need to explain clearly:
- What's the central action of the issue part
- What we did to let this happen (our fault or just compatibility breaking
- Any possible solution
@Mister-Hope Thanks for you feedback. I will update error message
Sorry for the waitting. From the error info. I judged that the error occurred in the generatorBundle stage. Becasue currently. vuepress internal build logic is parallel. But it will casue rollup bundle context loose right hash assets file
According
[clientOutput, serverOutput] = await Promise.all([
viteBuild(clientConfig),
viteBuild(serverConfig)
]);
Will emit an error
But with serial

~~Sorry for the late reply, so what 's the actual problem of paralleling packaging one project with 2 rollup instance? I still need some further explanation.~~
~~It's fair to packing a project and outputting them at different places at same time.~~
I got what the issue is.
Here we are generating 2 config:
https://github.com/vuepress/vuepress-next/blob/fd2e241235fc87c66ce59ba22c8e27521c594fbd/packages/bundler-vite/src/resolveViteConfig.ts
But we are sharing same plugin instance across client/server in build process. @meteorlxy
Yes. You are right.It will cause concurrent.
I think we should generator two difference app instance? Or build config?
parallel build won't cause error ( My mistake
I am not familiar with vite, but if you do think that 2 plugin instance is required to fix this, then a breaking change must be made at api, we shall use a callable function for bundler:
- bundler: viteBundler({
- // vite bundler config
- })
+ bundler: () => viteBundler({
+ // vite bundler config
+ })
Sounds bad. That will be a break change : (
I look vuepress source code. I noticed https://github.com/vuepress/vuepress-next/blob/fd2e241235fc87c66ce59ba22c8e27521c594fbd/packages/bundler-vite/src/plugins/mainPlugin.ts#L93-L114
Currently, Us build config across client/server in build process. But will change the process of rollup generating hash. See rollup
By the way. rollup generateBundle is sequential : )
I think there two way to sovle.
- Remove Promise.all ( Using serial.
- Isolate two config list.
Remove Promise.all ( Using serial.
This is definitely not our consideration, our build time is already long enough, and our primary goal is to improve speed
Closing as this has been stale for a long time. Vite version and VuePress version has updated a lot.
Feel free to open a new issue with the latest version & context if it's still a problem
I got what the issue is.
Here we are generating 2 config:
https://github.com/vuepress/vuepress-next/blob/fd2e241235fc87c66ce59ba22c8e27521c594fbd/packages/bundler-vite/src/resolveViteConfig.ts
But we are sharing same plugin instance across client/server in build process. @meteorlxy
I don't think this is should be resolved. A lot of plugins can not work in multiple instance.
Running successfully in multiple instance Means plugin cannot have any local state outside any hooks, But as plugins are designed callable, they should be allowed to have such things.
I am not familiar with vite, but if you do think that 2 plugin instance is required to fix this, then a breaking change must be made at api, we shall use a callable function for bundler:
- bundler: viteBundler({ - // vite bundler config - }) + bundler: () => viteBundler({ + // vite bundler config + })
This should be a valid fix, but this is a breaking change. @meteorlxy
Suggest remaining it open