Skip to content

Commit 4d2ef2b

Browse files
alan-agius4mgechev
authored andcommitted
feat(@angular-devkit/build-angular): add support for i18n extraction with Ivy (#15796)
Re-enable i18n extraction in Ivy by using the legacy VE compiler.
1 parent 35edccf commit 4d2ef2b

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/typescript.ts

+7
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ function _createAotPlugin(
6868
i18nInFormat: buildOptions.i18nFormat,
6969
};
7070

71+
const compilerOptions = options.compilerOptions || {};
72+
if (i18nExtract) {
73+
// Extraction of i18n is still using the legacy VE pipeline
74+
compilerOptions.enableIvy = false;
75+
}
76+
7177
const additionalLazyModules: { [module: string]: string } = {};
7278
if (buildOptions.lazyModules) {
7379
for (const lazyModule of buildOptions.lazyModules) {
@@ -92,6 +98,7 @@ function _createAotPlugin(
9298
logger: wco.logger,
9399
directTemplateLoading: true,
94100
...options,
101+
compilerOptions,
95102
};
96103

97104
pluginOptions = _pluginOptionsOverrides(buildOptions, pluginOptions);

packages/angular_devkit/build_angular/src/extract-i18n/index.ts

-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
getStatsConfig,
2121
getStylesConfig,
2222
} from '../angular-cli-files/models/webpack-configs';
23-
import { readTsconfig } from '../angular-cli-files/utilities/read-tsconfig';
2423
import { statsErrorsToString, statsWarningsToString } from '../angular-cli-files/utilities/stats';
2524
import { Schema as BrowserBuilderOptions } from '../browser/schema';
2625
import { assertCompatibleAngularVersion } from '../utils/version';
@@ -59,15 +58,6 @@ async function execute(options: ExtractI18nBuilderOptions, context: BuilderConte
5958
await context.getBuilderNameForTarget(browserTarget),
6059
);
6160

62-
// FIXME: i18n is not yet implemented in Ivy
63-
// We should display a warning and exit gracefully.
64-
const { options: compilerOptions } = readTsconfig(browserOptions.tsConfig, context.workspaceRoot);
65-
if (compilerOptions.enableIvy) {
66-
context.logger.warn('We are sorry but i18n is not yet implemented in Ivy.');
67-
68-
return { success: true };
69-
}
70-
7161
// We need to determine the outFile name so that AngularCompiler can retrieve it.
7262
let outFile = options.outFile || getI18nOutfile(options.i18nFormat);
7363
if (options.outputPath) {

packages/angular_devkit/build_angular/test/extract-i18n/works_spec_large.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
import { Architect } from '@angular-devkit/architect';
99
import { TestLogger } from '@angular-devkit/architect/testing';
1010
import { join, normalize, virtualFs } from '@angular-devkit/core';
11-
import { createArchitect, extractI18nTargetSpec, host, veEnabled } from '../utils';
11+
import { createArchitect, extractI18nTargetSpec, host } from '../utils';
1212

1313

14-
// DISABLED_FOR_IVY These should pass but are currently not supported
15-
(veEnabled ? describe : xdescribe)('Extract i18n Target', () => {
14+
describe('Extract i18n Target', () => {
1615
const extractionFile = join(normalize('src'), 'messages.xlf');
1716
let architect: Architect;
1817

tests/legacy-cli/e2e_runner.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ if (!argv.ve) {
100100
// As we transition into using Ivy as the default this list should be reassessed.
101101
allTests = allTests
102102
// Ivy doesn't support i18n externally at the moment.
103-
.filter(name => !name.includes('tests/i18n/'))
104-
.filter(name => !name.endsWith('tests/build/aot/aot-i18n.ts'))
103+
.filter(name => !name.endsWith('tests/build/aot/aot-i18n.ts'));
105104
}
106105

107106
const shardId = 'shard' in argv ? argv['shard'] : null;

0 commit comments

Comments
 (0)