sharedDuringBuild: true
doesn't work in some cases
#18225
Labels
feat: environment API
Vite Environment API
p3-minor-bug
An edge case that only affects very specific usage (priority)
Describe the bug
This is probably an edge case. It looks like
sharedDuringBuild: true
doesn't function when there are differences inplugin
indices since the logic depends on matching plugin.name at the same index:vite/packages/vite/src/node/build.ts
Lines 1578 to 1591 in 95020ab
For example, this can happen when a custom environment has
build.modulePreload: false
as it offsets plugin list by:vite/packages/vite/src/node/plugins/index.ts
Lines 58 to 60 in 95020ab
I think most of the case explicitly setting
modulePreload: false
isn't necessary, but this kind of pattern exists in other places?Reproduction
https://github.com/hi-ogawa/reproductions/tree/main/vite-environment-sharedDuringBuild
Steps to reproduce
pnpm build
This reproduction initializes
sharedValue
in a config file, which is then accessed inside a plugin hook. Adding aconsole.log
, it shows something like this:System Info
(stackblitz) System: OS: Linux 5.0 undefined CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 18.20.3 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 10.2.3 - /usr/local/bin/npm pnpm: 8.15.6 - /usr/local/bin/pnpm npmPackages: vite: 6.0.0-beta.1 => 6.0.0-beta.1
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: