Skip to content

Commit 43ca58a

Browse files
committed
Fix an issue with the loc stats file and unnamed chunks.
1 parent 9987360 commit 43ca58a

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

webpack/localization-plugin/src/LocalizationPlugin.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ export class LocalizationPlugin implements Webpack.Plugin {
209209

210210
for (const chunk of chunkGroup.chunks) {
211211
const chunkFilesSet: Set<string> = new Set(chunk.files);
212+
const localizedChunkAssets: { [locale: string]: string } = {};
212213
for (const chunkFileName of chunk.files) {
213214
if (
214215
chunkFileName.match(Constants.LOCALE_FILENAME_PLACEHOLDER_REGEX) && // Ensure this is expected to be localized
@@ -228,25 +229,26 @@ export class LocalizationPlugin implements Webpack.Plugin {
228229
delete compilation.assets[chunkFileName];
229230
chunkFilesSet.delete(chunkFileName);
230231

231-
const localizedChunkAssets: { [locale: string]: string } = {};
232232
for (const [locale, newAsset] of resultingAssets) {
233233
compilation.assets[newAsset.filename] = newAsset.asset;
234234
localizedChunkAssets[locale] = newAsset.filename;
235235
chunkFilesSet.add(newAsset.filename);
236236
}
237+
}
238+
}
237239

238-
if (chunkGroup.getParents().length > 0) {
239-
// This is a secondary chunk
240-
localizationStats.namedChunkGroups[chunkGroup.name] = {
241-
localizedAssets: localizedChunkAssets
242-
};
243-
} else {
244-
// This is an entrypoint
245-
localizationStats.entrypoints[chunkGroup.name] = {
246-
localizedAssets: localizedChunkAssets
247-
};
248-
}
240+
if (chunkGroup.getParents().length > 0) {
241+
// This is a secondary chunk
242+
if (chunkGroup.name) {
243+
localizationStats.namedChunkGroups[chunkGroup.name] = {
244+
localizedAssets: localizedChunkAssets
245+
};
249246
}
247+
} else {
248+
// This is an entrypoint
249+
localizationStats.entrypoints[chunkGroup.name] = {
250+
localizedAssets: localizedChunkAssets
251+
};
250252
}
251253

252254
chunk.files = Array.from(chunkFilesSet);

0 commit comments

Comments
 (0)