Giter Club home page Giter Club logo

Comments (15)

vlazh avatar vlazh commented on May 24, 2024 1

@aspirisen, take a look at autoRestart. Maybe it will usefull for you.
While I close the issue.

from node-hot-loader.

vlazh avatar vlazh commented on May 24, 2024

Adding code to entry file (where you starting server) may help:

  if (module.hot) {
    // For reload main module (self). It will restart server.
    module.hot.accept((err: Error) => console.error('Hot accept error:', err));
    module.hot.dispose(() => {
      console.log('Disposing entry module...');
      // ... other stuff
    });
  }

But if webpack HMR state is broken you should restart process manually at the moment.

from node-hot-loader.

aspirisen avatar aspirisen commented on May 24, 2024

The problem is that in case of 'module.hot.dispose' the global object is the same, i need full reload, how to indicate it?

from node-hot-loader.

vlazh avatar vlazh commented on May 24, 2024

It's just disposer callback: clear resources, close connections, etc. In 'module.hot.dispose' you steel have old state of all objects in current module. The global var is the same may be because a node process is not restarted (just hot reloaded some modules, but global scope is not changed). It seems to be how the webpack does its job.

from node-hot-loader.

aspirisen avatar aspirisen commented on May 24, 2024

Yes, and i am looking for a way how to tell node-hot-loader to do full reload instead of manually i.e. close terminal and open once again

from node-hot-loader.

vlazh avatar vlazh commented on May 24, 2024

There is no such feature. May be you don't need hor reload If you need new global scope? May be nodemon it's your choise. Or you should restore global scope manually in dispose callback.

from node-hot-loader.

aspirisen avatar aspirisen commented on May 24, 2024

In general HMR works for me, except updating several files because they are depended on global object.

from node-hot-loader.

vlazh avatar vlazh commented on May 24, 2024

You may add dispose to these files and restore global object as you need.

from node-hot-loader.

vlazh avatar vlazh commented on May 24, 2024

It's difficult to discuss without concrete example.

from node-hot-loader.

aspirisen avatar aspirisen commented on May 24, 2024

There is a third party library which provides decorators and this library uses global object to store decorators' data. This library is in node_modules so hmr doesn't affect it, change or reset global object i can't because the behavior becomes unpredictable, it would be good to have fallback option to reload the whole bundle

from node-hot-loader.

vlazh avatar vlazh commented on May 24, 2024

Try to add a whatcher (nodemod, webpack plugin or something else) for these files and restart whole process.

from node-hot-loader.

aspirisen avatar aspirisen commented on May 24, 2024

Ok, could you tell how to restart the process from bundle script?

from node-hot-loader.

vlazh avatar vlazh commented on May 24, 2024

process.exit and the same way you start it.
Stack overflow can help you.

from node-hot-loader.

aspirisen avatar aspirisen commented on May 24, 2024

Why not to add this feature to 'node-hot-loader' as i remember i.e. hmr will reload browser page in case of emergency

from node-hot-loader.

vlazh avatar vlazh commented on May 24, 2024

PR welcome! )

from node-hot-loader.

Related Issues (18)

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.