-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement a live reload server #2
Comments
I use that with Vue.js, +1 super useful |
Yes @kinow, the vue cli is using some npm package like livereload to do that. The thing is that that needs a nodejs server to work, my intent is to have a prolog version of that if possible without the need of nodejs. |
Yup, that's what I understood too. Only used "this inotify" to show another module with same name, though in different language. Sorry the confusion! |
be simpler to write a bit of js that makes a pengine that calls make, add a button to page to fire it and reload on success. |
or just poll and watch on the server for change |
@Anniepoo I don't want to sound utopic but ideally the page will refresh automagically when saving a file. I just need some help with the part that creates the pengine and calls make. Can you provide any example? |
It would be quite nice if we could move towards using webpack with it's dev server and Hot Module Reload, designed for just this use case. To really make this work, however, I believe we would need to write out the JavaScript and serve it, rather than generating it on demand within Pengines. Would be something like this:
However, the current flow is always generating the JS on demand, so we might need to come up with a way to build it at development time. |
I do not agree at all @ninjarobot Also take into account that when a .pl is saved it doesn't necessarily implies that a js should be rebuilt. |
That's not really the only reason to use webpack, it brings a lot of other benefits. True, you're going to end up with nodejs and deeper integration into the JS ecosystem, babel, etc, I'm not so sure that's really a bad thing, though (I'm not the first person in this thread to mention I understand every .pl doesn't result in a new .js, however some .pl change does, and with some opinionated project structure, HMR is a mature solution for this common problem. Did you have something else in mind? Manually building this same sort of thing? |
Yes and I have specified the steps needed in the description of the thread. @ninjarobot you are free to explore the webpack option and come back to tell us how it went. |
I'll provide an example for the pengine call. I agree, the file observation solution is better. |
SWI-Prolog resource system takes care of this. |
I've thought up a way to do this with no change to code, just by loading a lib. Involves a bit of deep chicken waving, but can be done. I'll try to find some cycles this evening to promulgate a pack for it. |
I should also say, reading the original issue - C-c C-m in the editor makes, and will give save dialogs for each file. I personally do C-c C-s C-c C-m to make, which avoids the dialog. |
One thing I should say here - Prolog lives in it's own ecosystem, and that's been amazingly effective at futureproofing it. I would guess some descendent of SWI-Prolog will be here long after nodejs is gone. |
www_open_uri/1 will open a web page in a new tab. |
That's fine, I understand the perspective. There are existing processes and tooling that will just have to be reinvented, in this case it's just reloading a page (or part of it) when code changes server side, and then the necessary work to pull that code out when publishing a production application. Not an insurmountable task, for sure. |
After a bit more research, it looks like yes, inotifywait and either a websocket or a never-ending pengine call. |
A nice client side hook might be to not reload the page but just call a js function. |
@nicoabie - check out the websocket package. https://github.com/anniepoo/whiteboard hub.pl got integrated into SWI-Prolog after that was written. |
@Anniepoo I think I got lost a little bit in your train of thought. I'll take a look into the websocket package, sure. Regarding not reloading and just calling a js function what will the use case? Or you just mean to have it decoupled to call any function, one being The hook about grabbing the state before reload to have it applied after reloading (which I believe is the use case) I think it is a great idea and we can create another story for it. I will then check alternatives on how to do it :) |
yes, I meant decouple it so you can put in some custom behavior instead of just reloading the document. my train of thought is a Brio train. |
As I was playing with the code I found myself querying make. upon save and the going to the browser to press F5 to reload.
I think it would be very cool if we can automate this process. I've already started playing with inotify and reading about websockets in prolog.
The idea is fairly simple and can be split in tasks (each one with an approximate complexity given my beginner skills):
make.
Needs investigation but I've read of hot reload from another thread. (hard)Thoughts?
The text was updated successfully, but these errors were encountered: