From 47c72e46272605c840bef7c477119996b1a8c033 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 15 May 2017 18:44:07 -0700 Subject: [PATCH] perf(aio): load reflect-metadata polyfill only in the dev mode --- aio/src/environments/environment.ts | 9 +++++++++ aio/src/polyfills.ts | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/aio/src/environments/environment.ts b/aio/src/environments/environment.ts index 69c1f7c8bd..165a718f55 100644 --- a/aio/src/environments/environment.ts +++ b/aio/src/environments/environment.ts @@ -3,6 +3,15 @@ // `ng build --env=prod` then `environment.prod.ts` will be used instead. // The list of which env maps to which file can be found in `angular-cli.json`. + +// Reflect.metadata polyfill is only needed in the JIT/dev mode. +// +// In order to load these polyfills early enough (before app code), polyfill.ts imports this file to +// to change the order in the final bundle. +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; + + export const environment = { gaId: 'UA-8594346-26', // Staging site production: false diff --git a/aio/src/polyfills.ts b/aio/src/polyfills.ts index 53bdaf1b86..1e6698d216 100644 --- a/aio/src/polyfills.ts +++ b/aio/src/polyfills.ts @@ -40,9 +40,8 @@ // import 'web-animations-js'; // Run `npm install --save web-animations-js`. -/** Evergreen browsers require these. **/ -import 'core-js/es6/reflect'; -import 'core-js/es7/reflect'; +/** HACK: force import of environment.ts/environment.prod.ts to load env specific polyfills */ +import './environments/environment'; /** ALL Firefox browsers require the following to support `@angular/animation`. **/