-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Add HMR #25
Add HMR #25
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one question
I suggest you to extract HMR runtime codes into virtual module, you can refer to these codes: |
It looks good to apply. Let me take a closer look and try to apply it. thank you |
I have a question whether it can be done that refresh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GLTM
Hello everybody. Sorry for the delay in merging this PR. I need to review and supplement the suggestions you have made. Thank you for your understanding. |
Happy holidays! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the slow review, as I have been busy with the company's work content recently。
GLTM !
have two question:
1、chrome always give a error about look like can't load file: src/pages/options/index.html
and close crx when hrm reload。Then must goto chrome://extensions/
page click refresh button by my self。Maybe chrome checked local file between vite transformed and render files execution。(only happened when i write refreshOnUpdate
function in background.js
)
2、why use rollup plugin alone but not vite ?
Hi! I'll give you an answer. 1️⃣ Yes, that's right. From what I found out, the only way to update the background.js was to call To resolve this issue, the reloadServer must be able to know if the change occurred in the background or in the client. If you look at the screenshot below, you can actually see other sources using those solutions. The cons of this method is that it takes away the opportunity for the user to change the file name freely. Well... anyway, vite config is still detecting the location of the files inside the src folder :) Or, I think we can change the name of the file used in each part in one place while changing the boiler plate more rigidly. Anyway, I'm thinking about it, so I'd appreciate it if you could give me your opinion. 2️⃣ I didn't quite understand this question. I'm not sure exactly what it means to use the rollup plug-in and not use the vite plug-in. |
@Jonghakseo 2️⃣ |
1️⃣ All right, but I want to give developers a more flexible reload function without checking or modifying their internal implementation. Therefore, I worked on setting the watch path so that I could set the path to trigger the update. 2️⃣ I'm not sure about the additional benefits of using the vite plug-in. There is no reason not to use the vite plug-in if it is more improved when using other hooks. If you have a good idea, I would appreciate it if you could suggest it. For now, HMR will merge. |
Seems your HMR doesn't work correctly 😅 Look around this web ext plugin: They just emit HTML pages into ext file during dev server starts. Let's create a custom HTML entry and add it to rollup's input.
<script type="module">
<!-- HMR here -->
import RefreshRuntime from "/@react-refresh"
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
</script>
<script type="module" src="/@vite/client"></script>
...
<script type="module" src="./main.ts"> Any TS file is imported by the entry will be transpiled, even accessing it through HTTP.
|
Wow. Here's the implementation I was looking for. I will refer to it and reflect it. |
@@ -15,10 +15,13 @@ | |||
"allowSyntheticDefaultImports": true, | |||
"lib": ["dom", "dom.iterable", "esnext"], | |||
"forceConsistentCasingInFileNames": true, | |||
"typeRoots": ["./src/global.d.ts"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curios what is it about
No description provided.