diff --git a/packages/angular_devkit/build_angular/src/utils/build-browser-features_spec.ts b/packages/angular_devkit/build_angular/src/utils/build-browser-features_spec.ts index 072948de8a85..4e987e69a9c8 100644 --- a/packages/angular_devkit/build_angular/src/utils/build-browser-features_spec.ts +++ b/packages/angular_devkit/build_angular/src/utils/build-browser-features_spec.ts @@ -25,7 +25,7 @@ describe('BuildBrowserFeatures', () => { afterEach(async () => host.restore().toPromise()); describe('isDifferentialLoadingNeeded', () => { - it('should be true for for IE 9-11 and ES2015', () => { + it('should be true for IE 9-11 and ES2015', () => { host.writeMultipleFiles({ '.browserslistrc': 'IE 9-11', }); diff --git a/packages/schematics/angular/application/files/.browserslistrc.template b/packages/schematics/angular/application/files/.browserslistrc.template index 80848532e47d..44c4367c77fa 100644 --- a/packages/schematics/angular/application/files/.browserslistrc.template +++ b/packages/schematics/angular/application/files/.browserslistrc.template @@ -2,11 +2,17 @@ # For additional information regarding the format and rule options, please see: # https://github.com/browserslist/browserslist#queries +# For the full list of supported browsers by the Angular framework, please see: +# https://angular.io/guide/browser-support + # You can see what browsers were selected by your queries by running: # npx browserslist -> 0.5% -last 2 versions -Firefox ESR -not dead -not IE 9-11 # For IE 9-11 support, remove 'not'. \ No newline at end of file +last 1 Chrome version +last 1 Firefox version +last 2 Edge major versions +last 2 Safari major version +last 2 iOS major versions +Firefox ESR<% if (legacyBrowsers) { %> +IE 9-11<% } else { %> +not IE 9-11 # For IE 9-11 support, remove 'not'.<% } %> diff --git a/packages/schematics/angular/application/index_spec.ts b/packages/schematics/angular/application/index_spec.ts index 4e569a19a226..595721575202 100644 --- a/packages/schematics/angular/application/index_spec.ts +++ b/packages/schematics/angular/application/index_spec.ts @@ -401,4 +401,21 @@ describe('Application Schematic', () => { expect(specTsConfig.extends).toEqual('../tsconfig.json'); }); }); + + it(`should add support for IE 9-11 in '.browserslistrc' when 'legacyBrowsers' is true`, async () => { + const options: ApplicationOptions = { ...defaultOptions, legacyBrowsers: true }; + const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree) + .toPromise(); + const content = tree.readContent('/projects/foo/.browserslistrc'); + expect(content).not.toContain(`not IE 9-11 # For IE 9-11 support, remove 'not'.`); + expect(content).toContain('IE 9-11'); + }); + + it(`should not add support for IE 9-11 in '.browserslistrc' when 'legacyBrowsers' is false`, async () => { + const options: ApplicationOptions = { ...defaultOptions, legacyBrowsers: false }; + const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree) + .toPromise(); + const content = tree.readContent('/projects/foo/.browserslistrc'); + expect(content).toContain(`not IE 9-11 # For IE 9-11 support, remove 'not'.`); + }); }); diff --git a/packages/schematics/angular/application/schema.json b/packages/schematics/angular/application/schema.json index 467cb82693ee..abec92b6a0a7 100644 --- a/packages/schematics/angular/application/schema.json +++ b/packages/schematics/angular/application/schema.json @@ -105,6 +105,11 @@ "default": false, "description": "When true, applies lint fixes after generating the application.", "x-user-analytics": 15 + }, + "legacyBrowsers": { + "type": "boolean", + "description": "Add support for legacy browsers like Internet Explorer using differential loading.", + "default": false } }, "required": [ diff --git a/packages/schematics/angular/ng-new/index.ts b/packages/schematics/angular/ng-new/index.ts index ac05f30ca8bb..3aafe41867ad 100644 --- a/packages/schematics/angular/ng-new/index.ts +++ b/packages/schematics/angular/ng-new/index.ts @@ -59,6 +59,7 @@ export default function(options: NgNewOptions): Rule { // always 'skipInstall' here, so that we do it after the move skipInstall: true, minimal: options.minimal, + legacyBrowsers: options.legacyBrowsers, }; return chain([ diff --git a/packages/schematics/angular/ng-new/schema.json b/packages/schematics/angular/ng-new/schema.json index 790208570380..cd6f4dbd65c9 100644 --- a/packages/schematics/angular/ng-new/schema.json +++ b/packages/schematics/angular/ng-new/schema.json @@ -133,6 +133,11 @@ "type": "boolean", "default": false }, + "legacyBrowsers": { + "type": "boolean", + "description": "Add support for legacy browsers like Internet Explorer using differential loading.", + "default": false + }, "packageManager": { "description": "The package manager used to install dependencies.", "type": "string", diff --git a/tests/legacy-cli/e2e/tests/basic/aot.ts b/tests/legacy-cli/e2e/tests/basic/aot.ts index a4dd67d5018d..aa0562615fad 100644 --- a/tests/legacy-cli/e2e/tests/basic/aot.ts +++ b/tests/legacy-cli/e2e/tests/basic/aot.ts @@ -6,14 +6,10 @@ export default async function () { await ng('build', '--aot=true'); if (getGlobalVariable('argv')['ve']) { - await expectFileToMatch('dist/test-project/main-es5.js', - /platformBrowser.*bootstrapModuleFactory.*AppModuleNgFactory/); - await expectFileToMatch('dist/test-project/main-es2015.js', + await expectFileToMatch('dist/test-project/main.js', /platformBrowser.*bootstrapModuleFactory.*AppModuleNgFactory/); } else { - await expectFileToMatch('dist/test-project/main-es5.js', - /platformBrowser.*bootstrapModule.*AppModule/); - await expectFileToMatch('dist/test-project/main-es2015.js', + await expectFileToMatch('dist/test-project/main.js', /platformBrowser.*bootstrapModule.*AppModule/); } } diff --git a/tests/legacy-cli/e2e/tests/basic/build.ts b/tests/legacy-cli/e2e/tests/basic/build.ts index 119e1b2c5c4a..824a2723c41d 100644 --- a/tests/legacy-cli/e2e/tests/basic/build.ts +++ b/tests/legacy-cli/e2e/tests/basic/build.ts @@ -5,8 +5,7 @@ import { ng } from '../../utils/process'; export default async function() { // Development build await ng('build'); - await expectFileToMatch('dist/test-project/index.html', 'main-es5.js'); - await expectFileToMatch('dist/test-project/index.html', 'main-es2015.js'); + await expectFileToMatch('dist/test-project/index.html', 'main.js'); // Named Development build await ng('build', 'test-project'); @@ -15,7 +14,6 @@ export default async function() { // Production build await ng('build', '--prod'); - await expectFileToMatch('dist/test-project/index.html', /main-es2015\.[a-zA-Z0-9]{20}\.js/); - await expectFileToMatch('dist/test-project/index.html', /main-es5\.[a-zA-Z0-9]{20}\.js/); + await expectFileToMatch('dist/test-project/index.html', /main\.[a-zA-Z0-9]{20}\.js/); await ng('build', '--prod', '--no-progress', 'test-project'); } diff --git a/tests/legacy-cli/e2e/tests/basic/scripts-array.ts b/tests/legacy-cli/e2e/tests/basic/scripts-array.ts index fd7f869b6cc9..7994b5e50ffd 100644 --- a/tests/legacy-cli/e2e/tests/basic/scripts-array.ts +++ b/tests/legacy-cli/e2e/tests/basic/scripts-array.ts @@ -1,5 +1,3 @@ -// TODO(architect): edit the architect config instead of the cli config. - import { oneLineTrim } from 'common-tags'; import { appendToFile, expectFileToMatch, writeMultipleFiles } from '../../utils/fs'; import { ng } from '../../utils/process'; @@ -53,40 +51,15 @@ export default async function () { await expectFileToMatch('dist/test-project/renamed-lazy-script.js', 'pre-rename-lazy-script'); // index.html lists the right bundles - if (process.env['NG_BUILD_DIFFERENTIAL_FULL']) { - await expectFileToMatch( - 'dist/test-project/index.html', - oneLineTrim` - - - - - - - - - - - `, - ); - } else { - await expectFileToMatch( - 'dist/test-project/index.html', - oneLineTrim` - - - - - - - - - - - `, - ); - } - // Ensure scripts can be separately imported from the app. - await expectFileToMatch('dist/test-project/main-es5.js', /console\.log\((['"])string\-script\1\);/); - await expectFileToMatch('dist/test-project/main-es2015.js', /console\.log\((['"])string\-script\1\);/); + await expectFileToMatch( + 'dist/test-project/index.html', + oneLineTrim` + + + + + + + `, + ); } diff --git a/tests/legacy-cli/e2e/tests/basic/styles-array.ts b/tests/legacy-cli/e2e/tests/basic/styles-array.ts index 72b082f3d18c..ad178eb612fa 100644 --- a/tests/legacy-cli/e2e/tests/basic/styles-array.ts +++ b/tests/legacy-cli/e2e/tests/basic/styles-array.ts @@ -1,4 +1,3 @@ -// TODO(architect): edit the architect config instead of the cli config. import { oneLineTrim } from 'common-tags'; import { expectFileToMatch, writeMultipleFiles } from '../../utils/fs'; import { ng } from '../../utils/process'; @@ -42,34 +41,4 @@ export default async function() { `, ); - - if (process.env['NG_BUILD_DIFFERENTIAL_FULL']) { - await expectFileToMatch( - 'dist/test-project/index.html', - oneLineTrim` - - - - - - - - - `, - ); - } else { - await expectFileToMatch( - 'dist/test-project/index.html', - oneLineTrim` - - - - - - - - - `, - ); - } } diff --git a/tests/legacy-cli/e2e/tests/build/css-urls.ts b/tests/legacy-cli/e2e/tests/build/css-urls.ts index 4fce5d50156a..05b199982a82 100644 --- a/tests/legacy-cli/e2e/tests/build/css-urls.ts +++ b/tests/legacy-cli/e2e/tests/build/css-urls.ts @@ -38,9 +38,9 @@ export default function () { /url\('\/assets\/global-img-absolute\.svg'\)/)) .then(() => expectFileToMatch('dist/test-project/styles.css', /global-img-relative\.png/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', '/assets/component-img-absolute.svg')) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', /component-img-relative\.png/)) // Check files are correctly created. .then(() => expectToFail(() => expectFileToExist('dist/test-project/global-img-absolute.svg'))) @@ -52,21 +52,21 @@ export default function () { '--extract-css')) .then(() => expectFileToMatch('dist/test-project/styles.css', /url\(\'\/assets\/global-img-absolute\.svg\'\)/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', /url\(\'\/assets\/component-img-absolute\.svg\'\)/)) // Check urls with base-href scheme are used as is (with deploy-url). .then(() => ng('build', '--base-href=http://base.url/', '--deploy-url=deploy/', '--extract-css')) .then(() => expectFileToMatch('dist/test-project/styles.css', /url\(\'\/assets\/global-img-absolute\.svg\'\)/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', /url\(\'\/assets\/component-img-absolute\.svg\'\)/)) // Check urls with deploy-url and base-href scheme only use deploy-url. .then(() => ng('build', '--base-href=http://base.url/', '--deploy-url=http://deploy.url/', '--extract-css')) .then(() => expectFileToMatch('dist/test-project/styles.css', /url\(\'\/assets\/global-img-absolute\.svg\'\)/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', /url\(\'\/assets\/component-img-absolute\.svg\'\)/)) // Check with base-href and deploy-url flags. .then(() => ng('build', '--base-href=/base/', '--deploy-url=deploy/', @@ -75,9 +75,9 @@ export default function () { '/assets/global-img-absolute.svg')) .then(() => expectFileToMatch('dist/test-project/styles.css', /global-img-relative\.png/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', '/assets/component-img-absolute.svg')) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', /deploy\/component-img-relative\.png/)) // Check with identical base-href and deploy-url flags. .then(() => ng('build', '--base-href=/base/', '--deploy-url=/base/', @@ -86,9 +86,9 @@ export default function () { '/assets/global-img-absolute.svg')) .then(() => expectFileToMatch('dist/test-project/styles.css', /global-img-relative\.png/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', '/assets/component-img-absolute.svg')) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', /\/base\/component-img-relative\.png/)) // Check with only base-href flag. .then(() => ng('build', '--base-href=/base/', @@ -97,8 +97,8 @@ export default function () { '/assets/global-img-absolute.svg')) .then(() => expectFileToMatch('dist/test-project/styles.css', /global-img-relative\.png/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', '/assets/component-img-absolute.svg')) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', /component-img-relative\.png/)); } diff --git a/tests/legacy-cli/e2e/tests/build/deploy-url.ts b/tests/legacy-cli/e2e/tests/build/deploy-url.ts index a5cf9f769702..2c4cf0cbd4c8 100644 --- a/tests/legacy-cli/e2e/tests/build/deploy-url.ts +++ b/tests/legacy-cli/e2e/tests/build/deploy-url.ts @@ -1,9 +1,6 @@ import { ng } from '../../utils/process'; import { copyProjectAsset } from '../../utils/assets'; import { expectFileToMatch, writeMultipleFiles } from '../../utils/fs'; -import { updateJsonFile } from '../../utils/project'; -import { getGlobalVariable } from '../../utils/env'; - export default function () { return Promise.resolve() @@ -13,20 +10,16 @@ export default function () { // use image with file size >10KB to prevent inlining .then(() => copyProjectAsset('images/spectrum.png', './src/assets/more.png')) .then(() => ng('build', '--deploy-url=deployUrl/', '--extract-css')) - .then(() => expectFileToMatch('dist/test-project/index.html', 'deployUrl/main-es5.js')) + .then(() => expectFileToMatch('dist/test-project/index.html', 'deployUrl/main.js')) // verify --deploy-url isn't applied to extracted css urls .then(() => expectFileToMatch('dist/test-project/styles.css', /url\(['"]?more\.png['"]?\)/)) .then(() => ng('build', '--deploy-url=http://example.com/some/path/', '--extract-css')) - .then(() => expectFileToMatch('dist/test-project/index.html', 'http://example.com/some/path/main-es5.js')) + .then(() => expectFileToMatch('dist/test-project/index.html', 'http://example.com/some/path/main.js')) // verify --deploy-url is applied to non-extracted css urls .then(() => ng('build', '--deploy-url=deployUrl/', '--extract-css=false')) - .then(() => expectFileToMatch('dist/test-project/styles-es5.js', + .then(() => expectFileToMatch('dist/test-project/styles.js', /\(['"]?deployUrl\/more\.png['"]?\)/)) - .then(() => expectFileToMatch('dist/test-project/runtime-es5.js', + .then(() => expectFileToMatch('dist/test-project/runtime.js', /__webpack_require__\.p\s*=\s*"deployUrl\/";/)); - // // verify slash is appended to the end of --deploy-url if missing - // .then(() => ng('build', '--deploy-url=deployUrl', '--extract-css=false')) - // .then(() => - // expectFileToMatch('dist/test-project/untime.js', /__webpack_require__\.p = "deployUrl\/";/)); } diff --git a/tests/legacy-cli/e2e/tests/build/differential-cache.ts b/tests/legacy-cli/e2e/tests/build/differential-cache.ts index fe9fc766a1ae..cbfe398d841f 100644 --- a/tests/legacy-cli/e2e/tests/build/differential-cache.ts +++ b/tests/legacy-cli/e2e/tests/build/differential-cache.ts @@ -1,6 +1,6 @@ import * as crypto from 'crypto'; import * as fs from 'fs'; -import { rimraf } from '../../utils/fs'; +import { rimraf, replaceInFile } from '../../utils/fs'; import { ng } from '../../utils/process'; function generateFileHashMap(): Map { @@ -39,6 +39,13 @@ export default async function() { let oldHashes: Map; let newHashes: Map; + // Enable Differential loading to run both size checks + await replaceInFile( + '.browserslistrc', + 'not IE 9-11', + 'IE 9-11', + ); + // Remove the cache so that an initial build and build with cache can be tested await rimraf('./node_modules/.cache'); diff --git a/tests/legacy-cli/e2e/tests/build/differential-loading.ts b/tests/legacy-cli/e2e/tests/build/differential-loading.ts new file mode 100644 index 000000000000..02c483570716 --- /dev/null +++ b/tests/legacy-cli/e2e/tests/build/differential-loading.ts @@ -0,0 +1,49 @@ +import { oneLineTrim } from 'common-tags'; +import { appendToFile, expectFileToMatch, replaceInFile, writeMultipleFiles } from '../../utils/fs'; +import { ng } from '../../utils/process'; +import { updateJsonFile } from '../../utils/project'; +import { expectToFail } from '../../utils/utils'; + +export default async function () { + // Enable Differential loading to run both size checks + await replaceInFile( + '.browserslistrc', + 'not IE 9-11', + 'IE 9-11', + ); + + await writeMultipleFiles({ + 'src/string-script.js': "console.log('string-script'); var number = 1+1;", + 'src/pre-rename-script.js': "console.log('pre-rename-script');", + }); + + await updateJsonFile('angular.json', configJson => { + const appArchitect = configJson.projects['test-project'].architect; + appArchitect.build.options.scripts = [ + { input: 'src/string-script.js' }, + { input: 'src/pre-rename-script.js', bundleName: 'renamed-script' }, + ]; + }); + + await ng('build', '--extract-css', '--vendor-chunk', '--optimization'); + + // index.html lists the right bundles + await expectFileToMatch( + 'dist/test-project/index.html', + oneLineTrim` + + + + + + + + + + + `, + ); + + await expectFileToMatch('dist/test-project/vendor-es2015.js', /class \w{constructor\(/); + await expectToFail(() => expectFileToMatch('dist/test-project/vendor-es5.js', /class \w{constructor\(/)); +} diff --git a/tests/legacy-cli/e2e/tests/build/dynamic-import.ts b/tests/legacy-cli/e2e/tests/build/dynamic-import.ts index cfa72e03e0ed..e40c142fc008 100644 --- a/tests/legacy-cli/e2e/tests/build/dynamic-import.ts +++ b/tests/legacy-cli/e2e/tests/build/dynamic-import.ts @@ -46,7 +46,7 @@ export default async function() { // Build and look for the split lazy module await ng('build'); for (const file of fs.readdirSync('./dist/test-project')) { - if (file === 'src-app-lazy-lazy-module-es5.js') { + if (file === 'src-app-lazy-lazy-module.js') { // Lazy module chunk was found and succesfully split return; } diff --git a/tests/legacy-cli/e2e/tests/build/environment.ts b/tests/legacy-cli/e2e/tests/build/environment.ts index e8f739be43fb..c4c6418d36b3 100644 --- a/tests/legacy-cli/e2e/tests/build/environment.ts +++ b/tests/legacy-cli/e2e/tests/build/environment.ts @@ -3,21 +3,20 @@ import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; -export default function() { +export default async function () { // Try a prod build. - return Promise.resolve() - .then(() => updateJsonFile('angular.json', configJson => { - const appArchitect = configJson.projects['test-project'].architect; - appArchitect.build.configurations['prod-env'] = { - fileReplacements: [ - { - src: 'src/environments/environment.ts', - replaceWith: 'src/environments/environment.prod.ts', - } - ], - }; - })) - .then(() => ng('build', '--configuration=prod-env')) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /production:\s*true/)) - .then(() => expectFileToMatch('dist/test-project/main-es2015.js', /production:\s*true/)); + await updateJsonFile('angular.json', configJson => { + const appArchitect = configJson.projects['test-project'].architect; + appArchitect.build.configurations['prod-env'] = { + fileReplacements: [ + { + src: 'src/environments/environment.ts', + replaceWith: 'src/environments/environment.prod.ts', + }, + ], + }; + }); + + await ng('build', '--configuration=prod-env'); + await expectFileToMatch('dist/test-project/main.js', /production:\s*true/); } diff --git a/tests/legacy-cli/e2e/tests/build/extract-licenses.ts b/tests/legacy-cli/e2e/tests/build/extract-licenses.ts index b809def92767..e7da88cc6404 100644 --- a/tests/legacy-cli/e2e/tests/build/extract-licenses.ts +++ b/tests/legacy-cli/e2e/tests/build/extract-licenses.ts @@ -7,13 +7,11 @@ export default async function() { await ng('build', '--prod', '--extract-licenses=false', '--output-hashing=none'); await expectToFail(() => expectFileToExist('dist/test-project/3rdpartylicenses.txt')); - await expectFileToMatch('dist/test-project/main-es2015.js', '@license'); - await expectFileToMatch('dist/test-project/main-es5.js', '@license'); + await expectFileToMatch('dist/test-project/main.js', '@license'); // Licenses should be removed if extraction is enabled await ng('build', '--prod', '--extract-licenses', '--output-hashing=none'); await expectFileToExist('dist/test-project/3rdpartylicenses.txt'); - await expectToFail(() => expectFileToMatch('dist/test-project/main-es2015.js', '@license')); - await expectToFail(() => expectFileToMatch('dist/test-project/main-es5.js', '@license')); + await expectToFail(() => expectFileToMatch('dist/test-project/main.js', '@license')); } diff --git a/tests/legacy-cli/e2e/tests/build/json.ts b/tests/legacy-cli/e2e/tests/build/json.ts index 337f77caefc0..96865f1b9d02 100644 --- a/tests/legacy-cli/e2e/tests/build/json.ts +++ b/tests/legacy-cli/e2e/tests/build/json.ts @@ -3,14 +3,7 @@ import { expectGitToBeClean } from '../../utils/git'; import { ng } from '../../utils/process'; export default async function() { - // TODO(architect): Delete this test. It is now in devkit/build-angular. - await ng('build', '--stats-json'); - - if (process.env['NG_BUILD_DIFFERENTIAL_FULL']) { - await expectFileToExist('./dist/test-project/stats-es5.json'); - } - await expectFileToExist('./dist/test-project/stats-es2015.json'); - + await expectFileToExist('./dist/test-project/stats.json'); await expectGitToBeClean(); } diff --git a/tests/legacy-cli/e2e/tests/build/multiple-configs.ts b/tests/legacy-cli/e2e/tests/build/multiple-configs.ts index 50b15f03517d..784ebc737bb8 100644 --- a/tests/legacy-cli/e2e/tests/build/multiple-configs.ts +++ b/tests/legacy-cli/e2e/tests/build/multiple-configs.ts @@ -42,30 +42,30 @@ export default async function () { // Test the base configuration. await ng('build'); await expectFileToExist('dist/test-project/favicon.ico'); - await expectFileToExist('dist/test-project/main-es2015.js.map'); - await expectFileToExist('dist/test-project/styles-es2015.js'); - await expectFileToExist('dist/test-project/vendor-es2015.js'); + await expectFileToExist('dist/test-project/main.js.map'); + await expectFileToExist('dist/test-project/styles.js'); + await expectFileToExist('dist/test-project/vendor.js'); // Test that --prod extracts css. await ng('build', '--prod'); await expectFileToExist('dist/test-project/styles.css'); // But using a config overrides prod. await ng('build', '--prod', '--configuration=three'); - await expectFileToExist('dist/test-project/styles-es2015.js'); + await expectFileToExist('dist/test-project/styles.js'); await expectToFail(() => expectFileToExist('dist/test-project/styles.css')); // Use two configurations. await ng('build', '--configuration=one,two', '--vendor-chunk=false'); await expectToFail(() => expectFileToExist('dist/test-project/favicon.ico')); - await expectToFail(() => expectFileToExist('dist/test-project/main-es2015.js.map')); + await expectToFail(() => expectFileToExist('dist/test-project/main.js.map')); // Use two configurations and two overrides, one of which overrides a config. await ng('build', '--configuration=one,two', '--vendor-chunk=false', '--sourceMap=true'); await expectToFail(() => expectFileToExist('dist/test-project/favicon.ico')); - await expectFileToExist('dist/test-project/main-es2015.js.map'); - await expectToFail(() => expectFileToExist('dist/test-project/vendor-es2015.js')); + await expectFileToExist('dist/test-project/main.js.map'); + await expectToFail(() => expectFileToExist('dist/test-project/vendor.js')); // Use three configurations and a override, and prod at the end. await ng('build', '--configuration=one,two,three', '--vendor-chunk=false', '--prod'); await expectToFail(() => expectFileToExist('dist/test-project/favicon.ico')); - await expectToFail(() => expectFileToExist('dist/test-project/main-es2015.js.map')); - await expectToFail(() => expectFileToExist('dist/test-project/vendor-es2015.js')); - await expectFileToExist('dist/test-project/styles-es2015.js'); + await expectToFail(() => expectFileToExist('dist/test-project/main.js.map')); + await expectToFail(() => expectFileToExist('dist/test-project/vendor.js')); + await expectFileToExist('dist/test-project/styles.js'); await expectToFail(() => expectFileToExist('dist/test-project/styles.css')); } diff --git a/tests/legacy-cli/e2e/tests/build/no-sourcemap.ts b/tests/legacy-cli/e2e/tests/build/no-sourcemap.ts index bf0468fbfaa3..2d96e0da5b75 100644 --- a/tests/legacy-cli/e2e/tests/build/no-sourcemap.ts +++ b/tests/legacy-cli/e2e/tests/build/no-sourcemap.ts @@ -3,10 +3,10 @@ import { ng } from '../../utils/process'; export default async function () { await ng('build', '--prod', '--output-hashing=none', '--source-map', 'false'); - await testForSourceMaps(6); + await testForSourceMaps(3); await ng('build', '--output-hashing=none', '--source-map', 'false'); - await testForSourceMaps(8); + await testForSourceMaps(4); } async function testForSourceMaps(expectedNumberOfFiles: number): Promise { diff --git a/tests/legacy-cli/e2e/tests/build/output-dir.ts b/tests/legacy-cli/e2e/tests/build/output-dir.ts index 222ce06582af..012fa7bff668 100644 --- a/tests/legacy-cli/e2e/tests/build/output-dir.ts +++ b/tests/legacy-cli/e2e/tests/build/output-dir.ts @@ -10,8 +10,7 @@ export default function() { return ng('build', '--output-path', 'build-output') .then(() => expectFileToExist('./build-output/index.html')) - .then(() => expectFileToExist('./build-output/main-es5.js')) - .then(() => expectFileToExist('./build-output/main-es2015.js')) + .then(() => expectFileToExist('./build-output/main.js')) .then(() => expectToFail(expectGitToBeClean)) .then(() => updateJsonFile('angular.json', workspaceJson => { const appArchitect = workspaceJson.projects['test-project'].architect; @@ -19,7 +18,6 @@ export default function() { })) .then(() => ng('build')) .then(() => expectFileToExist('./config-build-output/index.html')) - .then(() => expectFileToExist('./config-build-output/main-es5.js')) - .then(() => expectFileToExist('./config-build-output/main-es2015.js')) + .then(() => expectFileToExist('./config-build-output/main.js')) .then(() => expectToFail(expectGitToBeClean)); } diff --git a/tests/legacy-cli/e2e/tests/build/output-hashing.ts b/tests/legacy-cli/e2e/tests/build/output-hashing.ts index 676fae3ac49b..d54283c215b5 100644 --- a/tests/legacy-cli/e2e/tests/build/output-hashing.ts +++ b/tests/legacy-cli/e2e/tests/build/output-hashing.ts @@ -15,42 +15,26 @@ export default async function () { // use image with file size >10KB to prevent inlining await copyProjectAsset('images/spectrum.png', './src/assets/image.png'); await ng('build', '--output-hashing=all'); - await expectFileToMatch('dist/test-project/index.html', /runtime-es2015\.[0-9a-f]{20}\.js/); - await expectFileToMatch('dist/test-project/index.html', /main-es2015\.[0-9a-f]{20}\.js/); - await expectFileToMatch('dist/test-project/index.html', /runtime-es5\.[0-9a-f]{20}\.js/); - await expectFileToMatch('dist/test-project/index.html', /main-es5\.[0-9a-f]{20}\.js/); - await expectFileToMatch('dist/test-project/index.html', /styles-es5\.[0-9a-f]{20}\.(css|js)/); - await expectFileToMatch('dist/test-project/index.html', /styles-es2015\.[0-9a-f]{20}\.(css|js)/); - await verifyMedia(/styles-es5\.[0-9a-f]{20}\.(css|js)/, /image\.[0-9a-f]{20}\.png/); - await verifyMedia(/styles-es2015\.[0-9a-f]{20}\.(css|js)/, /image\.[0-9a-f]{20}\.png/); + await expectFileToMatch('dist/test-project/index.html', /runtime\.[0-9a-f]{20}\.js/); + await expectFileToMatch('dist/test-project/index.html', /main\.[0-9a-f]{20}\.js/); + await expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.(css|js)/); + await verifyMedia(/styles\.[0-9a-f]{20}\.(css|js)/, /image\.[0-9a-f]{20}\.png/); await ng('build', '--output-hashing=none'); - await expectFileToMatch('dist/test-project/index.html', /runtime-es2015\.js/); - await expectFileToMatch('dist/test-project/index.html', /runtime-es5\.js/); - await expectFileToMatch('dist/test-project/index.html', /main-es5\.js/); - await expectFileToMatch('dist/test-project/index.html', /main-es2015\.js/); - await expectFileToMatch('dist/test-project/index.html', /styles-es5\.(css|js)/); - await expectFileToMatch('dist/test-project/index.html', /styles-es2015\.(css|js)/); - await verifyMedia(/styles-es5\.(css|js)/, /image\.png/); - await verifyMedia(/styles-es2015\.(css|js)/, /image\.png/); + await expectFileToMatch('dist/test-project/index.html', /runtime\.js/); + await expectFileToMatch('dist/test-project/index.html', /main\.js/); + await expectFileToMatch('dist/test-project/index.html', /styles\.(css|js)/); + await verifyMedia(/styles\.(css|js)/, /image\.png/); await ng('build', '--output-hashing=media'); - await expectFileToMatch('dist/test-project/index.html', /runtime-es2015\.js/); - await expectFileToMatch('dist/test-project/index.html', /main-es2015\.js/); - await expectFileToMatch('dist/test-project/index.html', /runtime-es5\.js/); - await expectFileToMatch('dist/test-project/index.html', /main-es5\.js/); - await expectFileToMatch('dist/test-project/index.html', /styles-es5\.(css|js)/); - await expectFileToMatch('dist/test-project/index.html', /styles-es2015\.(css|js)/); - await verifyMedia(/styles-es5\.(css|js)/, /image\.[0-9a-f]{20}\.png/); - await verifyMedia(/styles-es2015\.(css|js)/, /image\.[0-9a-f]{20}\.png/); + await expectFileToMatch('dist/test-project/index.html', /runtime\.js/); + await expectFileToMatch('dist/test-project/index.html', /main\.js/); + await expectFileToMatch('dist/test-project/index.html', /styles\.(css|js)/); + await verifyMedia(/styles\.(css|js)/, /image\.[0-9a-f]{20}\.png/); await ng('build', '--output-hashing=bundles'); - await expectFileToMatch('dist/test-project/index.html', /runtime-es2015\.[0-9a-f]{20}\.js/); - await expectFileToMatch('dist/test-project/index.html', /main-es2015\.[0-9a-f]{20}\.js/); - await expectFileToMatch('dist/test-project/index.html', /runtime-es5\.[0-9a-f]{20}\.js/); - await expectFileToMatch('dist/test-project/index.html', /main-es5\.[0-9a-f]{20}\.js/); - await expectFileToMatch('dist/test-project/index.html', /styles-es5\.[0-9a-f]{20}\.(css|js)/); - await expectFileToMatch('dist/test-project/index.html', /styles-es2015\.[0-9a-f]{20}\.(css|js)/); - await verifyMedia(/styles-es5\.[0-9a-f]{20}\.(css|js)/, /image\.png/); - await verifyMedia(/styles-es2015\.[0-9a-f]{20}\.(css|js)/, /image\.png/); + await expectFileToMatch('dist/test-project/index.html', /runtime\.[0-9a-f]{20}\.js/); + await expectFileToMatch('dist/test-project/index.html', /main\.[0-9a-f]{20}\.js/); + await expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.(css|js)/); + await verifyMedia(/styles\.[0-9a-f]{20}\.(css|js)/, /image\.png/); } diff --git a/tests/legacy-cli/e2e/tests/build/polyfills.ts b/tests/legacy-cli/e2e/tests/build/polyfills.ts index 3681ff77d127..080bbddd5c23 100644 --- a/tests/legacy-cli/e2e/tests/build/polyfills.ts +++ b/tests/legacy-cli/e2e/tests/build/polyfills.ts @@ -4,48 +4,40 @@ import { expectFileToExist, expectFileToMatch, getFileSize, + replaceInFile, } from '../../utils/fs'; import { ng } from '../../utils/process'; import { expectToFail } from '../../utils/utils'; export default async function () { - await ng('build', '--aot=false'); - // files were created successfully - await expectFileToMatch('dist/test-project/polyfills-es5.js', 'core-js/proposals/reflect-metadata'); - await expectFileToMatch('dist/test-project/polyfills-es5.js', 'zone.js'); - if (process.env['NG_BUILD_DIFFERENTIAL_FULL']) { - await expectFileToMatch('dist/test-project/index.html', oneLineTrim` - - - - - `); - } else { - await expectFileToMatch('dist/test-project/index.html', oneLineTrim` - - - - - - `); - } else { - await expectFileToMatch('dist/test-project/index.html', oneLineTrim` - - + + - - - + + `)), ) // also check when css isn't extracted .then(() => ng('build', '--no-extract-css')) // files were created successfully - .then(() => expectFileToMatch('dist/test-project/styles-es5.js', '.string-style')) - .then(() => expectFileToMatch('dist/test-project/styles-es5.js', '.input-style')) - .then(() => expectFileToMatch('dist/test-project/lazy-style-es5.js', '.lazy-style')) - .then(() => expectFileToMatch('dist/test-project/renamed-style-es5.js', '.pre-rename-style')) - .then(() => - expectFileToMatch('dist/test-project/renamed-lazy-style-es5.js', '.pre-rename-lazy-style'), - ) - .then(() => expectFileToMatch('dist/test-project/styles-es2015.js', '.string-style')) - .then(() => expectFileToMatch('dist/test-project/styles-es2015.js', '.input-style')) - .then(() => expectFileToMatch('dist/test-project/lazy-style-es2015.js', '.lazy-style')) + .then(() => expectFileToMatch('dist/test-project/styles.js', '.string-style')) + .then(() => expectFileToMatch('dist/test-project/styles.js', '.input-style')) + .then(() => expectFileToMatch('dist/test-project/lazy-style.js', '.lazy-style')) + .then(() => expectFileToMatch('dist/test-project/renamed-style.js', '.pre-rename-style')) .then(() => - expectFileToMatch('dist/test-project/renamed-style-es2015.js', '.pre-rename-style'), + expectFileToMatch('dist/test-project/renamed-lazy-style.js', '.pre-rename-lazy-style'), ) .then(() => expectFileToMatch( - 'dist/test-project/renamed-lazy-style-es2015.js', + 'dist/test-project/renamed-lazy-style.js', '.pre-rename-lazy-style', ), ) @@ -104,10 +88,8 @@ export default function() { expectFileToMatch( 'dist/test-project/index.html', oneLineTrim` - - - - + + `, ), ) diff --git a/tests/legacy-cli/e2e/tests/build/styles/imports.ts b/tests/legacy-cli/e2e/tests/build/styles/imports.ts index 784d51f4f6c0..41bb0dc4b571 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/imports.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/imports.ts @@ -56,9 +56,9 @@ export default function () { .then(() => expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""'))) // verify component styles - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', + .then(() => expectFileToMatch('dist/test-project/main.js', /h1.*background:\s*#000+/)) // Also check imports work on ng test .then(() => ng('test', '--watch=false')) diff --git a/tests/legacy-cli/e2e/tests/build/styles/include-paths.ts b/tests/legacy-cli/e2e/tests/build/styles/include-paths.ts index 709dfc7784e6..0c4ac094697f 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/include-paths.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/include-paths.ts @@ -59,16 +59,16 @@ export default function () { // files were created successfully .then(() => ng('build', '--extract-css')) .then(() => expectFileToMatch('dist/test-project/styles.css', /h1\s*{\s*color: red;\s*}/)) - .then(() => expectFileToMatch('dist/test-project/main-es2015.js', /h2.*{.*color: red;.*}/)) + .then(() => expectFileToMatch('dist/test-project/main.js', /h2.*{.*color: red;.*}/)) .then(() => expectFileToMatch('dist/test-project/styles.css', /h3\s*{\s*color: #008000;\s*}/)) - .then(() => expectFileToMatch('dist/test-project/main-es2015.js', /h4.*{.*color: #008000;.*}/)) + .then(() => expectFileToMatch('dist/test-project/main.js', /h4.*{.*color: #008000;.*}/)) .then(() => expectFileToMatch('dist/test-project/styles.css', /h5\s*{\s*color: #ADDADD;\s*}/)) - .then(() => expectFileToMatch('dist/test-project/main-es2015.js', /h6.*{.*color: #ADDADD;.*}/)) + .then(() => expectFileToMatch('dist/test-project/main.js', /h6.*{.*color: #ADDADD;.*}/)) .then(() => ng('build', '--extract-css', '--aot')) .then(() => expectFileToMatch('dist/test-project/styles.css', /h1\s*{\s*color: red;\s*}/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /h2.*{.*color: red;.*}/)) + .then(() => expectFileToMatch('dist/test-project/main.js', /h2.*{.*color: red;.*}/)) .then(() => expectFileToMatch('dist/test-project/styles.css', /h3\s*{\s*color: #008000;\s*}/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /h4.*{.*color: #008000;.*}/)) + .then(() => expectFileToMatch('dist/test-project/main.js', /h4.*{.*color: #008000;.*}/)) .then(() => expectFileToMatch('dist/test-project/styles.css', /h5\s*{\s*color: #ADDADD;\s*}/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /h6.*{.*color: #ADDADD;.*}/)); + .then(() => expectFileToMatch('dist/test-project/main.js', /h6.*{.*color: #ADDADD;.*}/)); } diff --git a/tests/legacy-cli/e2e/tests/build/styles/less.ts b/tests/legacy-cli/e2e/tests/build/styles/less.ts index 947ccb52aa98..a8616a78484b 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/less.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/less.ts @@ -42,5 +42,5 @@ export default function () { .then(() => expectFileToMatch('dist/test-project/styles.css', /p\s*{\s*background-color: red;\s*}/)) .then(() => expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""'))) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /.outer.*.inner.*background:\s*#[fF]+/)); + .then(() => expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/)); } diff --git a/tests/legacy-cli/e2e/tests/build/styles/node-sass.ts b/tests/legacy-cli/e2e/tests/build/styles/node-sass.ts index e0a4b3fc2cdc..4c9d116a519f 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/node-sass.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/node-sass.ts @@ -39,8 +39,7 @@ export default async function () { await expectFileToMatch('dist/test-project/styles.css', /body\s*{\s*background-color: blue;\s*}/); await expectFileToMatch('dist/test-project/styles.css', /p\s*{\s*background-color: red;\s*}/); await expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""')); - await expectFileToMatch('dist/test-project/main-es5.js', /.outer.*.inner.*background:\s*#[fF]+/); - await expectFileToMatch('dist/test-project/main-es2015.js', /.outer.*.inner.*background:\s*#[fF]+/); + await expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/); await silentNpm('install', 'node-gyp'); await silentNpm('install', 'fibers'); @@ -51,6 +50,5 @@ export default async function () { await expectFileToMatch('dist/test-project/styles.css', /body\s*{\s*background-color: blue;\s*}/); await expectFileToMatch('dist/test-project/styles.css', /p\s*{\s*background-color: red;\s*}/); await expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""')); - await expectFileToMatch('dist/test-project/main-es5.js', /.outer.*.inner.*background:\s*#[fF]+/); - await expectFileToMatch('dist/test-project/main-es2015.js', /.outer.*.inner.*background:\s*#[fF]+/); + await expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/); } diff --git a/tests/legacy-cli/e2e/tests/build/styles/scss.ts b/tests/legacy-cli/e2e/tests/build/styles/scss.ts index 156ad85cd592..60173381142d 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/scss.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/scss.ts @@ -42,6 +42,5 @@ export default function () { .then(() => expectFileToMatch('dist/test-project/styles.css', /p\s*{\s*background-color: red;\s*}/)) .then(() => expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""'))) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /.outer.*.inner.*background:\s*#[fF]+/)); - .then(() => expectFileToMatch('dist/test-project/main-es2015.js', /.outer.*.inner.*background:\s*#[fF]+/)); + .then(() => expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/)); } diff --git a/tests/legacy-cli/e2e/tests/build/styles/stylus.ts b/tests/legacy-cli/e2e/tests/build/styles/stylus.ts index fef7ef380ec0..83d33074719a 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/stylus.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/stylus.ts @@ -42,6 +42,5 @@ export default function () { .then(() => expectFileToMatch('dist/test-project/styles.css', /p\s*{\s*background-color: #f00;\s*}/)) .then(() => expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""'))) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /.outer.*.inner.*background:\s*#[fF]+/)); - .then(() => expectFileToMatch('dist/test-project/main-es2015.js', /.outer.*.inner.*background:\s*#[fF]+/)); + .then(() => expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/)); } diff --git a/tests/legacy-cli/e2e/tests/build/vendor-chunk.ts b/tests/legacy-cli/e2e/tests/build/vendor-chunk.ts index d2fd20a855b1..1cf03cc7680c 100644 --- a/tests/legacy-cli/e2e/tests/build/vendor-chunk.ts +++ b/tests/legacy-cli/e2e/tests/build/vendor-chunk.ts @@ -1,15 +1,11 @@ -import {ng} from '../../utils/process'; -import {expectFileToExist} from '../../utils/fs'; -import {expectToFail} from '../../utils/utils'; +import { expectFileToExist } from '../../utils/fs'; +import { ng } from '../../utils/process'; +import { expectToFail } from '../../utils/utils'; -export default function() { - // TODO(architect): Delete this test. It is now in devkit/build-angular. - - return ng('build') - .then(() => expectFileToExist('dist/test-project/vendor-es5.js')) - .then(() => expectFileToExist('dist/test-project/vendor-es2015.js')) - .then(() => ng('build', '--vendor-chunk=false')) - .then(() => expectToFail(() => expectFileToExist('dist/test-project/vendor-es5.js'))) - .then(() => expectToFail(() => expectFileToExist('dist/test-project/vendor-es2015.js'))); +export default async function () { + await ng('build'); + await expectFileToExist('dist/test-project/vendor.js'); + await ng('build', '--vendor-chunk=false'); + await expectToFail(() => expectFileToExist('dist/test-project/vendor.js')); } diff --git a/tests/legacy-cli/e2e/tests/build/worker.ts b/tests/legacy-cli/e2e/tests/build/worker.ts index 5ea4f1b02ef9..e5e9c1a8f495 100644 --- a/tests/legacy-cli/e2e/tests/build/worker.ts +++ b/tests/legacy-cli/e2e/tests/build/worker.ts @@ -16,6 +16,13 @@ export default async function () { const projectTsConfig = 'tsconfig.json'; const workerTsConfig = 'tsconfig.worker.json'; + // Enable Differential loading to run both size checks + await replaceInFile( + '.browserslistrc', + 'not IE 9-11', + 'IE 9-11', + ); + await ng('generate', 'web-worker', 'app'); await expectFileToExist(workerPath); await expectFileToExist(projectTsConfig); diff --git a/tests/legacy-cli/e2e/tests/i18n/build-locale.ts b/tests/legacy-cli/e2e/tests/i18n/build-locale.ts index cfc3ef2120cc..c140d341fc3f 100644 --- a/tests/legacy-cli/e2e/tests/i18n/build-locale.ts +++ b/tests/legacy-cli/e2e/tests/i18n/build-locale.ts @@ -9,21 +9,16 @@ export default async function () { return; } - // These tests should be moved to the default when we use ng5 in new projects. - return Promise.resolve() - // tests for register_locale_data transformer - .then(() => ng('build', '--aot', '--i18n-locale=fr')) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /registerLocaleData/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /angular_common_locales_fr/)) - .then(() => expectFileToMatch('dist/test-project/main-es2015.js', /registerLocaleData/)) - .then(() => expectFileToMatch('dist/test-project/main-es2015.js', /angular_common_locales_fr/)) - .then(() => expectFileToMatch('dist/test-project/index.html', /lang="fr"/)) - .then(() => rimraf('dist')) - .then(() => ng('build', '--aot', '--i18n-locale=fr_FR')) - .then(() => expectFileToMatch('dist/test-project/main-es2015.js', /registerLocaleData/)) - .then(() => expectFileToMatch('dist/test-project/main-es2015.js', /angular_common_locales_fr/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /registerLocaleData/)) - .then(() => expectFileToMatch('dist/test-project/main-es5.js', /angular_common_locales_fr/)) - .then(() => expectFileToMatch('dist/test-project/index.html', /lang="fr_FR"/)) - .then(() => rimraf('dist')); + // tests for register_locale_data transformer + await ng('build', '--aot', '--i18n-locale=fr'); + await expectFileToMatch('dist/test-project/main.js', /registerLocaleData/); + await expectFileToMatch('dist/test-project/main.js', /angular_common_locales_fr/); + await expectFileToMatch('dist/test-project/index.html', /lang="fr"/); + + await rimraf('dist'); + await ng('build', '--aot', '--i18n-locale=fr_FR'); + await expectFileToMatch('dist/test-project/main.js', /registerLocaleData/); + await expectFileToMatch('dist/test-project/main.js', /angular_common_locales_fr/); + await expectFileToMatch('dist/test-project/index.html', /lang="fr_FR"/); + await rimraf('dist'); } diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-dl-xliff2.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-dl-xliff2.ts index 28225d45a583..cd7f58263e17 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-dl-xliff2.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-dl-xliff2.ts @@ -1,4 +1,4 @@ -import { appendToFile, expectFileToMatch } from '../../utils/fs'; +import { appendToFile, expectFileToMatch, replaceInFile } from '../../utils/fs'; import { execAndWaitForOutputToMatch, killAllProcesses, ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; @@ -14,6 +14,12 @@ export default async function() { export async function executeTest() { // Ensure a DL build is used. + await replaceInFile( + '.browserslistrc', + 'not IE 9-11', + 'IE 9-11', + ); + await updateJsonFile('tsconfig.json', config => { config.compilerOptions.target = 'es2015'; config.angularCompilerOptions.disableTypeScriptVersionCheck = true; diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-hashes.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-hashes.ts index 28d7f727acdb..14f58c413db8 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-hashes.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-hashes.ts @@ -10,7 +10,7 @@ import { appendToFile } from '../../utils/fs'; import { ng } from '../../utils/process'; import { langTranslations, setupI18nConfig } from './legacy'; -const OUTPUT_RE = /^(?(?:main|vendor|\d+)\-(?:es2015|es5))\.(?[a-z0-9]+)\.js$/i; +const OUTPUT_RE = /^(?(?:main|vendor|\d+))\.(?[a-z0-9]+)\.js$/i; export default async function() { // Setup i18n tests and config. diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-sourcelocale.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-sourcelocale.ts index 7b8609a0852f..0fd335e2cea7 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-sourcelocale.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-sourcelocale.ts @@ -8,7 +8,7 @@ import { expectFileToMatch } from '../../utils/fs'; import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; -import { externalServer, langTranslations, setupI18nConfig } from './legacy'; +import { langTranslations, setupI18nConfig } from './legacy'; export default async function() { // Setup i18n tests and config. @@ -33,12 +33,10 @@ export default async function() { continue; } - await expectFileToMatch(`${outputPath}/vendor-es5.js`, lang); - await expectFileToMatch(`${outputPath}/vendor-es2015.js`, lang); + await expectFileToMatch(`${outputPath}/vendor.js`, lang); // Verify the locale data is registered using the global files - await expectFileToMatch(`${outputPath}/vendor-es5.js`, '.ng.common.locales'); - await expectFileToMatch(`${outputPath}/vendor-es2015.js`, '.ng.common.locales'); + await expectFileToMatch(`${outputPath}/vendor.js`, '.ng.common.locales'); // Verify the HTML lang attribute is present await expectFileToMatch(`${outputPath}/index.html`, `lang="${lang}"`); diff --git a/tests/legacy-cli/e2e/tests/i18n/legacy.ts b/tests/legacy-cli/e2e/tests/i18n/legacy.ts index d40d900421c4..90a6942e9423 100644 --- a/tests/legacy-cli/e2e/tests/i18n/legacy.ts +++ b/tests/legacy-cli/e2e/tests/i18n/legacy.ts @@ -259,8 +259,7 @@ export default async function () { // Build each locale and verify the output. for (const { lang, translation, outputPath } of langTranslations) { await ng('build', `--configuration=${lang}`); - await expectFileToMatch(`${outputPath}/main-es5.js`, translation.helloPartial); - await expectFileToMatch(`${outputPath}/main-es2015.js`, translation.helloPartial); + await expectFileToMatch(`${outputPath}/main.js`, translation.helloPartial); // Verify the HTML lang attribute is present await expectFileToMatch(`${outputPath}/index.html`, `lang="${lang}"`); @@ -280,7 +279,6 @@ export default async function () { // Verify missing translation behaviour. await appendToFile('src/app/app.component.html', '

Other content

'); await ng('build', '--configuration=fr', '--i18n-missing-translation', 'ignore'); - await expectFileToMatch(`${baseDir}/fr/main-es5.js`, /Other content/); - await expectFileToMatch(`${baseDir}/fr/main-es2015.js`, /Other content/); + await expectFileToMatch(`${baseDir}/fr/main.js`, /Other content/); await expectToFail(() => ng('build', '--configuration=fr')); } diff --git a/tests/legacy-cli/e2e/tests/misc/browsers.ts b/tests/legacy-cli/e2e/tests/misc/browsers.ts index 31d864c3e9ba..b0fe3eea06a9 100644 --- a/tests/legacy-cli/e2e/tests/misc/browsers.ts +++ b/tests/legacy-cli/e2e/tests/misc/browsers.ts @@ -18,7 +18,7 @@ export default async function () { await replaceInFile( '.browserslistrc', 'not IE 9-11', - 'Safari 9-10.1\nIE 9-11', + 'IE 9-11', ); if (!getGlobalVariable('argv')['ve']) { diff --git a/tests/legacy-cli/e2e/tests/misc/forwardref-es2105.ts b/tests/legacy-cli/e2e/tests/misc/forwardref-es2015.ts similarity index 100% rename from tests/legacy-cli/e2e/tests/misc/forwardref-es2105.ts rename to tests/legacy-cli/e2e/tests/misc/forwardref-es2015.ts diff --git a/tests/legacy-cli/e2e/tests/misc/lazy-module.ts b/tests/legacy-cli/e2e/tests/misc/lazy-module.ts index 0256d2a82081..745a76db639e 100644 --- a/tests/legacy-cli/e2e/tests/misc/lazy-module.ts +++ b/tests/legacy-cli/e2e/tests/misc/lazy-module.ts @@ -28,7 +28,7 @@ export default function() { } oldNumberOfFiles = currentNumberOfDistFiles; - if (!distFiles.includes('too-lazy-lazy-module-es5.js')) { + if (!distFiles.includes('too-lazy-lazy-module.js')) { throw new Error('The lazy module chunk did not use a unique name.'); } }) @@ -47,7 +47,7 @@ export default function() { if (oldNumberOfFiles >= currentNumberOfDistFiles) { throw new Error('A bundle for the lazy file was not created.'); } - if (!distFiles.includes('lazy-file-es5.js')) { + if (!distFiles.includes('lazy-file.js')) { throw new Error('The lazy file chunk did not have a name.'); } oldNumberOfFiles = currentNumberOfDistFiles; @@ -68,9 +68,7 @@ export default function() { .then(() => ng('build', '--no-named-chunks')) .then(() => readdirSync('dist/test-project')) .then((distFiles) => { - if (distFiles.includes('lazy-lazy-module-es5.js') - || distFiles.includes('too-lazy-lazy-module-es5.js') - ) { + if (distFiles.includes('lazy-lazy-module.js') || distFiles.includes('too-lazy-lazy-module.js')) { throw new Error('Lazy chunks shouldn\'t have a name but did.'); } })