Skip to content

Commit 8bcdbff

Browse files
clydinvikerman
authored andcommitted
fix(@angular-devkit/build-angular): enable dynamic import parsing with serve localization
Fixes #16248
1 parent 51d90bc commit 8bcdbff

File tree

2 files changed

+11
-0
lines changed
  • packages/angular_devkit/build_angular/src/dev-server
  • tests/legacy-cli/e2e/tests/i18n

2 files changed

+11
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ async function setupLocalize(
367367
translationIntegrity: localeDescription && localeDescription.integrity,
368368
}),
369369
plugins,
370+
parserOpts: {
371+
plugins: ['dynamicImport'],
372+
},
370373
},
371374
},
372375
],

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const langTranslations = [
5757
},
5858
];
5959
export const sourceLocale = langTranslations[0].lang;
60+
6061
export const externalServer = (outputPath: string) => {
6162
const app = express();
6263
app.use(express.static(resolve(outputPath)));
@@ -87,6 +88,13 @@ export async function setupI18nConfig(useLocalize = true) {
8788
<p id="plural" i18n>Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}}</p>
8889
`);
8990

91+
// Add a dynamic import to ensure syntax is supported
92+
// ng serve support: https://github.com/angular/angular-cli/issues/16248
93+
await writeFile('src/app/dynamic.ts', `export const abc = 5;`);
94+
await appendToFile('src/app/app.component.ts', `
95+
(async () => { await import('./dynamic'); })();
96+
`);
97+
9098
// Add e2e specs for each lang.
9199
for (const { lang, translation } of langTranslations) {
92100
await writeFile(`./e2e/src/app.${lang}.e2e-spec.ts`, `

0 commit comments

Comments
 (0)