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

Check for `process` in `hmr-decorator.ts` fails when used in browsers #4

Closed jffry closed 8 years ago

jffry commented 8 years ago

When angular2-hmr is used on the client-side (as it is in https://github.com/AngularClass/angular2-webpack-starter), the code looking for process in https://github.com/gdi2290/angular2-hmr/blob/75ec097/src/hmr-decorator.ts#L5 causes an exception to be thrown in the browser:

Uncaught ReferenceError: process is not defined (hmr-decorator.ts:5)

This is causing this issue: https://github.com/AngularClass/angular2-webpack-starter/issues/491

The check for process could be pretty easily be made to fail gracefully if process is not defined, for example:

const _env = typeof process !== 'undefined' &&
  (process &&
  process.env &&
  process.env.ENV ||
  process.env.NODE_ENV);
PatrickJS commented 8 years ago

thanks! done via https://github.com/gdi2290/angular2-hmr/commit/55bdee0d9799430d3d244195a50d31514f4d13cb