yan-foto / electron-reload

Simplest (:pray:) way to reload an electron app on file changes!
https://www.npmjs.com/package/electron-reload
MIT License
522 stars 55 forks source link

Can we keep track of changed resources and reload only respective browser windows? #4

Open yan-foto opened 9 years ago

dorayx commented 9 years ago

Can I help with this feature ?

yan-foto commented 9 years ago

@dorayx sorry for the late reply! Do you have any suggestions on where to start?

dorayx commented 9 years ago

@yan-foto I think these events might help:

We can get the URLs of the loaded files by the event did-finish-load, but some other files may be loaded by a request, such as the scripts and the stylesheets I think we can fetch the URLs of those by the event did-get-response-details

Then we create a Map object to maintain every loaded resource, an URL as the key and an array of the relative webContents objects as the value

So every time a resource is changed, we will get the resource URL via the module chokidar and then reloadIgnoringCache the webContents objects associated with it

yan-foto commented 9 years ago

This sounds promising. I haven't got into the details though! Would you create a pull request please :+1: ?

dorayx commented 9 years ago

Yes, I've been working on it

HeilTec commented 7 years ago

The render process can load resources in several ways. Any references made by the loaded file (index.html) like script tags or external style-sheets can be leached from the webContents events.

To detect modules loading using require('module') a global hook needs to be implemented. Hooking the require function in the main module does not seem to affect sub-modules loading.

@dorayx Have you made any uncommitted progress?

Despite the problems, I feel this warrants looking into.