Skip to content

Commit

Permalink
feat(@angular-devkit/build-angular): enable Ivy extraction by default…
Browse files Browse the repository at this point in the history
… for Ivy applications
  • Loading branch information
alan-agius4 committed Sep 28, 2020
1 parent c8f8640 commit e0244d0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Expand Up @@ -131,6 +131,7 @@ export async function execute(
const i18n = createI18nOptions(metadata);

let usingIvy = false;

const ivyMessages: LocalizeMessage[] = [];
const { config, projectRoot } = await generateBrowserWebpackConfigFromContext(
{
Expand Down Expand Up @@ -159,14 +160,15 @@ export async function execute(
(wco) => {
const isIvyApplication = wco.tsConfig.options.enableIvy !== false;

// Ivy-based extraction is currently opt-in
// Ivy extraction is the default for Ivy applications.
usingIvy = (isIvyApplication && options.ivy === undefined) || !!options.ivy;

if (options.ivy) {
if (!isIvyApplication) {
context.logger.warn(
'Ivy extraction enabled but application is not Ivy enabled. Extraction may fail.',
);
}
usingIvy = true;
} else if (isIvyApplication) {
context.logger.warn(
'Ivy extraction not enabled but application is Ivy enabled. ' +
Expand Down
Expand Up @@ -43,7 +43,7 @@
},
"ivy": {
"type": "boolean",
"description": "Use Ivy compiler to extract translations."
"description": "Use Ivy compiler to extract translations. The default for Ivy applications."
},
"progress": {
"type": "boolean",
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy-cli/e2e/tests/i18n/extract-ivy.ts
Expand Up @@ -20,7 +20,7 @@ export default async function() {
);

// Should fail with --ivy flag if `@angular/localize` is missing
const { message: message1 } = await expectToFail(() => ng('xi18n', '--ivy'));
const { message: message1 } = await expectToFail(() => ng('xi18n'));
if (!message1.includes(`Ivy extraction requires the '@angular/localize' package version 10.1.0 or higher.`)) {
throw new Error('Expected localize package error message when missing');
}
Expand All @@ -40,7 +40,7 @@ export default async function() {
await npm('install', `${localizeVersion}`);

// Should show ivy enabled application warning without --ivy flag
const { stderr: message3 } = await ng('xi18n');
const { stderr: message3 } = await ng('xi18n', '--no-ivy');
if (!message3.includes(`Ivy extraction not enabled but application is Ivy enabled.`)) {
throw new Error('Expected ivy enabled application warning');
}
Expand Down
1 change: 0 additions & 1 deletion tests/legacy-cli/e2e/tests/i18n/legacy.ts
Expand Up @@ -221,7 +221,6 @@ export async function setupI18nConfig(useLocalize = true, format: keyof typeof f
'xi18n',
'--output-path=src/locale',
`--format=${format}`,
getGlobalVariable('argv')['ve'] ? '' : '--ivy',
);
const translationFile = `src/locale/messages.${formats[format].ext}`;
await expectFileToExist(translationFile);
Expand Down

0 comments on commit e0244d0

Please sign in to comment.