Giter Site home page Giter Site logo

Comments (5)

glenjamin avatar glenjamin commented on August 20, 2024 1

I think this thread has demonstrated that there's value in converting to ES6 module syntax for the static parts, to demonstrate the mix - looks like I was wrong in the other PR.

If you fancy sending that change over again @lucascosta I'll get it merged - otherwise I'll try and get around to it myself some time.

Sorry!

from ultimate-hot-reloading-example.

andy-mcdonald avatar andy-mcdonald commented on August 20, 2024 1

Thanks @lucascosta! After a bit of tinkering, I eventually arrived at an almost identical version to yours and now I'm hot-reloading like a champ! I want to add in some bits and pieces like react-router and Immutable.js as well as the ability to load images via webpack and fetch data asynchronously - I'll post the resulting repo if I feel that it adds value to what is already out there.

@glenjamin - I'm not a fan of the CommonJS require / module.exports syntax compared to the ES6 equivalent however, in this case it actually enhances readability by establishing a handy convention that makes it is easy to recognize which parts of the app should be loaded dynamically.

Thanks again to both of you. Happy hot loading!

from ultimate-hot-reloading-example.

glenjamin avatar glenjamin commented on August 20, 2024

As babel compiles ES6 modules into require function calls, I find the simplest way to approach this is to use the require() function in any locations which need to be dynamic.

In this case it is the following two calls:
https://github.com/glenjamin/ultimate-hot-reloading-example/blob/master/server.js#L23
https://github.com/glenjamin/ultimate-hot-reloading-example/blob/master/server.js#L28

Once Node has figured out its ES6 modules story and we know how live bindings will work, this might be doable in a different way.

Making a webpack bundle for the server code is certainly an option, but the goal of this project is explicitly to avoid that, so you'll have to look elsewhere for guidance on how to make that work.

from ultimate-hot-reloading-example.

andy-mcdonald avatar andy-mcdonald commented on August 20, 2024

Cheers for the quick response! Seems that the store and reducers would also need to implement CommonJS-style module.exports since these are also loaded dynamically within the dependency tree for client/render-server.js.

I'll try running the server code through webpack and if that doesn't work cleanly, then I might just hold tight until the HMR landscape settles down a bit.

Thanks again for your help!

from ultimate-hot-reloading-example.

lucasrcosta avatar lucasrcosta commented on August 20, 2024

@andy-mcdonald, I have made the move to ES6 syntax in my fork https://github.com/lucascosta/ultimate-hot-reloading-example, maintaining require where needed for the hot reloading.

from ultimate-hot-reloading-example.

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.