Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New features option does not work as expected #438

Closed
8 of 9 tasks
kevinmarrec opened this issue Aug 29, 2024 · 1 comment
Closed
8 of 9 tasks

New features option does not work as expected #438

kevinmarrec opened this issue Aug 29, 2024 · 1 comment

Comments

@kevinmarrec
Copy link

kevinmarrec commented Aug 29, 2024

Related plugins

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 :

  • features.optionsAPI is set to false
  • No define set in config

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

  • Notice no bundle size difference when toggling features.optionsAPI and run npm run build
  • Notice difference only when defining define.__VUE_OPTIONS_API__

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

@kevinmarrec
Copy link
Author

kevinmarrec commented Aug 29, 2024

Thanks for the quick fix, I'm gonna play with the new release, please discard the comment I deleted if you got one in your notifications, I think I misread the commit with ! instead of actual !!.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant