Skip to content

Commit

Permalink
refactor(@angular-devkit/build-angular): drop support for zone.js 0.10
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

Minimum supported `zone.js` version is `0.11.4`
  • Loading branch information
alan-agius4 authored and filipesilva committed Feb 17, 2021
1 parent bb38f85 commit f309516
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 33 deletions.
2 changes: 1 addition & 1 deletion integration/angular_cli/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export const environment = {
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
2 changes: 1 addition & 1 deletion integration/angular_cli/src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
import 'zone.js'; // Included with Angular CLI.


/***************************************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion integration/angular_cli/src/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import 'zone.js/dist/zone-testing';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,9 @@ describe('Browser Builder with differential loading', () => {

it('uses the right zone.js variant', async () => {
const { files } = await browserBuild(architect, host, target, { optimization: false });
expect(await files['polyfills-es5.js']).toContain('zone.js/dist/zone-legacy');
expect(await files['polyfills-es5.js']).toContain('zone.js/plugins/zone-legacy');
expect(await files['polyfills-es5.js']).toContain('registerElementPatch');
expect(await files['polyfills-es5.js']).toContain('zone.js/dist/zone-evergreen');
expect(await files['polyfills-es2015.js']).toContain('zone.js/dist/zone-evergreen');
expect(await files['polyfills-es2015.js']).not.toContain('zone.js/dist/zone-legacy');
expect(await files['polyfills-es2015.js']).not.toContain('zone.js/plugins/zone-legacy');
expect(await files['polyfills-es2015.js']).not.toContain('registerElementPatch');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,6 @@ export async function generateWebpackConfig(

const webpackConfig = webpackMerge(webpackPartialGenerator(wco));

if (supportES2015) {
if (!webpackConfig.resolve) {
webpackConfig.resolve = {};
}
if (Array.isArray(webpackConfig.resolve.alias)) {
webpackConfig.resolve.alias.push({
alias: 'zone.js/dist/zone',
name: 'zone.js/dist/zone-evergreen',
});
} else {
if (!webpackConfig.resolve.alias) {
webpackConfig.resolve.alias = {};
}
webpackConfig.resolve.alias['zone.js/dist/zone'] = 'zone.js/dist/zone-evergreen';
}
}

if (profilingEnabled) {
const esVersionInFileName = getEsVersionForFileName(
tsConfig.options.target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
if (buildBrowserFeatures.isEs5SupportNeeded()) {
const polyfillsChunkName = 'polyfills-es5';
entryPoints[polyfillsChunkName] = [path.join(__dirname, '..', 'es5-polyfills.js')];
if (differentialLoadingMode) {
// Add zone.js legacy support to the es5 polyfills
// This is a noop execution-wise if zone-evergreen is not used.
entryPoints[polyfillsChunkName].push('zone.js/dist/zone-legacy');

if (differentialLoadingMode) {
// Since the chunkFileName option schema does not allow the function overload, add a plugin
// that changes the name of the ES5 polyfills chunk to not include ES2015.
extraPlugins.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,7 @@ import 'core-js/modules/web.dom-collections.iterator';
import 'core-js/modules/es.promise';
import 'core-js/modules/es.json.to-string-tag';

import 'regenerator-runtime/runtime';
import 'regenerator-runtime/runtime';

// Zone.js
import 'zone.js/plugins/zone-legacy';
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import '@angular/localize/init';
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
import 'zone.js'; // Included with Angular CLI.

/***************************************************************************************************
* APPLICATION IMPORTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import 'zone.js/dist/zone-testing';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import 'zone.js/dist/zone';
import 'zone.js/dist/zone-testing';
import 'zone.js';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
Expand Down

0 comments on commit f309516

Please sign in to comment.