-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
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 a vite 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
if(isBuild && nodeEnv === 'development'){
delete importMetaFallbackKeys['import.meta.hot']
}
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.