Giter Site home page Giter Site logo

simple-hot-loader's Introduction

simple-hot-loader

This toy project started as an idea for live-reloading Mithril views and controllers (see mithril-example). It is a fork of https://github.com/gaearon/react-hot-loader, which is a stable for daily use in development implementation of React live code editing.

This loader handles some simple cases where live-updating should be pretty trivial. The main use case is updating prototypes, and I'm also toying with updating objects and functions using wrappers.

This loader should allow many elements of the application to be modified while running with minimal reloads of additional components or the entire page. Beyond that, you'll usually want to rerender some bits if you modified a view. Currently that is handled via a simple custom "hotreload" event on the document.

Exceptions

As opposed to react-hot-loader, this loader will process any JS, but trust me, you don't want it on all your JS, particularly node modules and itself. Best to map it to a subset of your JS using a loader matching expression such as the one in example/webpack.config.js.

Source Maps

If you use devtool: 'source-map' (or its equivalent), source maps will be emitted to hide hot reloading code.

This also works when previous loader emits its own source maps.

Running Example

npm install
npm start
open http://localhost:8080/index.html

Then edit example/instanceA.js and example/ClassB.jsx. Your changes should be displayed live, without unmounting components or destroying their state.

Implementation Notes

Simply keep track of the original module.exports and employ a few merge strategies to update it. If there is a prototype property, it is merged using util-extend. Otherwise the original module.exports is updated with properties from the new one. After this, a custom 'hotreload' event is triggered on the document.

Changelog

0.0.0 (so far)

License

MIT (http://www.opensource.org/licenses/mit-license.php)

simple-hot-loader's People

Contributors

chrisdwheatley avatar gaearon avatar kompot avatar syranide avatar tracker1 avatar winstonfassett avatar zachasme avatar

Watchers

 avatar  avatar

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.