New features option does not work as expected (original) (raw)

Describe the bug

Base on implementation here : https://github.com/vitejs/vite-plugin-vue/blob/main/packages/plugin-vue/src/index.ts#L224

And the following state :

It results in this expression

(false || undefined) ?? true

And unfortunately, the whole expression results to true.

Indeed (false || undefined) === undefined, and then comes the nullish coalescing operator.

I think what we want would be :

options.value.features?.optionsAPI ?? config.define?.VUE_OPTIONS_API ?? true

I guess it's not a problem for __VUE_PROD_DEVTOOLS_ & __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ because they fallback to false.

Reproduction

https://stackblitz.com/edit/vitejs-vite-y1sguk

Steps to reproduce

System Info

System: OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish) CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K Memory: 6.32 GB / 15.49 GB Container: Yes Shell: 5.8.1 - /usr/bin/zsh Binaries: Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node Yarn: 1.22.22 - ~/.nvm/versions/node/v20.15.0/bin/yarn npm: 10.7.0 - ~/.nvm/versions/node/v20.15.0/bin/npm bun: 1.1.26 - ~/.bun/bin/bun

Used Package Manager

npm

Logs

No response

Validations