Q:

Angular2 wrapping bootstrap functionality in promise.resolve,

I'm a bit of a js newbie, and I was wondering if someone could explain the benefit of doing this in your angular2 bootstrapping class (I got this from https://github.com/angularclass/angular2-webpack-starter):
export function main(): Promise<any> {
    return platformBrowserDynamic()
    .bootstrapModule(AppModule)
    .then(decorateModuleRef)
    .catch(err => console.error(err));
}

// Ripped this from angularclass/hmr
if (document.readyState === 'complete') {
    main();
} else {
    document.addEventListener('DOMContentLoaded', main);
}

vs just doing platformBrowserDynamic().bootstrapModule(AppModule)
And am I correct in my thinking that the decorateModuleRef code in environment.ts just returns the identity in prod mode, otherwise it calls enableDebugTools on each component reference that it grabs from the injector?
let _decorateModuleRef = function identity<T>(value: T): T { return value; };

if ('build' === process.env.ENV) {
  // Production
  disableDebugTools();
  enableProdMode();

  PROVIDERS = [
    ...PROVIDERS,
    // custom providers in production
  ];

  IMPORTS = [
      ...IMPORTS
  ];

  DECLARATIONS = [
      ...DECLARATIONS
  ];
} else {

  _decorateModuleRef = (modRef: any) => {
    const appRef = modRef.injector.get(ApplicationRef);
    const cmpRef = appRef.components[0];

    let _ng = (<any>window).ng;
    enableDebugTools(cmpRef);
    (<any>window).ng.probe = _ng.probe;
    (<any>window).ng.coreTokens = _ng.coreTokens;
    return modRef;
  };

A:

The main reason that code exists is for helping with Dev and HMR, if you check the AngularClass HMR repo, more exactly here:

Production
In production you only need bootloader which just does this
export function bootloader(main) {
  if (document.readyState === 'complete') {
    main()
  } else {
   document.addEventListener('DOMContentLoaded', main);
  }
}

you would bootstrap your app the normal way, in production, afer dom is ready. Also, in production, you should remove the loader

But why do you need that? The main reason is: 

bootloader is only needed to detect that the dom is ready before
  bootstraping otherwise bootstrap. This is needed because that dom is
  already ready during reloading

So basically when webpack notice a file change it can tell Angular2 to force itself to render again.
if (document.readyState === 'complete') {
    main(); //this will happen when the app is already boostraped and a file was changed.
} else {
    document.addEventListener('DOMContentLoaded', main); //This will happen whenever we open the app for the very first time
}

