Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

unzico/vite-define-failing-build

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vite-define-failing-build

The define plugin of vite is replacing code inside node_modules, which can lead to failing builds.

Tracked in vitejs/vite#4271
Fixed in vitejs/vite#5515

Reproduce the issue

  1. yarn
  2. yarn build -> fails
  3. uncomment line 9 in vite.config.ts
  4. yarn build -> doesn't fail

Explanation

The define plugin allows the use of a global var called __DEV__. Take a look at the src/App.tsx file (line 11) to see it in action. The define plugin statically replaces this part of the code with a boolean during the build process, e.g. if (__DEV__) becomes if (false). However, the warning dependency is also defining a var named __DEV__. Vite replaces this part as well. The final code in warning.js looks something like this: var false = process.env.NODE_ENV !== "production". That's not valid js, the build fails.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published