Skip to content

Commit 3bcb729

Browse files
clydinalan-agius4
authored andcommitted
refactor(@angular-devkit/build-angular): remove unneeded ivy enabled checks
Applications can now only be built with Ivy. However, several checks were still present in the code to determine if Ivy was enabled. Since Ivy is always enabled these checks have since become unused code and can be removed.
1 parent 59fb117 commit 3bcb729

File tree

5 files changed

+10
-44
lines changed

5 files changed

+10
-44
lines changed

packages/angular_devkit/build_angular/src/builders/dev-server/index.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { colors } from '../../utils/color';
2727
import { I18nOptions } from '../../utils/i18n-options';
2828
import { IndexHtmlTransform } from '../../utils/index-file/index-html-generator';
2929
import { generateEntryPoints } from '../../utils/package-chunk-sort';
30-
import { readTsconfig } from '../../utils/read-tsconfig';
3130
import { assertCompatibleAngularVersion } from '../../utils/version';
3231
import {
3332
generateI18nBrowserWebpackConfigFromContext,
@@ -276,17 +275,13 @@ export function serveWebpackBrowser(
276275

277276
// If a locale is defined, setup localization
278277
if (locale) {
279-
// Only supported with Ivy
280-
const tsConfig = readTsconfig(browserOptions.tsConfig, workspaceRoot);
281-
if (tsConfig.options.enableIvy !== false) {
282-
if (i18n.inlineLocales.size > 1) {
283-
throw new Error(
284-
'The development server only supports localizing a single locale per build.',
285-
);
286-
}
287-
288-
await setupLocalize(locale, i18n, browserOptions, webpackConfig);
278+
if (i18n.inlineLocales.size > 1) {
279+
throw new Error(
280+
'The development server only supports localizing a single locale per build.',
281+
);
289282
}
283+
284+
await setupLocalize(locale, i18n, browserOptions, webpackConfig);
290285
}
291286

292287
if (transforms.webpackConfiguration) {

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,6 @@ export async function execute(
200200
builderOptions,
201201
context,
202202
(wco) => {
203-
if (wco.tsConfig.options.enableIvy === false) {
204-
context.logger.warn(
205-
'Ivy extraction enabled but application is not Ivy enabled. Extraction may fail.',
206-
);
207-
}
208-
209203
// Default value for legacy message ids is currently true
210204
useLegacyIds = wco.tsConfig.options.enableI18nLegacyMessageIdFormat ?? true;
211205

packages/angular_devkit/build_angular/src/builders/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function execute(
7474
);
7575
}
7676

77-
if (!options.bundleDependencies && tsConfig.options.enableIvy) {
77+
if (!options.bundleDependencies) {
7878
// eslint-disable-next-line import/no-extraneous-dependencies
7979
const { __processed_by_ivy_ngcc__, main = '' } = require('@angular/core/package.json');
8080
if (

packages/angular_devkit/build_angular/src/webpack/configs/analytics.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ export function getAnalyticsConfig(
2828

2929
// The category is the builder name if it's an angular builder.
3030
return {
31-
plugins: [
32-
new NgBuildAnalyticsPlugin(
33-
wco.projectRoot,
34-
context.analytics,
35-
category,
36-
!!wco.tsConfig.options.enableIvy,
37-
),
38-
],
31+
plugins: [new NgBuildAnalyticsPlugin(wco.projectRoot, context.analytics, category, true)],
3932
};
4033
}

tests/legacy-cli/e2e/tests/i18n/extract-ivy.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ import { updateJsonFile } from '../../utils/project';
77
import { expectToFail } from '../../utils/utils';
88
import { readNgVersion } from '../../utils/version';
99

10-
export default async function() {
10+
export default async function () {
1111
// Setup an i18n enabled component
1212
await ng('generate', 'component', 'i18n-test');
13-
await writeFile(
14-
join('src/app/i18n-test', 'i18n-test.component.html'),
15-
'<p i18n>Hello world</p>',
16-
);
13+
await writeFile(join('src/app/i18n-test', 'i18n-test.component.html'), '<p i18n>Hello world</p>');
1714

1815
// Should fail if `@angular/localize` is missing
1916
const { message: message1 } = await expectToFail(() => ng('extract-i18n'));
@@ -34,18 +31,5 @@ export default async function() {
3431
throw new Error('Expected no warnings to be shown');
3532
}
3633

37-
// Disable Ivy
38-
await updateJsonFile('tsconfig.json', config => {
39-
const { angularCompilerOptions = {} } = config;
40-
angularCompilerOptions.enableIvy = false;
41-
config.angularCompilerOptions = angularCompilerOptions;
42-
});
43-
44-
// Should show ivy disabled application warning with enableIvy false
45-
const { stderr: message4 } = await ng('extract-i18n');
46-
if (!message4.includes(`Ivy extraction enabled but application is not Ivy enabled.`)) {
47-
throw new Error('Expected ivy disabled application warning');
48-
}
49-
5034
await uninstallPackage('@angular/localize');
5135
}

0 commit comments

Comments
 (0)