From 51d90bc504fab5b3044e159e87940b2618eee080 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 21 Nov 2019 22:09:28 -0500 Subject: [PATCH] fix(@schematics/angular): when migrating do not set base localize option for builder This can cause unnecesary rebuild time increases and is unneeded when using the new multi-locale builds. --- .../update-9/update-workspace-config.ts | 32 ------------------- .../update-9/update-workspace-config_spec.ts | 14 -------- 2 files changed, 46 deletions(-) diff --git a/packages/schematics/angular/migrations/update-9/update-workspace-config.ts b/packages/schematics/angular/migrations/update-9/update-workspace-config.ts index a2986c90535e..bfcfa20fdf91 100644 --- a/packages/schematics/angular/migrations/update-9/update-workspace-config.ts +++ b/packages/schematics/angular/migrations/update-9/update-workspace-config.ts @@ -128,7 +128,6 @@ function addProjectI18NOptions( function addBuilderI18NOptions(recorder: UpdateRecorder, builderConfig: JsonAstObject, projectConfig: JsonAstObject) { const options = getAllOptions(builderConfig); - let hasi18n = false; for (const option of options) { const localeId = findPropertyInAstObject(option, 'i18nLocale'); if (localeId && localeId.kind === 'string') { @@ -146,37 +145,6 @@ function addBuilderI18NOptions(recorder: UpdateRecorder, builderConfig: JsonAstO if (i18nFormat) { removePropertyInAstObject(recorder, option, 'i18nFormat'); } - - hasi18n = !!(hasi18n || i18nFormat || i18nFile || localeId); - } - - if (hasi18n) { - const options = findPropertyInAstObject(builderConfig, 'options'); - if (!options || options.kind !== 'object') { - return; - } - - // Don't add localize option of it's already present in the main options - if (findPropertyInAstObject(options, 'i18nLocale') || findPropertyInAstObject(options, 'localize')) { - return; - } - - // Get sourceLocale from extract-i18n builder - const extractI18nConfig = getProjectTarget(projectConfig, 'extract-i18n', Builders.ExtractI18n); - let sourceLocale: string | undefined; - - if (extractI18nConfig && extractI18nConfig.kind === 'object') { - const i18nOptions = getAllOptions(extractI18nConfig); - sourceLocale = i18nOptions - .map(o => { - const sourceLocale = findPropertyInAstObject(o, 'i18nLocale'); - - return sourceLocale && sourceLocale.value; - }) - .find(x => !!x) as string; - } - - insertPropertyInAstObjectInOrder(recorder, options, 'localize', [sourceLocale || 'en-US'], 12); } } diff --git a/packages/schematics/angular/migrations/update-9/update-workspace-config_spec.ts b/packages/schematics/angular/migrations/update-9/update-workspace-config_spec.ts index c96a2b800fd3..7c2ed8b38cb6 100644 --- a/packages/schematics/angular/migrations/update-9/update-workspace-config_spec.ts +++ b/packages/schematics/angular/migrations/update-9/update-workspace-config_spec.ts @@ -333,20 +333,6 @@ describe('Migration to version 9', () => { expect(config.configurations.de.localize).toEqual(['de']); }); - it(`should add 'localize' option in main options`, async () => { - let config = getWorkspaceTargets(tree); - config.build.options.aot = false; - config.build.configurations.de = getI18NConfig('de'); - config['extract-i18n'].options.i18nFormat = 'xmb'; - config['extract-i18n'].options.i18nLocale = 'en-GB'; - updateWorkspaceTargets(tree, config); - - const tree2 = await schematicRunner.runSchematicAsync('workspace-version-9', {}, tree.branch()).toPromise(); - config = getWorkspaceTargets(tree2).build; - expect(config.options.localize).toEqual(['en-GB']); - expect(config.configurations.de.localize).toEqual(['de']); - }); - it('should remove deprecated i18n options', async () => { let config = getWorkspaceTargets(tree); config.build.options.aot = false;