Skip to content

Commit 51d90bc

Browse files
clydinvikerman
authored andcommitted
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.
1 parent 807eae2 commit 51d90bc

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

packages/schematics/angular/migrations/update-9/update-workspace-config.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ function addProjectI18NOptions(
128128
function addBuilderI18NOptions(recorder: UpdateRecorder, builderConfig: JsonAstObject, projectConfig: JsonAstObject) {
129129
const options = getAllOptions(builderConfig);
130130

131-
let hasi18n = false;
132131
for (const option of options) {
133132
const localeId = findPropertyInAstObject(option, 'i18nLocale');
134133
if (localeId && localeId.kind === 'string') {
@@ -146,37 +145,6 @@ function addBuilderI18NOptions(recorder: UpdateRecorder, builderConfig: JsonAstO
146145
if (i18nFormat) {
147146
removePropertyInAstObject(recorder, option, 'i18nFormat');
148147
}
149-
150-
hasi18n = !!(hasi18n || i18nFormat || i18nFile || localeId);
151-
}
152-
153-
if (hasi18n) {
154-
const options = findPropertyInAstObject(builderConfig, 'options');
155-
if (!options || options.kind !== 'object') {
156-
return;
157-
}
158-
159-
// Don't add localize option of it's already present in the main options
160-
if (findPropertyInAstObject(options, 'i18nLocale') || findPropertyInAstObject(options, 'localize')) {
161-
return;
162-
}
163-
164-
// Get sourceLocale from extract-i18n builder
165-
const extractI18nConfig = getProjectTarget(projectConfig, 'extract-i18n', Builders.ExtractI18n);
166-
let sourceLocale: string | undefined;
167-
168-
if (extractI18nConfig && extractI18nConfig.kind === 'object') {
169-
const i18nOptions = getAllOptions(extractI18nConfig);
170-
sourceLocale = i18nOptions
171-
.map(o => {
172-
const sourceLocale = findPropertyInAstObject(o, 'i18nLocale');
173-
174-
return sourceLocale && sourceLocale.value;
175-
})
176-
.find(x => !!x) as string;
177-
}
178-
179-
insertPropertyInAstObjectInOrder(recorder, options, 'localize', [sourceLocale || 'en-US'], 12);
180148
}
181149
}
182150

packages/schematics/angular/migrations/update-9/update-workspace-config_spec.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,6 @@ describe('Migration to version 9', () => {
333333
expect(config.configurations.de.localize).toEqual(['de']);
334334
});
335335

336-
it(`should add 'localize' option in main options`, async () => {
337-
let config = getWorkspaceTargets(tree);
338-
config.build.options.aot = false;
339-
config.build.configurations.de = getI18NConfig('de');
340-
config['extract-i18n'].options.i18nFormat = 'xmb';
341-
config['extract-i18n'].options.i18nLocale = 'en-GB';
342-
updateWorkspaceTargets(tree, config);
343-
344-
const tree2 = await schematicRunner.runSchematicAsync('workspace-version-9', {}, tree.branch()).toPromise();
345-
config = getWorkspaceTargets(tree2).build;
346-
expect(config.options.localize).toEqual(['en-GB']);
347-
expect(config.configurations.de.localize).toEqual(['de']);
348-
});
349-
350336
it('should remove deprecated i18n options', async () => {
351337
let config = getWorkspaceTargets(tree);
352338
config.build.options.aot = false;

0 commit comments

Comments
 (0)