-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Support resolve import.meta.hot.accept dep #16375
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
Comments
Can't agree more. |
I found a better way to do this if you are using react. import React from 'react'
import {lib} from '@/lib.js'
export function SomeComponent(props) {
React.useEffect((){
// you can get the new lib here
// if you are using import.meta.hot.accept callback , you will get the old file instead of the newest one.
console.log(lib)
},[lib]);
} |
Seems a bit magical. I'll try it out later to see if it can work under vite. |
Virtual modules are confusing, too. |
Description
Vite is a great project, and it does an excellent job with code hot reloading. However, I feel that it could be more friendly towards monorepos. When I tried to depend on other packages within a monorepo, I encountered some issues. The 'accept' feature tracks dependencies based on file paths, but when my module is an external module (relative to the current module within the workspace), I found it inconvenient to register the paths. I believe this project could potentially provide some useful APIs to address such needs.
Alternatively, I could redefine a file and then reexport the module.
This method is incredibly inconvenient and becomes a pure burden when it comes to writing code.
Suggested solution
vite/packages/vite/src/shared/hmr.ts
Lines 74 to 86 in b05c405
With this approach, it seems that I only need to check and resolve the 'deps' parameter at this point. I have tried it, but I'm not sure why there is a '/src' added before the relative path. I couldn't figure out when it was added, so I paused the experimental changes using this method.
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: