ericclemmons/start-server-webpack-plugin

Support restarting on every build

djmitche opened this issue · 14 comments

I built https://github.com/djmitche/neutrino-middleware-restart-server because, for local development of an app that doesn't support HMR, it's easiest to just restart the whole thing on every build.

Is this a feature you'd consider including in start-server-webpack-plugin? Any recommendations on how you'd like to see it implemented?

The monitor.js script that gets added to the end of the entry could exit the app when a change happens; this could be done by process.exit(0)
To know when to do this, monitor-loader.js should include a setting, or monitor.js might find it itself.
I imagine that you don't turn on hmr? Monitor-loader.js should be able to read that setting.

I'm of course talking about the v3 branch which is currently still a PR because I didn't get around to releasing it yet :)

Hm, I was hoping to implement this externally, so that the app itself can run without any injected code. For example, if I was working on a sync data-analysis tool that just crunches lots of numbers, then any async node monitoring callbacks would never get a chance to run. My approach was rather to kill the subprocess on every change. As you've noted, this mode does not require HMR, either.

Hm, maybe we're going in different directions. I want to be able to run essentially arbitrary code -- no HMR, no startup monitoring, nothing -- for all it cares, the thing it's running is a binary executable.

If that's far enough from what start-server does, then maybe it makes sense for me to fork and develop something like "restart-server-webpack-plugin"?

Sounds good. Your comment about v3 being a PR has me worried, though -- if I write a PR against current master, will that generate massive conflicts?

@djmitche did you ever write a PR for this?

Not yet, but it's still on my todo list :)

Now that I look more closely at the open "v3" PR, it looks like it might support this already. If HMR fails (which it would all the time if it's disabled, I think), then it restarts the process. True, it seems to inject the monitor anyway, but for my purposes at least that's not the end of the world. I think I'll wait until that's released and try it out. If it doesn't suit my needs, then I'll try to make a minimal modification.

I'm not using HMR and installed the beta using npm install --save-dev start-server-webpack-plugin@beta

        new StartServerPlugin({
            entryName: 'Server',
            nodeArgs: ['--inspect'],
            restartable: true
        }),

It doesn't appear to restart the server upon rebuilds, unfortunately.

@RyanEwen can you paste a log?