Skip to content

[plugin-react] Alpha crashes when setting NODE_ENV in .env file #10854

@IanVS

Description

@IanVS

Describe the bug

I tried upgrading my app to the alpha versions, and found that it was crashing in my staging environment.

I use vite build --mode=staging, and set the NODE_ENV=production in a file named .env.staging. This seems to result in a mixup of production and non-production modes in the react plugin, and I get an error in my browser console:

index.f694439e.js:7690 Uncaught TypeError: jsxDEV is not a function

Ping @rtsao, I guess this check might be happening before .env files are taken into consideration? https://github.com/vitejs/vite/pull/9590/files#r940780633

Reproduction

https://stackblitz.com/edit/vitejs-vite-usasym?file=.env.staging,package.json&terminal=repro

Steps to reproduce

No response

System Info

System:
    OS: macOS 12.5.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 65.91 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.12.1 - ~/.nvm/versions/node/v16.14.2/bin/npm
  Browsers:
    Brave Browser: 107.1.45.116
    Firefox: 106.0.5
    Safari: 15.6.1
  npmPackages:
    @vitejs/plugin-react: ^3.0.0-alpha.0 => 3.0.0-alpha.0
    vite: ^4.0.0-alpha.0 => 4.0.0-alpha.0

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions