Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): ESM-interop loaded plugin creator…
Browse files Browse the repository at this point in the history
…s of `@angular/localize/tools` not respected

This is a follow-up to fb210e5 which
added support for the ESM-variant of the `@angular/localize` package,
and also prepared for the `tools/` secondary entry-point we will expose
as of v13.

Unfortunately this change currently does not pass-through the ESM-loaded
plugin creators as the option (which is passed to the Babel plugin) is
incorrect. This was hidden due to a type cast. This commit fixes the
issue and also ensures TS would complain in the future if the option
names differ.
  • Loading branch information
devversion authored and clydin committed Sep 30, 2021
1 parent 1a8d0d0 commit f383f32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Expand Up @@ -138,9 +138,9 @@ export default custom<AngularCustomOptions>(() => {
}

customOptions.i18n = {
...(i18n as ApplicationPresetOptions['i18n']),
i18nPluginCreators,
} as ApplicationPresetOptions['i18n'];
...(i18n as NonNullable<ApplicationPresetOptions['i18n']>),
pluginCreators: i18nPluginCreators,
};
shouldProcess = true;
}

Expand Down
Expand Up @@ -24,8 +24,6 @@ import { allowMinify, shouldBeautify } from './environment-options';
import { I18nOptions } from './i18n-options';
import { loadEsmModule } from './load-esm';

type LocalizeUtilities = typeof import('@angular/localize/src/tools/src/source_file_utils');

// Extract Sourcemap input type from the remapping function since it is not currently exported
type SourceMapInput = Exclude<Parameters<typeof remapping>[0], unknown[]>;

Expand Down Expand Up @@ -386,7 +384,7 @@ function inlineCopyOnly(options: InlineOptions) {
function findLocalizePositions(
ast: ParseResult,
options: InlineOptions,
utils: LocalizeUtilities,
utils: LocalizeUtilityModule,
): LocalizePosition[] {
const positions: LocalizePosition[] = [];

Expand Down Expand Up @@ -438,7 +436,7 @@ function findLocalizePositions(

function unwrapTemplateLiteral(
path: NodePath<types.TaggedTemplateExpression>,
utils: LocalizeUtilities,
utils: LocalizeUtilityModule,
): [TemplateStringsArray, types.Expression[]] {
const [messageParts] = utils.unwrapMessagePartsFromTemplateLiteral(
path.get('quasi').get('quasis'),
Expand All @@ -450,7 +448,7 @@ function unwrapTemplateLiteral(

function unwrapLocalizeCall(
path: NodePath<types.CallExpression>,
utils: LocalizeUtilities,
utils: LocalizeUtilityModule,
): [TemplateStringsArray, types.Expression[]] {
const [messageParts] = utils.unwrapMessagePartsFromLocalizeCall(path);
const [expressions] = utils.unwrapSubstitutionsFromLocalizeCall(path);
Expand Down

0 comments on commit f383f32

Please sign in to comment.