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
yarn
yarn build
-> fails- uncomment line 9 in
vite.config.ts
yarn build
-> doesn't fail
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.