PatrickJS / angular-hmr

:fire: Angular Hot Module Replacement for Hot Module Reloading
https://patrickjs.com
Apache License 2.0
506 stars 45 forks source link

What's best practice to tell from development and production #22

Closed elaijuh closed 8 years ago

elaijuh commented 8 years ago

So definitely I don't want HMR in production running, do I need to manually check the environment and then decide if to use this module or not?

Should I do this ?

if (<any>module.hot) { 
  // go HMR way
} else {
  // go normal bootstrap way
}
PatrickJS commented 8 years ago

don't include the loader in production and the only thing you need from this lib is bootloader but you can remove that and bootstrap the normal way after the dom is ready

       {
          test: /\.ts$/,
          loaders: [
            'awesome-typescript-loader',
          ].concat(prod ? [] : '@angularclass/hmr-loader')
        },
elaijuh commented 8 years ago

well in this way, i still have things like hrmOnInit, hmrOnDestroy in my source code.

PatrickJS commented 8 years ago

I could update @angularclass/hmr-loader to strip out the methods in prod mode that way you need to include the loader in prod. The methods won't be called at all without the loader

elaijuh commented 8 years ago

ok i think just let the those code in my source code, thanks

PatrickJS commented 8 years ago

I updated the loader to allow switching to prod mode here's an example https://github.com/AngularClass/angular2-seed/blob/c139cbd9c279cd3c2864b7d9ad9f119c1d8f5b32/webpack.config.ts#L80