@@ -65,25 +65,27 @@ async function createI18nPlugins(
65
65
66
66
const diagnostics = new localizeDiag . Diagnostics ( ) ;
67
67
68
- if ( translation ) {
69
- const es2015 = await import (
70
- // tslint:disable-next-line: trailing-comma no-implicit-dependencies
71
- '@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin'
72
- ) ;
73
- plugins . push (
74
- // tslint:disable-next-line: no-any
75
- es2015 . makeEs2015TranslatePlugin ( diagnostics , translation as any , { missingTranslation } ) ,
76
- ) ;
68
+ const es2015 = await import (
69
+ // tslint:disable-next-line: trailing-comma no-implicit-dependencies
70
+ '@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin'
71
+ ) ;
72
+ plugins . push (
73
+ // tslint:disable-next-line: no-any
74
+ es2015 . makeEs2015TranslatePlugin ( diagnostics , ( translation || { } ) as any , {
75
+ missingTranslation : translation === undefined ? 'ignore' : missingTranslation ,
76
+ } ) ,
77
+ ) ;
77
78
78
- const es5 = await import (
79
- // tslint:disable-next-line: trailing-comma no-implicit-dependencies
80
- '@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin'
81
- ) ;
82
- plugins . push (
83
- // tslint:disable-next-line: no-any
84
- es5 . makeEs5TranslatePlugin ( diagnostics , translation as any , { missingTranslation } ) ,
85
- ) ;
86
- }
79
+ const es5 = await import (
80
+ // tslint:disable-next-line: trailing-comma no-implicit-dependencies
81
+ '@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin'
82
+ ) ;
83
+ plugins . push (
84
+ // tslint:disable-next-line: no-any
85
+ es5 . makeEs5TranslatePlugin ( diagnostics , ( translation || { } ) as any , {
86
+ missingTranslation : translation === undefined ? 'ignore' : missingTranslation ,
87
+ } ) ,
88
+ ) ;
87
89
88
90
const inlineLocale = await import (
89
91
// tslint:disable-next-line: trailing-comma no-implicit-dependencies
@@ -173,14 +175,29 @@ export function serveWebpackBrowser(
173
175
}
174
176
175
177
const locale = [ ...i18n . inlineLocales ] [ 0 ] ;
176
- const translation = i18n . locales [ locale ] && i18n . locales [ locale ] . translation ;
178
+ const localeDescription = i18n . locales [ locale ] && i18n . locales [ locale ] ;
177
179
178
180
const { plugins, diagnostics } = await createI18nPlugins (
179
181
locale ,
180
- translation ,
182
+ localeDescription && localeDescription . translation ,
181
183
browserOptions . i18nMissingTranslation ,
182
184
) ;
183
185
186
+ // Modify main entrypoint to include locale data
187
+ if (
188
+ localeDescription &&
189
+ localeDescription . dataPath &&
190
+ typeof config . entry === 'object' &&
191
+ ! Array . isArray ( config . entry ) &&
192
+ config . entry [ 'main' ]
193
+ ) {
194
+ if ( Array . isArray ( config . entry [ 'main' ] ) ) {
195
+ config . entry [ 'main' ] . unshift ( localeDescription . dataPath ) ;
196
+ } else {
197
+ config . entry [ 'main' ] = [ localeDescription . dataPath , config . entry [ 'main' ] ] ;
198
+ }
199
+ }
200
+
184
201
// Get the insertion point for the i18n babel loader rule
185
202
// This is currently dependent on the rule order/construction in common.ts
186
203
// A future refactor of the webpack configuration definition will improve this situation
@@ -212,7 +229,6 @@ export function serveWebpackBrowser(
212
229
// Add a plugin to inject the i18n diagnostics
213
230
// tslint:disable-next-line: no-non-null-assertion
214
231
webpackConfig . plugins ! . push ( {
215
- // tslint:disable-next-line:no-any
216
232
apply : ( compiler : webpack . Compiler ) => {
217
233
compiler . hooks . thisCompilation . tap ( 'build-angular' , compilation => {
218
234
compilation . hooks . finishModules . tap ( 'build-angular' , ( ) => {
0 commit comments