Git Product home page Git Product logo

angular-hmr's Introduction

Angular HMR

Join the chat at https://gitter.im/yargalot/Angular-HMR

A (very alpha version) Webpack loader for Hot Module Replacement in Angular applications.

This will only work in Ui Router at the moment with a specific app structure shown below. Will work on it a bit more over the week.

Throwing up a sample app up at https://github.com/yargalot/Angular-HMR-Example

How it works

This will inject the new controller / template then reload the state in UI Router

Say your structure was all like

angular
  .module('app.components')
  .directive('sessionItem',function() {
    return {
        restrict : 'E',
        scope: {
            session: '='
        },
        bindToController: true,
        controllerAs: 'state',
        replace: true,
        controller: 'sessionItemCtrl',
        template: require('./template.html')
    };
  })
  .factory('TestFactory', function() {
    console.log('derp');
  })
  .controller('sessionItemCtrl', require('./sessionItemCtrl'));

and you save that the browser should refresh

NOTE

This is pulled from https://github.com/jeroenverfallie/angular-hmr-loader and https://github.com/bitsoflove/jsconfbe-2015

Just more developing on top of that idea. Would feel bad for not mentioning that

angular-hmr's People

Contributors

gitter-badger avatar xbill82 avatar yargalot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-hmr's Issues

[HMR] TypeError: Cannot read property 'has' of undefined

I tried to apply the angular-HMR to the existing project and got this error:

[HMR] TypeError: Cannot read property 'has' of undefined
at HotAngular.reloadState (http://localhost:8080/assets/style-guide.js:61911:26)
at module.exports as directive
at Object. (http://localhost:8080/assets/style-guide.js:67077:63)
at webpack_require (http://localhost:8080/assets/style-guide.js:521:30)
at hotApply (http://localhost:8080/assets/style-guide.js:476:14)
at hotUpdateDownloaded (http://localhost:8080/assets/style-guide.js:269:13)
at hotAddUpdateChunk (http://localhost:8080/assets/style-guide.js:249:13)
at webpackHotUpdateCallback (http://localhost:8080/assets/style-guide.js:5:12)
at http://localhost:8080/assets/0.b36e9a53c6b398f686b1.hot-update.js:1:1

Any advices, or is it a bug? The library seems to understand the angular directives and logs them into console, so i guess there is just a small bug somewhere.

Infinite call loop while hot updating controller

Hi, I've just set this project up with Angular HMR.

As a side note, since the example calls the global Angular variable Angular instead of angular, I had to change the angularModule regexp in angular-hmr/index.js to accept this variable name

var angularModule= /[aA]ngular[\.\n ]+module\(([\'\"\w\.\/\(\)\n\-\,\[\] ]+)\)/g;

BTW, should we address this case in another issue?

So, when I try to hot update a controller (e.g. page3Controller.js), I get no hot reload and the following error Uncaught RangeError: Maximum call stack size exceeded. The infinitely-called function is hotAddUpdateChunk.

Rename to angular-hmr-loader

All other webpack loaders follow the naming convention of

<name-of-loader>-loader

Rename this project to "angular-hmr-loader" for two reasons:

  1. Consistency
  2. Quick recognition that this is a Webpack loader without having to read the readme or look at the example project

Readme needs some refreshing

  • NPM badge
  • Better explanation of what this is (reference to Dan Abramov's talk at React Europe?)
  • A getting started section (npm, webpack config, link to the example)
  • A TODO section (missing features and call for contributions)

Once this is done, I'd suggest tweeting.

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.