@@ -18,13 +18,15 @@ import {
1818 logging ,
1919 normalize ,
2020 resolve ,
21+ tags ,
2122 virtualFs ,
2223} from '@angular-devkit/core' ;
2324import { NodeJsSyncHost } from '@angular-devkit/core/node' ;
2425import * as fs from 'fs' ;
2526import * as path from 'path' ;
26- import { concat , from , of , zip } from 'rxjs' ;
27+ import { from , of } from 'rxjs' ;
2728import { bufferCount , catchError , concatMap , map , mergeScan , switchMap } from 'rxjs/operators' ;
29+ import * as ts from 'typescript' ;
2830import * as webpack from 'webpack' ;
2931import { NgBuildAnalyticsPlugin } from '../../plugins/webpack/analytics' ;
3032import { WebpackConfigOptions } from '../angular-cli-files/models/build-options' ;
@@ -38,14 +40,15 @@ import {
3840 getWorkerConfig ,
3941} from '../angular-cli-files/models/webpack-configs' ;
4042import { writeIndexHtml } from '../angular-cli-files/utilities/index-file/write-index-html' ;
43+ import { readTsconfig } from '../angular-cli-files/utilities/read-tsconfig' ;
4144import { augmentAppWithServiceWorker } from '../angular-cli-files/utilities/service-worker' ;
4245import {
4346 statsErrorsToString ,
4447 statsToString ,
4548 statsWarningsToString ,
4649} from '../angular-cli-files/utilities/stats' ;
4750import { ExecutionTransformer } from '../transforms' ;
48- import { deleteOutputDir } from '../utils' ;
51+ import { deleteOutputDir , isEs5SupportNeeded } from '../utils' ;
4952import { generateBrowserWebpackConfigFromContext } from '../utils/webpack-browser-config' ;
5053import { Schema as BrowserBuilderSchema } from './schema' ;
5154
@@ -182,6 +185,19 @@ export function buildWebpackBrowser(
182185 normalize ( workspace . getProject ( projectName ) . root ) ,
183186 ) ;
184187
188+ const tsConfigPath = path . resolve ( workspace . root , options . tsConfig ) ;
189+ const tsConfig = readTsconfig ( tsConfigPath ) ;
190+
191+ if ( isEs5SupportNeeded ( projectRoot ) &&
192+ tsConfig . options . target !== ts . ScriptTarget . ES5 &&
193+ tsConfig . options . target !== ts . ScriptTarget . ES2015 ) {
194+ context . logger . warn ( tags . stripIndent `
195+ WARNING: Using differential loading with targets ES5 and ES2016 or higher may
196+ cause problems. Browsers with support for ES2015 will load the ES2016+ scripts
197+ referenced with script[type="module"] but they may not support ES2016+ syntax.
198+ ` ) ;
199+ }
200+
185201 return from ( configs ) . pipe (
186202 // the concurrency parameter (3rd parameter of mergeScan) is deliberately
187203 // set to 1 to make sure the build steps are executed in sequence.
0 commit comments