Thanks to visit codestin.com
Credit goes to github.com

Skip to content

New features option does not work as expected #438

@kevinmarrec

Description

@kevinmarrec

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions