-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(optimizer): hash by config mode only #8878
Conversation
👷 Deploy Preview for vite-docs-main processing.
|
✅ Deploy Preview for vite-docs-main canceled.
|
1 similar comment
✅ Deploy Preview for vite-docs-main canceled.
|
We still need this in dev though, see: // esbuild automatically replaces process.env.NODE_ENV for platform 'browser'
// In lib mode, we need to keep process.env.NODE_ENV untouched, so to at build
// time we replace it by __vite_process_env_NODE_ENV. This placeholder will be
// later replaced by the define plugin
const define = {
'process.env.NODE_ENV': isBuild
? '__vite_process_env_NODE_ENV'
: JSON.stringify(process.env.NODE_ENV || config.mode)
}
// Build with esbuild using `define` Maybe we should review why we are not using config.mode directly for deps optimization. Or another option is to always define to |
We only need to do Though I also think it's worth investigating why Re using |
If
Really puzzled by this one. It should be easy to debug in your setup to check what is going on 🤔
I think we should go with this approach so we remove these from the hash. If you prefer, I can send a PR with that. |
When I test #8869, it doesn't seem to happen anymore. Though whenever I log For Vite 2.9, I log in the same locations, and dep hash returns Reference: dep hash:
esbuild optimize:
This is really strange, and perhaps we're calling the optimizer too early. But anyways this shouldn't be an issue with #8869 merged so closing this. |
Description
Fix regression from #7673
When hashing the
mode
, useconfig.mode
only.process.env.NODE_ENV
is different thanmode
.Otherwise this could cause unnecessary reloads on warm starts.
Additional context
I think past me made a brain-fart.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).