catamphetamine / webpack-isomorphic-tools

Server-side rendering for your Webpack-built applications (e.g. React)
MIT License
1.25k stars 48 forks source link

Is there a possibility to call "webpackIsomorphicTools.refresh();" outside of rendering middleware? #26

Closed sergesemashko closed 9 years ago

sergesemashko commented 9 years ago

Hello,

I have wepback configured with webpack-isomorphic-tools and encapsulated in npm package by custom CLI, so several projects can share the same webpack setup. Rendering middleware is outside of npm package containing webpack-isomorphic-tools, so I'm trying to avoid any references to webpack-isomorphic-tools on the project level.

Is there a way to keep hot module replacement feature and do not have webpackIsomorphicTools.refresh(); in middleware in the same time?

Thanks, Sergey

catamphetamine commented 9 years ago

Well, you could try to add a parameter to your rendering middleware. Like onClick but that would be onRender. Pass webpackIsomorphicTools.refresh.bind(webpackIsomorphicTools) and call it during refresh.

sergesemashko commented 9 years ago

good idea, thanks. Would you consider having some kind of files watcher just for development mode to clear assets cache? maybe in this case webpackIsomorphicTools.refresh(); will be not necessary at all. I could submit a pull request If you are interested. Let me know what do you think.

catamphetamine commented 9 years ago

No go for embedding a file watcher inside webpack-isomorphic-tools.

In your case there are two npm packages which aren't connected to each other in any way, and still you want to have a way for one npm package to know when an event in the other npm package fires.

I guess a classic on-render listener function is the simplest solution in your case