You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This allows users to preserve import.meta.hot in the build by using define: { 'import.meta.hot': 'import.meta.hot' } in the config. Being able to preserve these keywords in the final build is useful for library development builds that want to include HMR code directly in the library.
Additional context
Not sure if this requires more tests than what I've provided, but if so, let me know where and I can add them.
What is the purpose of this pull request?
Bug fix
New Feature
Documentation update
Other
Before submitting the PR, please make sure you do the following
Vite usually does not transform libraries under node_modules, so having import.meta.hot in your lib might not always work. I'd suggest using https://github.com/antfu/vite-hot-client
Oh I didn't know that. Could it be because in Vite 2, esbuild was incorrectly transforming import.meta.hot to ({}).hot? I think this is fixed in Vite 3 now, and it looks like importAnalysis work in node_modules too.
I guess it would because import.meta.hot is preserved in the optimized bundle, and importAnalysis would detect and inject the hot context. I also did a quick test and it seems to work.
One thing we changed in Vite 3 is that optimized deps are going now through the vite plugin pipeline, as we need to replicate what the build did in v2 with plugin commonjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix #8921
This allows users to preserve
import.meta.hotin the build by usingdefine: { 'import.meta.hot': 'import.meta.hot' }in the config. Being able to preserve these keywords in the final build is useful for library development builds that want to include HMR code directly in the library.Additional context
Not sure if this requires more tests than what I've provided, but if so, let me know where and I can add them.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).