Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@angular-devkit/build-angular): show warning during build when project requires IE 11 support #20225

Merged
merged 2 commits into from Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 26 additions & 13 deletions packages/angular_devkit/build_angular/src/browser/index.ts
Expand Up @@ -7,7 +7,7 @@
*/
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
import { EmittedFiles, WebpackLoggingCallback, runWebpack } from '@angular-devkit/build-webpack';
import { getSystemPath, json, normalize, resolve, tags } from '@angular-devkit/core';
import { getSystemPath, json, logging, normalize, resolve, tags } from '@angular-devkit/core';
import * as fs from 'fs';
import * as path from 'path';
import { Observable, from } from 'rxjs';
Expand Down Expand Up @@ -229,18 +229,7 @@ export function buildWebpackBrowser(
`);
}

const hasIE9 = buildBrowserFeatures.supportedBrowsers.includes('ie 9');
const hasIE10 = buildBrowserFeatures.supportedBrowsers.includes('ie 10');
if (hasIE9 || hasIE10) {
const browsers =
(hasIE9 ? 'IE 9' + (hasIE10 ? ' & ' : '') : '') + (hasIE10 ? 'IE 10' : '');
context.logger.warn(
`Warning: Support was requested for ${browsers} in the project's browserslist configuration. ` +
(hasIE9 && hasIE10 ? 'These browsers are' : 'This browser is') +
' no longer officially supported with Angular v11 and higher.' +
'\nFor additional information: https://v10.angular.io/guide/deprecations#ie-9-10-and-mobile',
);
}
checkInternetExplorerSupport(buildBrowserFeatures.supportedBrowsers, context.logger);

return {
...(await initialize(options, context, isDifferentialLoadingNeeded, transforms.webpackConfiguration)),
Expand Down Expand Up @@ -811,4 +800,28 @@ function mapEmittedFilesToFileInfo(files: EmittedFiles[] = []): FileInfo[] {
return filteredFiles;
}

function checkInternetExplorerSupport(supportedBrowsers: string[], logger: logging.LoggerApi): void {
const hasIE9 = supportedBrowsers.includes('ie 9');
const hasIE10 = supportedBrowsers.includes('ie 10');
const hasIE11 = supportedBrowsers.includes('ie 11');

if (hasIE9 || hasIE10) {
const browsers = (hasIE9 ? 'IE 9' + (hasIE10 ? ' & ' : '') : '') + (hasIE10 ? 'IE 10' : '');
logger.warn(
`Warning: Support was requested for ${browsers} in the project's browserslist configuration. ` +
(hasIE9 && hasIE10 ? 'These browsers are' : 'This browser is') +
' no longer officially supported with Angular v11 and higher.' +
'\nFor more information, see https://v10.angular.io/guide/deprecations#ie-9-10-and-mobile',
);
}

if (hasIE11) {
logger.warn(
`Warning: Support was requested for IE 11 in the project's browserslist configuration. ` +
'IE 11 support is deprecated since Angular v12.' +
'\nFor more information, see https://angular.io/guide/browser-support',
);
}
}

export default createBuilder<json.JsonObject & BrowserBuilderSchema>(buildWebpackBrowser);
3 changes: 2 additions & 1 deletion packages/schematics/angular/application/schema.json
Expand Up @@ -113,7 +113,8 @@
"legacyBrowsers": {
"type": "boolean",
"description": "Add support for legacy browsers like Internet Explorer using differential loading.",
"default": false
"default": false,
"x-deprecated": "Legacy browsers support is deprecated since version 12. For more information, see https://angular.io/guide/browser-support"
}
},
"required": [
Expand Down
3 changes: 2 additions & 1 deletion packages/schematics/angular/ng-new/schema.json
Expand Up @@ -135,7 +135,8 @@
"legacyBrowsers": {
"type": "boolean",
"description": "Add support for legacy browsers like Internet Explorer using differential loading.",
"default": false
"default": false,
"x-deprecated": "Legacy browsers support is deprecated since version 12. For more information, see https://angular.io/guide/browser-support"
},
"packageManager": {
"description": "The package manager used to install dependencies.",
Expand Down