-
-
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
Preserve import.meta.hot for library dev builds #8921
Comments
vite build mode will replace const importMeta = import.meta
if(importMeta.hot) {
....
} BTW, for vite build I think to replace |
That doesn't seem to work. Removing my local changes from original issue where I delete the replacement key, I agree replacing |
One way Vite can allow this is by moving this line:
into |
I too would like a feature like this, but for different reasons. I maintain a library that ships a bunch of components and composables. There's also an optional bundle that users can include to integrate with pinia. I wish it would handle HMR automatically for them, but if I can't have a clean way to preserve |
Description
I would like a way to preserve
import.meta.hot
in library builds. I'm building a library that will be used in a project developed with vite and there doesn't seem to be a way to add HMR code to the library itself for use in my other project. Ideally I would be able to build a dev version of the library with HRM code using a config flag or during avite build --watch
process.Suggested solution
I think a solution similar to this #8090 would work. Currently, as I'm developing this library, I'm using a locally linked version of vite (3.0.0-beta.6) with custom modifications to the define plugin file as a workaround but ideally it would be built into vite. My workaround is basically to delete the replacement when in dev mode but someone with a better understanding of vite internals may have a more robust solution including configs.
my workaround:
packages/vite/src/node/plugins/define.ts
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: