Skip to content

vite define and object property value shorthand dev and build inconsistencies  #6653

@xrado

Description

@xrado

Describe the bug

Vite config define: {APP_DOMAIN: JSON.strinfigy('x')}
and vue component source

data(){
        return {
                APP_DOMAIN
        }
},

works fine in dev mode, but on build returns error on APP_DOMAIN position

[rollup-plugin-dynamic-import-variables] Unexpected token (166:6)
App.vue:166:6
error during build:
SyntaxError: Unexpected token (166:6)

Tried also APP_DOMAIN: APP_DOMAIN which works as expected in dev mode, but build translate it to x: 'x'
Webpack didn't have issue with this.

Reproduction

link

System Info

System:
    OS: macOS 12.1
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 403.77 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.18.2 - /usr/local/opt/node@14/bin/node
    npm: 6.14.15 - /usr/local/opt/node@14/bin/npm
  Browsers:
    Chrome: 97.0.4692.99
    Firefox: 95.0.2
    Safari: 15.2
  npmPackages:
    @vitejs/plugin-legacy: ^1.6.4 => 1.6.4 
    @vitejs/plugin-vue: ^2.1.0 => 2.1.0 
    vite: ^2.7.13 => 2.7.13

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    inconsistencyInconsistency between dev & build

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions