Skip to content

Commit f383f32

Browse files
devversionclydin
authored andcommitted
fix(@angular-devkit/build-angular): ESM-interop loaded plugin creators 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.
1 parent 1a8d0d0 commit f383f32

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packages/angular_devkit/build_angular/src/babel/webpack-loader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ export default custom<AngularCustomOptions>(() => {
138138
}
139139

140140
customOptions.i18n = {
141-
...(i18n as ApplicationPresetOptions['i18n']),
142-
i18nPluginCreators,
143-
} as ApplicationPresetOptions['i18n'];
141+
...(i18n as NonNullable<ApplicationPresetOptions['i18n']>),
142+
pluginCreators: i18nPluginCreators,
143+
};
144144
shouldProcess = true;
145145
}
146146

packages/angular_devkit/build_angular/src/utils/process-bundle.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import { allowMinify, shouldBeautify } from './environment-options';
2424
import { I18nOptions } from './i18n-options';
2525
import { loadEsmModule } from './load-esm';
2626

27-
type LocalizeUtilities = typeof import('@angular/localize/src/tools/src/source_file_utils');
28-
2927
// Extract Sourcemap input type from the remapping function since it is not currently exported
3028
type SourceMapInput = Exclude<Parameters<typeof remapping>[0], unknown[]>;
3129

@@ -386,7 +384,7 @@ function inlineCopyOnly(options: InlineOptions) {
386384
function findLocalizePositions(
387385
ast: ParseResult,
388386
options: InlineOptions,
389-
utils: LocalizeUtilities,
387+
utils: LocalizeUtilityModule,
390388
): LocalizePosition[] {
391389
const positions: LocalizePosition[] = [];
392390

@@ -438,7 +436,7 @@ function findLocalizePositions(
438436

439437
function unwrapTemplateLiteral(
440438
path: NodePath<types.TaggedTemplateExpression>,
441-
utils: LocalizeUtilities,
439+
utils: LocalizeUtilityModule,
442440
): [TemplateStringsArray, types.Expression[]] {
443441
const [messageParts] = utils.unwrapMessagePartsFromTemplateLiteral(
444442
path.get('quasi').get('quasis'),
@@ -450,7 +448,7 @@ function unwrapTemplateLiteral(
450448

451449
function unwrapLocalizeCall(
452450
path: NodePath<types.CallExpression>,
453-
utils: LocalizeUtilities,
451+
utils: LocalizeUtilityModule,
454452
): [TemplateStringsArray, types.Expression[]] {
455453
const [messageParts] = utils.unwrapMessagePartsFromLocalizeCall(path);
456454
const [expressions] = utils.unwrapSubstitutionsFromLocalizeCall(path);

0 commit comments

Comments
 (0)