-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Saving js file does not cause browser to reload #909
Comments
That’s not supposed to happen,could u provide us with some code as this might be the problem. Sent with GitHawk |
I have some further observation. What I'm working on is a jQuery plugin project. Let's talk about two projects and two situations one by one: Project A (PA): A simplified one html one js project; Situation A (SA): toggle commenting the PA-SA: PA-SB: PB-SA: PB-SB: It looks like it has something to do with which part of the js file got changed. Also I found when the browser doesn't reload, the update notification actually is sent via the websocket to the browser.
|
Not sure if any chance to take a look at this issue? I have been using parcel for about a month, and I need to manually reload the browser each time I save the js file. For html, scss files, I don't need to. |
I have the same problem using React and Intellij IDE with Parcel. |
I had a similar issue, but was I'm using Windows 10 and PHPStorm as the IDE. HMR worked for maybe a couple of times, and stopped detecting changes. However, I noticed that when I used Notepad++ Parcel picked up the changes fine. So for any of you who are using PHPStorm, WebStorm, IntelliJ or any other Jetbrains IDE that uses an auto-save feature called "Safe write". If safe-write is selected, a changed file is first saved in a temporary file. If the save operation succeeds, the file being saved is replaced with the saved file. The original file is deleted and the temporary file is renamed. Also, the ownership of such file changes. And Parcel <= 1.9.7 does not detect that for now. So in the meantime, disable safe-write. Other IDE's have similar option, but they may be named differently. |
There is actually a pretty extended note on safewrite in the docs. https://en.parceljs.org/hmr.html#safe-write Not sure what else we can do to make this even more clear |
@DeMoorJasper in the Safe Write section of the doc, it writes like this:
In my situation, the change of the js file was detected, this can be proved by watching the websocket frames in Chrome dev tools. But I have to manually click the reload button on the browser to make the change of the js file effective. However, for html files, I don't need to reload the browser. This happened when I used vscode and vim. In vim, Update: I just had some further test of the |
@elgs my comment was more aimed towards the comment explaining safe write, not sure what issue you're having. Might just be improper HMR handling on the JS side (in your code), could be something else. |
Perhaps you could try with this in your entrypoint: if (module.hot) {
module.hot.accept(function () {
window.location.reload();
});
} |
@DeMoorJasper your code snippet solved my problem! Thank you! The reason I made the comment was that my feeling was that this problem might not be due to the safe write. Because safe write blocks the detection of file change. The problem happened after the file change had been successfully detected. This problem doesn't really bother me because a manual reload is not the end of the world, but with the if module dot hot code, my life is a lot easier. Thank you. Some side note: |
@elgs the project has come a long way, we are still constantly discovering new things where parcel hangs or has issues with and are trying to solve them all sooner or later. There might be other places, libraries and ofcourse also Parcel code that can cause hanging. I'm pretty positive that by the time Parcel 2 gets out, Parcel will rarely ever hang on any project. |
Gonna close this as it has been resolved. Feel free to open any new issues for the hanging issues you mentioned |
Btw — I had the same issue with hot-reload. |
@DeMoorJasper - Is there a plan to build a feature for parcel which allows parcel to handle the "save-write"-feature from different IDEs? |
I have the same issue on Visual Studio 15.8, and no way to disable the "safe write" feature (if any). |
This is a bummer. I'm running into this issue also using Visual Studio 15.9.3. I hope it gets resolved soon. Edit: If anyone using VS is interested, I created a Gist with the I also use NPM Task Runner to run the |
I have a couple of html, js and scss file managed by parcel. The only problem is that when the js files got saved, the watch process doesn't reload the browser. I can confirm that when the html, scss file got saved, the browser got reloaded as expected. I also observed that when js files got saved, the changes had been propagated to the browser via the websocket connection, this can be confirmed by looking at the websocket frames in the Chrome dev tools. Wondering if this happens to everyone or only me.
The text was updated successfully, but these errors were encountered: