Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): enable dynamic import parsing wit…
Browse files Browse the repository at this point in the history
…h serve localization

Fixes #16248
  • Loading branch information
clydin authored and vikerman committed Nov 27, 2019
1 parent 51d90bc commit 8bcdbff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/angular_devkit/build_angular/src/dev-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ async function setupLocalize(
translationIntegrity: localeDescription && localeDescription.integrity,
}),
plugins,
parserOpts: {
plugins: ['dynamicImport'],
},
},
},
],
Expand Down
8 changes: 8 additions & 0 deletions tests/legacy-cli/e2e/tests/i18n/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const langTranslations = [
},
];
export const sourceLocale = langTranslations[0].lang;

export const externalServer = (outputPath: string) => {
const app = express();
app.use(express.static(resolve(outputPath)));
Expand Down Expand Up @@ -87,6 +88,13 @@ export async function setupI18nConfig(useLocalize = true) {
<p id="plural" i18n>Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}}</p>
`);

// Add a dynamic import to ensure syntax is supported
// ng serve support: https://github.com/angular/angular-cli/issues/16248
await writeFile('src/app/dynamic.ts', `export const abc = 5;`);
await appendToFile('src/app/app.component.ts', `
(async () => { await import('./dynamic'); })();
`);

// Add e2e specs for each lang.
for (const { lang, translation } of langTranslations) {
await writeFile(`./e2e/src/app.${lang}.e2e-spec.ts`, `
Expand Down

0 comments on commit 8bcdbff

Please sign in to comment.