Skip to content

Commit 71eab3d

Browse files
alan-agius4filipesilva
authored andcommitted
feat(@angular-devkit/build-angular): show warning during build when project requires IE 11 support
Internet Explorer 11 support is deprecated and will be removed in future versions of the Angular CLI.
1 parent ba6f546 commit 71eab3d

File tree

1 file changed

+26
-13
lines changed
  • packages/angular_devkit/build_angular/src/browser

1 file changed

+26
-13
lines changed

packages/angular_devkit/build_angular/src/browser/index.ts

+26-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
99
import { EmittedFiles, WebpackLoggingCallback, runWebpack } from '@angular-devkit/build-webpack';
10-
import { getSystemPath, json, normalize, resolve, tags } from '@angular-devkit/core';
10+
import { getSystemPath, json, logging, normalize, resolve, tags } from '@angular-devkit/core';
1111
import * as fs from 'fs';
1212
import * as path from 'path';
1313
import { Observable, from } from 'rxjs';
@@ -229,18 +229,7 @@ export function buildWebpackBrowser(
229229
`);
230230
}
231231

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

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

803+
function checkInternetExplorerSupport(supportedBrowsers: string[], logger: logging.LoggerApi): void {
804+
const hasIE9 = supportedBrowsers.includes('ie 9');
805+
const hasIE10 = supportedBrowsers.includes('ie 10');
806+
const hasIE11 = supportedBrowsers.includes('ie 11');
807+
808+
if (hasIE9 || hasIE10) {
809+
const browsers = (hasIE9 ? 'IE 9' + (hasIE10 ? ' & ' : '') : '') + (hasIE10 ? 'IE 10' : '');
810+
logger.warn(
811+
`Warning: Support was requested for ${browsers} in the project's browserslist configuration. ` +
812+
(hasIE9 && hasIE10 ? 'These browsers are' : 'This browser is') +
813+
' no longer officially supported with Angular v11 and higher.' +
814+
'\nFor more information, see https://v10.angular.io/guide/deprecations#ie-9-10-and-mobile',
815+
);
816+
}
817+
818+
if (hasIE11) {
819+
logger.warn(
820+
`Warning: Support was requested for IE 11 in the project's browserslist configuration. ` +
821+
'IE 11 support is deprecated since Angular v12.' +
822+
'\nFor more information, see https://angular.io/guide/browser-support',
823+
);
824+
}
825+
}
826+
814827
export default createBuilder<json.JsonObject & BrowserBuilderSchema>(buildWebpackBrowser);

0 commit comments

Comments
 (0)