Skip to content

Commit 30f8352

Browse files
clydinvikerman
authored andcommitted
feat(@angular-devkit/build-angular): automatically include reflect metadata polyfill for JIT
The reflect metadata polyfill is only required by Angular when using JIT. Since it is unanticipated it would be needed when using AOT, including it when using AOT only serves to unnecessarily increase application file sizes. JIT is not recommended for production use. However, if an application uses JIT in production and an alternate reflect metadata polyfill is preferred (core-js/es7/reflect is currently used), then TypeScript path mapping can be used to override the polyfill. As an example, the following will allow the usage of the `reflect-metadata` package in lieu of the default: ``` "paths": { "core-js/es7/reflect": ["node_modules/reflect-metadata"] } ```
1 parent 1b268b2 commit 30f8352

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import 'core-js/es7/reflect';

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
6262
entryPoints['polyfills'] = [path.resolve(root, buildOptions.polyfills)];
6363
}
6464

65+
if (!buildOptions.aot) {
66+
entryPoints['polyfills'] = [
67+
...(entryPoints['polyfills'] || []),
68+
path.join(__dirname, '..', 'jit-polyfills.js'),
69+
];
70+
}
71+
6572
// determine hashing format
6673
const hashFormat = getOutputHashFormat(buildOptions.outputHashing as any);
6774

0 commit comments

Comments
 (0)