From 6b4660e83d53598def2f2cda134a6df99af0ef75 Mon Sep 17 00:00:00 2001
From: Charles Lyding <19598772+clydin@users.noreply.github.com>
Date: Mon, 25 Mar 2019 18:45:16 -0400
Subject: [PATCH 1/2] feat(@angular-devkit/build-angular): update to core-js 3
Fixes #13954
---
.../angular_devkit/build_angular/package.json | 2 +-
.../models/es2015-polyfills.js | 22 -----
...-jit-polyfills.js => es5-jit-polyfills.js} | 2 +-
.../angular-cli-files/models/es5-polyfills.js | 94 +++++++++++++++++++
.../angular-cli-files/models/jit-polyfills.js | 2 +-
.../models/webpack-configs/common.ts | 4 +-
.../ng-packaged/projects/lib/src/test.ts | 1 -
.../assets/webpack/test-app-ng5/app/main.ts | 2 +-
.../assets/webpack/test-app-ng5/package.json | 2 +-
.../not/so/source/app/main.jit.ts | 2 +-
.../webpack/test-app-weird-ng5/package.json | 2 +-
.../webpack/test-server-app-ng5/app/main.ts | 2 +-
.../webpack/test-server-app-ng5/package.json | 2 +-
tests/legacy-cli/e2e/tests/build/polyfills.ts | 4 +-
.../e2e/tests/packages/webpack/test-ng5.ts | 6 +-
yarn.lock | 7 +-
16 files changed, 116 insertions(+), 40 deletions(-)
delete mode 100644 packages/angular_devkit/build_angular/src/angular-cli-files/models/es2015-polyfills.js
rename packages/angular_devkit/build_angular/src/angular-cli-files/models/{es2015-jit-polyfills.js => es5-jit-polyfills.js} (87%)
create mode 100644 packages/angular_devkit/build_angular/src/angular-cli-files/models/es5-polyfills.js
diff --git a/packages/angular_devkit/build_angular/package.json b/packages/angular_devkit/build_angular/package.json
index 7195f774e6df..a29b7bf990ee 100644
--- a/packages/angular_devkit/build_angular/package.json
+++ b/packages/angular_devkit/build_angular/package.json
@@ -17,6 +17,7 @@
"circular-dependency-plugin": "5.0.2",
"clean-css": "4.2.1",
"copy-webpack-plugin": "5.0.2",
+ "core-js": "3.0.0",
"file-loader": "3.0.1",
"glob": "7.1.3",
"istanbul-instrumenter-loader": "3.0.1",
@@ -69,7 +70,6 @@
"@angular/router": "^8.0.0-beta.10",
"@angular/service-worker": "^8.0.0-beta.10",
"codelyzer": "^5.0.0",
- "core-js": "^2.4.1",
"bootstrap": "^4.0.0",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/models/es2015-polyfills.js b/packages/angular_devkit/build_angular/src/angular-cli-files/models/es2015-polyfills.js
deleted file mode 100644
index 354326535a52..000000000000
--- a/packages/angular_devkit/build_angular/src/angular-cli-files/models/es2015-polyfills.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
-import 'core-js/es6/symbol';
-import 'core-js/es6/object';
-import 'core-js/es6/function';
-import 'core-js/es6/parse-int';
-import 'core-js/es6/parse-float';
-import 'core-js/es6/number';
-import 'core-js/es6/math';
-import 'core-js/es6/string';
-import 'core-js/es6/date';
-import 'core-js/es6/array';
-import 'core-js/es6/regexp';
-import 'core-js/es6/map';
-import 'core-js/es6/weak-map';
-import 'core-js/es6/set';
-import 'core-js/es6/promise';
\ No newline at end of file
diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/models/es2015-jit-polyfills.js b/packages/angular_devkit/build_angular/src/angular-cli-files/models/es5-jit-polyfills.js
similarity index 87%
rename from packages/angular_devkit/build_angular/src/angular-cli-files/models/es2015-jit-polyfills.js
rename to packages/angular_devkit/build_angular/src/angular-cli-files/models/es5-jit-polyfills.js
index 0e68685db11f..febcbb5329c9 100644
--- a/packages/angular_devkit/build_angular/src/angular-cli-files/models/es2015-jit-polyfills.js
+++ b/packages/angular_devkit/build_angular/src/angular-cli-files/models/es5-jit-polyfills.js
@@ -5,4 +5,4 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
-import 'core-js/es6/reflect';
+import 'core-js/es/reflect';
diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/models/es5-polyfills.js b/packages/angular_devkit/build_angular/src/angular-cli-files/models/es5-polyfills.js
new file mode 100644
index 000000000000..2df88d889937
--- /dev/null
+++ b/packages/angular_devkit/build_angular/src/angular-cli-files/models/es5-polyfills.js
@@ -0,0 +1,94 @@
+/**
+ * @license
+ * Copyright Google Inc. All Rights Reserved.
+ *
+ * Use of this source code is governed by an MIT-style license that can be
+ * found in the LICENSE file at https://angular.io/license
+ */
+
+ // ES2015 symbol capabilities
+import 'core-js/modules/es.symbol';
+
+// ES2015 function capabilities
+import 'core-js/modules/es.function.bind';
+import 'core-js/modules/es.function.name';
+import 'core-js/modules/es.function.has-instance';
+
+// ES2015 object capabilities
+import 'core-js/modules/es.object.create';
+import 'core-js/modules/es.object.define-property';
+import 'core-js/modules/es.object.define-properties';
+import 'core-js/modules/es.object.get-own-property-descriptor';
+import 'core-js/modules/es.object.get-prototype-of';
+import 'core-js/modules/es.object.keys';
+import 'core-js/modules/es.object.get-own-property-names';
+import 'core-js/modules/es.object.freeze';
+import 'core-js/modules/es.object.seal';
+import 'core-js/modules/es.object.prevent-extensions';
+import 'core-js/modules/es.object.is-frozen';
+import 'core-js/modules/es.object.is-sealed';
+import 'core-js/modules/es.object.is-extensible';
+import 'core-js/modules/es.object.assign';
+import 'core-js/modules/es.object.is';
+import 'core-js/modules/es.object.set-prototype-of';
+import 'core-js/modules/es.object.to-string';
+
+// ES2015 array capabilities
+import 'core-js/modules/es.array.is-array';
+import 'core-js/modules/es.array.from';
+import 'core-js/modules/es.array.of';
+import 'core-js/modules/es.array.join';
+import 'core-js/modules/es.array.slice';
+import 'core-js/modules/es.array.sort';
+import 'core-js/modules/es.array.for-each';
+import 'core-js/modules/es.array.map';
+import 'core-js/modules/es.array.filter';
+import 'core-js/modules/es.array.some';
+import 'core-js/modules/es.array.every';
+import 'core-js/modules/es.array.reduce';
+import 'core-js/modules/es.array.reduce-right';
+import 'core-js/modules/es.array.index-of';
+import 'core-js/modules/es.array.last-index-of';
+import 'core-js/modules/es.array.copy-within';
+import 'core-js/modules/es.array.fill';
+import 'core-js/modules/es.array.find';
+import 'core-js/modules/es.array.find-index';
+import 'core-js/modules/es.array.iterator';
+
+// ES2015 string capabilities
+import 'core-js/modules/es.string.from-code-point';
+import 'core-js/modules/es.string.raw';
+import 'core-js/modules/es.string.trim';
+import 'core-js/modules/es.string.iterator';
+import 'core-js/modules/es.string.code-point-at';
+import 'core-js/modules/es.string.ends-with';
+import 'core-js/modules/es.string.includes';
+import 'core-js/modules/es.string.repeat';
+import 'core-js/modules/es.string.starts-with';
+import 'core-js/modules/es.string.anchor';
+import 'core-js/modules/es.string.big';
+import 'core-js/modules/es.string.blink';
+import 'core-js/modules/es.string.bold';
+import 'core-js/modules/es.string.fixed';
+import 'core-js/modules/es.string.fontcolor';
+import 'core-js/modules/es.string.fontsize';
+import 'core-js/modules/es.string.italics';
+import 'core-js/modules/es.string.link';
+import 'core-js/modules/es.string.small';
+import 'core-js/modules/es.string.strike';
+import 'core-js/modules/es.string.sub';
+import 'core-js/modules/es.string.sup';
+
+import 'core-js/modules/es.parse-int';
+import 'core-js/modules/es.parse-float';
+
+import 'core-js/es/number';
+import 'core-js/es/math';
+import 'core-js/es/date';
+import 'core-js/es/regexp';
+
+import 'core-js/modules/es.map';
+import 'core-js/modules/es.weak-map';
+import 'core-js/modules/es.set';
+import 'core-js/modules/web.dom-collections.iterator';
+import 'core-js/modules/es.promise';
diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/models/jit-polyfills.js b/packages/angular_devkit/build_angular/src/angular-cli-files/models/jit-polyfills.js
index 624a54706810..b57ee9bd423a 100644
--- a/packages/angular_devkit/build_angular/src/angular-cli-files/models/jit-polyfills.js
+++ b/packages/angular_devkit/build_angular/src/angular-cli-files/models/jit-polyfills.js
@@ -5,4 +5,4 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
-import 'core-js/es7/reflect';
+import 'core-js/proposals/reflect-metadata';
diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts b/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts
index a9c03738a641..d9cfd69b5043 100644
--- a/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts
+++ b/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts
@@ -60,7 +60,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
}
if (buildOptions.es5BrowserSupport) {
- entryPoints['polyfills.es5'] = [path.join(__dirname, '..', 'es2015-polyfills.js')];
+ entryPoints['polyfills.es5'] = [path.join(__dirname, '..', 'es5-polyfills.js')];
}
if (buildOptions.polyfills) {
@@ -76,7 +76,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
if (buildOptions.es5BrowserSupport) {
entryPoints['polyfills.es5'] = [
...entryPoints['polyfills.es5'],
- path.join(__dirname, '..', 'es2015-jit-polyfills.js'),
+ path.join(__dirname, '..', 'es5-jit-polyfills.js'),
];
}
}
diff --git a/tests/angular_devkit/build_ng_packagr/ng-packaged/projects/lib/src/test.ts b/tests/angular_devkit/build_ng_packagr/ng-packaged/projects/lib/src/test.ts
index 7f7cc44356b5..07d460969f3b 100644
--- a/tests/angular_devkit/build_ng_packagr/ng-packaged/projects/lib/src/test.ts
+++ b/tests/angular_devkit/build_ng_packagr/ng-packaged/projects/lib/src/test.ts
@@ -7,7 +7,6 @@
*/
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
-import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
diff --git a/tests/legacy-cli/e2e/assets/webpack/test-app-ng5/app/main.ts b/tests/legacy-cli/e2e/assets/webpack/test-app-ng5/app/main.ts
index 0a705a5daebb..a2a7a6c6b76c 100644
--- a/tests/legacy-cli/e2e/assets/webpack/test-app-ng5/app/main.ts
+++ b/tests/legacy-cli/e2e/assets/webpack/test-app-ng5/app/main.ts
@@ -1,4 +1,4 @@
-import 'core-js/es7/reflect';
+import 'core-js/proposals/reflect-metadata';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app.module';
diff --git a/tests/legacy-cli/e2e/assets/webpack/test-app-ng5/package.json b/tests/legacy-cli/e2e/assets/webpack/test-app-ng5/package.json
index 558c7d047703..e5078904a00a 100644
--- a/tests/legacy-cli/e2e/assets/webpack/test-app-ng5/package.json
+++ b/tests/legacy-cli/e2e/assets/webpack/test-app-ng5/package.json
@@ -12,7 +12,7 @@
"@angular/platform-server": "^5.0.0-rc.8",
"@angular/router": "^5.0.0-rc.8",
"@ngtools/webpack": "0.0.0",
- "core-js": "^2.4.1",
+ "core-js": "^3.0.0",
"rxjs": "^5.5.0",
"zone.js": "^0.8.14"
},
diff --git a/tests/legacy-cli/e2e/assets/webpack/test-app-weird-ng5/not/so/source/app/main.jit.ts b/tests/legacy-cli/e2e/assets/webpack/test-app-weird-ng5/not/so/source/app/main.jit.ts
index 0a705a5daebb..a2a7a6c6b76c 100644
--- a/tests/legacy-cli/e2e/assets/webpack/test-app-weird-ng5/not/so/source/app/main.jit.ts
+++ b/tests/legacy-cli/e2e/assets/webpack/test-app-weird-ng5/not/so/source/app/main.jit.ts
@@ -1,4 +1,4 @@
-import 'core-js/es7/reflect';
+import 'core-js/proposals/reflect-metadata';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app.module';
diff --git a/tests/legacy-cli/e2e/assets/webpack/test-app-weird-ng5/package.json b/tests/legacy-cli/e2e/assets/webpack/test-app-weird-ng5/package.json
index 4a2637e90a24..f15ed005a3de 100644
--- a/tests/legacy-cli/e2e/assets/webpack/test-app-weird-ng5/package.json
+++ b/tests/legacy-cli/e2e/assets/webpack/test-app-weird-ng5/package.json
@@ -12,7 +12,7 @@
"@angular/platform-server": "^5.0.0-rc.8",
"@angular/router": "^5.0.0-rc.8",
"@ngtools/webpack": "0.0.0",
- "core-js": "^2.4.1",
+ "core-js": "^3.0.0",
"rxjs": "^5.5.0",
"zone.js": "^0.8.14"
},
diff --git a/tests/legacy-cli/e2e/assets/webpack/test-server-app-ng5/app/main.ts b/tests/legacy-cli/e2e/assets/webpack/test-server-app-ng5/app/main.ts
index 5d57aafca8ae..647681b8b76c 100644
--- a/tests/legacy-cli/e2e/assets/webpack/test-server-app-ng5/app/main.ts
+++ b/tests/legacy-cli/e2e/assets/webpack/test-server-app-ng5/app/main.ts
@@ -1,4 +1,4 @@
-import 'core-js/es7/reflect';
+import 'core-js/proposals/reflect-metadata';
import {platformDynamicServer, renderModule} from '@angular/platform-server';
import {AppModule} from './app.module';
diff --git a/tests/legacy-cli/e2e/assets/webpack/test-server-app-ng5/package.json b/tests/legacy-cli/e2e/assets/webpack/test-server-app-ng5/package.json
index 96368897352a..003d0506fe8f 100644
--- a/tests/legacy-cli/e2e/assets/webpack/test-server-app-ng5/package.json
+++ b/tests/legacy-cli/e2e/assets/webpack/test-server-app-ng5/package.json
@@ -13,7 +13,7 @@
"@angular/platform-server": "^5.0.0",
"@angular/router": "^5.0.0",
"@ngtools/webpack": "0.0.0",
- "core-js": "^2.4.1",
+ "core-js": "^3.0.0",
"rxjs": "^5.4.2",
"zone.js": "^0.8.14"
},
diff --git a/tests/legacy-cli/e2e/tests/build/polyfills.ts b/tests/legacy-cli/e2e/tests/build/polyfills.ts
index c1ef73372bb7..d2a7b85bb3f3 100644
--- a/tests/legacy-cli/e2e/tests/build/polyfills.ts
+++ b/tests/legacy-cli/e2e/tests/build/polyfills.ts
@@ -11,7 +11,7 @@ import { expectToFail } from '../../utils/utils';
export default async function () {
await ng('build');
// files were created successfully
- await expectFileToMatch('dist/test-project/polyfills.js', 'core-js/es7/reflect');
+ await expectFileToMatch('dist/test-project/polyfills.js', 'core-js/proposals/reflect-metadata');
await expectFileToMatch('dist/test-project/polyfills.js', 'zone.js');
expectFileToMatch('dist/test-project/index.html', oneLineTrim`
@@ -24,7 +24,7 @@ export default async function () {
// files were created successfully
await expectFileToExist('dist/test-project/polyfills.js');
await expectFileSizeToBeUnder('dist/test-project/polyfills.js', jitPolyfillSize);
- await expectToFail(() => expectFileToMatch('dist/test-project/polyfills.js', 'core-js/es7/reflect'));
+ await expectToFail(() => expectFileToMatch('dist/test-project/polyfills.js', 'core-js/proposals/reflect-metadata'));
await expectFileToMatch('dist/test-project/polyfills.js', 'zone.js');
expectFileToMatch('dist/test-project/index.html', oneLineTrim`
diff --git a/tests/legacy-cli/e2e/tests/packages/webpack/test-ng5.ts b/tests/legacy-cli/e2e/tests/packages/webpack/test-ng5.ts
index 3b8dc3b903a7..f30d5fa250c2 100644
--- a/tests/legacy-cli/e2e/tests/packages/webpack/test-ng5.ts
+++ b/tests/legacy-cli/e2e/tests/packages/webpack/test-ng5.ts
@@ -8,9 +8,9 @@ export default function(skipCleaning: () => void) {
return Promise.resolve()
.then(() => createProjectFromAsset('webpack/test-app-ng5'))
.then(() => exec(normalize('node_modules/.bin/webpack-cli')))
- .then(() => expectFileSizeToBeUnder('dist/app.main.js', 375000))
- .then(() => expectFileSizeToBeUnder('dist/0.app.main.js', 25000))
- .then(() => expectFileSizeToBeUnder('dist/1.app.main.js', 2000))
+ .then(() => expectFileSizeToBeUnder('dist/app.main.js', 375 * 1024))
+ .then(() => expectFileSizeToBeUnder('dist/0.app.main.js', 25 * 1024))
+ .then(() => expectFileSizeToBeUnder('dist/1.app.main.js', 2 * 1024))
// test resource urls without ./
.then(() => replaceInFile('app/app.component.ts',
'./app.component.html', 'app.component.html'))
diff --git a/yarn.lock b/yarn.lock
index aa3afddc7554..5c0112f15677 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2484,7 +2484,12 @@ copy-webpack-plugin@5.0.2:
serialize-javascript "^1.4.0"
webpack-log "^2.0.0"
-core-js@^2.2.0, core-js@^2.4.0, core-js@^2.4.1:
+core-js@3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.0.0.tgz#a8dbfa978d29bfc263bfb66c556d0ca924c28957"
+ integrity sha512-WBmxlgH2122EzEJ6GH8o9L/FeoUKxxxZ6q6VUxoTlsE4EvbTWKJb447eyVxTEuq0LpXjlq/kCB2qgBvsYRkLvQ==
+
+core-js@^2.2.0, core-js@^2.4.0:
version "2.5.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e"
integrity sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==
From ffb48ad98d0ec4622673236c026609f2f61adc62 Mon Sep 17 00:00:00 2001
From: Charles Lyding <19598772+clydin@users.noreply.github.com>
Date: Mon, 25 Mar 2019 18:46:21 -0400
Subject: [PATCH 2/2] fix(@schematics/angular): remove unused core-js
dependency from new projects
Required polyfills are now managed directly by the build system. If additional polyfills are required, packages can be manually added as needed.
---
packages/schematics/angular/library/files/src/test.ts.template | 1 -
.../schematics/angular/workspace/files/package.json.template | 1 -
2 files changed, 2 deletions(-)
diff --git a/packages/schematics/angular/library/files/src/test.ts.template b/packages/schematics/angular/library/files/src/test.ts.template
index e11ff1c97b82..978c64fb83f4 100644
--- a/packages/schematics/angular/library/files/src/test.ts.template
+++ b/packages/schematics/angular/library/files/src/test.ts.template
@@ -1,6 +1,5 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
-import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
diff --git a/packages/schematics/angular/workspace/files/package.json.template b/packages/schematics/angular/workspace/files/package.json.template
index efa062d7908e..35afff10fc40 100644
--- a/packages/schematics/angular/workspace/files/package.json.template
+++ b/packages/schematics/angular/workspace/files/package.json.template
@@ -19,7 +19,6 @@
"@angular/platform-browser": "<%= latestVersions.Angular %>",
"@angular/platform-browser-dynamic": "<%= latestVersions.Angular %>",
"@angular/router": "<%= latestVersions.Angular %>",
- "core-js": "^2.5.4",
"rxjs": "<%= latestVersions.RxJs %>",
"tslib": "<%= latestVersions.TsLib %>",
"zone.js": "<%= latestVersions.ZoneJs %>"