ericclemmons / start-server-webpack-plugin

Automatically start your server once Webpack's build completes.
MIT License
158 stars 26 forks source link

Use IPC to notify child of hot update #9

Closed wmertens closed 6 years ago

wmertens commented 7 years ago

Since cluster uses childProcess.fork, you can send messages to the child. This could be used to tell the hot infra that there was an update.

That way, the polling setup isn't necessary and updates would be instant. It would require a custom hot module to receive the messages.

wmertens commented 7 years ago

Because of #12 it might actually be better to not fork at all, and run the script in-process. It would still need a little bit of code to tell the hot handler about the newly compiled code.

tikotzky commented 6 years ago

You should not need a custom hot module to send a signal to the child process... You should be able to use webpack/hot/signal instead of webpack/hot/poll and then just send a signal to the worker process in the after emit hook.

Im gonna submit a PR soon for you to take a look at...

wmertens commented 6 years ago

See https://github.com/ericclemmons/start-server-webpack-plugin/blob/use-the-fork/src/monitor.js