Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): warn if using unsupported IE9/10 …
…browsers As of Angular v11, IE9 and IE10 are no longer officially supported. A warning will now be shown during builds if these browsers are requested in the project's browserslist configuration.
- Loading branch information
1 parent
e64ea69
commit cdb404b
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
packages/angular_devkit/build_angular/src/browser/specs/browser-support_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* @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 { Architect } from '@angular-devkit/architect'; | ||
import { logging } from '@angular-devkit/core'; | ||
import { createArchitect, host } from '../../test-utils'; | ||
|
||
describe('Browser Builder browser support', () => { | ||
const targetSpec = { project: 'app', target: 'build' }; | ||
let architect: Architect; | ||
|
||
beforeEach(async () => { | ||
await host.initialize().toPromise(); | ||
architect = (await createArchitect(host.root())).architect; | ||
|
||
// target ES5 to disable differential loading which is not needed for the tests | ||
host.replaceInFile('tsconfig.json', '"target": "es2015"', '"target": "es5"'); | ||
}); | ||
afterEach(async () => host.restore().toPromise()); | ||
|
||
it('warns when IE9 is present in browserslist', async () => { | ||
host.appendToFile('.browserslistrc', '\nIE 9'); | ||
|
||
const logger = new logging.Logger(''); | ||
const logs: string[] = []; | ||
logger.subscribe((e) => logs.push(e.message)); | ||
|
||
const run = await architect.scheduleTarget(targetSpec, undefined, { logger }); | ||
const output = await run.result; | ||
expect(output.success).toBe(true); | ||
|
||
const fullLog = logs.join(); | ||
expect(fullLog).toContain( | ||
"WARNING: Support was requested for IE 9 in the project's browserslist configuration.", | ||
); | ||
expect(fullLog).toContain('This browser is '); | ||
|
||
await run.stop(); | ||
}); | ||
|
||
it('warns when IE10 is present in browserslist', async () => { | ||
host.appendToFile('.browserslistrc', '\nIE 10'); | ||
|
||
const logger = new logging.Logger(''); | ||
const logs: string[] = []; | ||
logger.subscribe((e) => logs.push(e.message)); | ||
|
||
const run = await architect.scheduleTarget(targetSpec, undefined, { logger }); | ||
const output = await run.result; | ||
expect(output.success).toBe(true); | ||
|
||
const fullLog = logs.join(); | ||
expect(fullLog).toContain( | ||
"WARNING: Support was requested for IE 10 in the project's browserslist configuration.", | ||
); | ||
expect(fullLog).toContain('This browser is '); | ||
|
||
await run.stop(); | ||
}); | ||
|
||
it('warns when both IE9 & IE10 are present in browserslist', async () => { | ||
host.appendToFile('.browserslistrc', '\nIE 9-10'); | ||
|
||
const logger = new logging.Logger(''); | ||
const logs: string[] = []; | ||
logger.subscribe((e) => logs.push(e.message)); | ||
|
||
const run = await architect.scheduleTarget(targetSpec, undefined, { logger }); | ||
const output = await run.result; | ||
expect(output.success).toBe(true); | ||
|
||
const fullLog = logs.join(); | ||
expect(fullLog).toContain( | ||
"WARNING: Support was requested for IE 9 & IE 10 in the project's browserslist configuration.", | ||
); | ||
expect(fullLog).toContain('These browsers are '); | ||
|
||
await run.stop(); | ||
}); | ||
}); |