Giter Site home page Giter Site logo

Comments (6)

bdefore avatar bdefore commented on July 28, 2024

@gaearon perhaps you can see what i'm doing wrong here?

from universal-redux.

gaearon avatar gaearon commented on July 28, 2024

Just to clarify.. Webpack analyzes module.hot.accept() calls at compile time. Both require() and module.hot.accept() need to have paths hard-coded there for hot reloading to work (as far as I know). I don't think it works with dynamic paths, no matter what you use to calculate them. Did it work before with dynamic paths for you?

from universal-redux.

bdefore avatar bdefore commented on July 28, 2024

@gaearon i don't think it ever worked with dynamic paths, no. the original didn't need to because all of its reducers lived in a ./modules/index path relative to where the store was created. my situation is somewhat different because i'm configuring webpack to build a bundle from the project root (via contextRoot and some webpack aliases) that includes this library as a dependency and has access to both ./src as well as ./node_modules/universal-redux/src

I've noticed that if I put the following in my setup:

    module.hot.accept('redux/modules/index', function () {
      console.log('replacing reducer in project...');
      store.replaceReducer(require('redux/modules/index'));
    });

    module.hot.accept('./modules/index', function () {
      console.log('replacing reducer in universal-redux...');
      store.replaceReducer(require('./modules/index'));
    });

It will hot reload the modules/test reducer relative to universal-redux, but not the redux/modules/index reducer relative to the project root. The console output after changing both files is:

[HMR] connected
[HMR] bundle rebuilding
[HMR] bundle rebuilt in 458ms
[HMR] Checking for updates on the server...
replacing reducer in universal-redux...
[HMR] Updated modules:
[HMR]  - ./~/universal-redux/lib/redux/modules/index.js
[HMR] App is up to date.
[HMR] bundle rebuilding
[HMR] bundle rebuilt in 498ms
[HMR] Checking for updates on the server...
[HMR] The following modules couldn't be hot updated: (Full reload needed)
[HMR]  - ./src/redux/modules/index.js

It's as if the accept route is not being mapped correctly.

from universal-redux.

bdefore avatar bdefore commented on July 28, 2024

This issue still remains, but I've noticed that it occurs in react-redux-universal-hot-example too, in the same circumstances. I'm not sure I fully understand when a change to a reducer module is 'reloadable', and need to put together some steps that are reproducible. For example, either in universal-redux or in react-redux-universal-hot-example, adding a new property to the initialState appears to fail hot reloading with reducers that have already been initialized.

from universal-redux.

gaearon avatar gaearon commented on July 28, 2024

Please file an issue with DevTools with instructions to reproduce.

from universal-redux.

bdefore avatar bdefore commented on July 28, 2024

The commit that fixed this is here: 436d748

What is not clear to me is why the import of reducers from a webpack alias, even if not used, would itself break hot reloading. All the way from initial client entry to the point where module.hot.accept is assigned, modules are required to be loaded via relative paths, or else modules fail to hot reload.

from universal-redux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.