Yes Webpack will replace the dependent files. Webpack made a concept called "module tree" based on dependency tree. File changes will propagate along the tree, and hit the root at last. But if a change propagates to root, the whole page reloads. That's not what we wanted.
I don't have an example, but you may follow the docs: https://webpack.js.org/guides/hmr-react/#app-code roughly 3 steps(I did that before but not sure about every detail) 1) add configs in `webpack.config.js` entry: [ 'react-hot-loader/patch', // activate HMR for React 'webpack-dev-server/client?http://localhost:8080', <---- add this // bundle the client for webpack-dev-server // and connect to the provided endpoint 'webpack/hot/only-dev-server', <---- add this // bundle the client for hot reloading // only- means to only hot reload for successful updates './index.js' // the entry point of our app ], plugins: [ new webpack.HotModuleReplacementPlugin(), <---- add this // enable HMR globally new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates ], 2) add `module.hot.accept('./demo', cb)` to handle the changes from './demo', so it will not reload the page: // Hot Module Replacement APIif (module.hot) { module.hot.accept('./components/App', () => { render(App) });} 3) replace `webpack` to `webpack-dev-server` to start bunding: webpack-dev-server Webpack would inject code that starts a WebSocket and responds to file changes. Since it contains many steps, it's highly possible you run into problems setting up Webpack HMR. On Wed, May 17, 2017 at 6:54 PM Thomas Heller <[email protected]> wrote: > The shadow-cljs compiler already does the correct thing when it comes to > macros and recompiles all affected CLJS files. > > It does however know nothing about JS files that may be affected as well > so it would not reload those. I don't know if the webpack HMR will reload > dependent files? > > Does it reload ./index.js if that does require("shadow.cljs/some.foo") and > some.foo was recompiled? > > I have never even seen a HMR config, can you share one so I can try a few > things? > > On Wednesday, May 17, 2017 at 12:48:18 PM UTC+2, Jiyin Yiyong wrote: > > Just realized that ClojureScript is different from CoffeeScript because > of the macro system. If a macro changed, it may cause changes of multiple > files. So that it's hard to just detect which file changed and compiled it > alone. The only window left is to read and compare file content before > writing, if we are trying to get rid of the unnecessary change events... > > > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to a topic in the > Google Groups "ClojureScript" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/clojurescript/AGXku7Ous0Y/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/clojurescript.
