You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here, config1ValueForSomeComponent is set to use the config1 property of either config.someComponent or config.default. Since the config.someComponent is an object, it should use the config1 property of that object. But since that object does not have config1 property, the value will be undefined and therefore the fallback of config1DefaultValue should be used.
However, in prod. build, the fallback code || 'config1DefaultValue' is stripped off and the value of config1ValueForSomeComponent is set to undefined.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Describe the bug
During production build, a part of code incorrectly gets removed which is not removed during dev mode
Reproduction
https://stackblitz.com/edit/vitejs-vite-new1edjc
Steps to reproduce
In the repro link, during dev, the value of
config1ValueForSomeComponent
isconfig1DefaultValue
and is shown in the HTML.However, after
npm run build && npm run preview
, the value ofconfig1ValueForSomeComponent
isundefined
as can be seen in the built preview HTML.The code in question is:
Here,
config1ValueForSomeComponent
is set to use theconfig1
property of eitherconfig.someComponent
orconfig.default
. Since theconfig.someComponent
is an object, it should use theconfig1
property of that object. But since that object does not haveconfig1
property, the value will beundefined
and therefore the fallback ofconfig1DefaultValue
should be used.However, in prod. build, the fallback code
|| 'config1DefaultValue'
is stripped off and the value ofconfig1ValueForSomeComponent
is set toundefined
.System Info
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.1.0 => 6.1.0
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: