Skip to content

Commit

Permalink
refactor(@angular-devkit/build-angular): normalize i18n options for a…
Browse files Browse the repository at this point in the history
…pplication builder

The esbuild-based application builder will now access the project level i18n configuration
as well as the builder `localize`, `duplicateTranslationBehavior`, and `missingTranslationBehavior`
options to construct a full, normalized i18n option structure.
These options are not yet used by the builder but they are now available to access as future
work incrementally adds i18n support.
  • Loading branch information
clydin authored and alan-agius4 committed Aug 31, 2023
1 parent 5e4b532 commit 1dcff01
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import {
normalizeGlobalStyles,
} from '../../tools/webpack/utils/helpers';
import { normalizeAssetPatterns, normalizeOptimization, normalizeSourceMaps } from '../../utils';
import { I18nOptions, createI18nOptions } from '../../utils/i18n-options';
import { normalizeCacheOptions } from '../../utils/normalize-cache';
import { generateEntryPoints } from '../../utils/package-chunk-sort';
import { findTailwindConfigurationFile } from '../../utils/tailwind';
import { getIndexInputFile, getIndexOutputFile } from '../../utils/webpack-browser-config';
import { Schema as ApplicationBuilderOptions, OutputHashing } from './schema';
import { Schema as ApplicationBuilderOptions, I18NTranslation, OutputHashing } from './schema';

export type NormalizedApplicationBuildOptions = Awaited<ReturnType<typeof normalizeOptions>>;

Expand Down Expand Up @@ -80,6 +81,13 @@ export async function normalizeOptions(
const cacheOptions = normalizeCacheOptions(projectMetadata, workspaceRoot);
cacheOptions.path = path.join(cacheOptions.path, projectName);

const i18nOptions: I18nOptions & {
duplicateTranslationBehavior?: I18NTranslation;
missingTranslationBehavior?: I18NTranslation;
} = createI18nOptions(projectMetadata, options.localize);
i18nOptions.duplicateTranslationBehavior = options.i18nDuplicateTranslation;
i18nOptions.missingTranslationBehavior = options.i18nMissingTranslation;

const entryPoints = normalizeEntryPoints(workspaceRoot, options.browser, options.entryPoints);
const tsconfig = path.join(workspaceRoot, options.tsConfig);
const outputPath = normalizeDirectoryPath(path.join(workspaceRoot, options.outputPath));
Expand Down Expand Up @@ -272,6 +280,7 @@ export async function normalizeOptions(
typeof serviceWorker === 'string' ? path.join(workspaceRoot, serviceWorker) : undefined,
indexHtmlOptions,
tailwindConfiguration,
i18nOptions,
};
}

Expand Down

0 comments on commit 1dcff01

Please sign in to comment.