Skip to content

Commit aba0f11

Browse files
authored
Merge pull request microsoft#1821 from iclanton/ianc/fix-loc-vendors-chunk-loading
[Localization Plugin] Fix an issue where the chunk URL generation code would mark some localized chunks as non-localized.
2 parents 0584b21 + 13214e8 commit aba0f11

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/localization-plugin",
5+
"comment": "Fix an issue where the chunk URL generation code would mark some localized chunks as non-localized.",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@rushstack/localization-plugin",
10+
"email": "iclanton@users.noreply.github.com"
11+
}

webpack/localization-plugin/src/AssetProcessor.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as Webpack from 'webpack';
55
import * as lodash from 'lodash';
66

77
import { Constants } from './utilities/Constants';
8-
import { EntityMarker } from './utilities/EntityMarker';
98
import { ILocaleElementMap } from './interfaces';
109
import { LocalizationPlugin, IStringSerialNumberData as IStringData } from './LocalizationPlugin';
1110

@@ -62,6 +61,7 @@ export interface IProcessAssetOptionsBase {
6261
asset: IAsset;
6362
chunk: Webpack.compilation.Chunk;
6463
noStringsLocaleName: string;
64+
chunkHasLocalizedModules: (chunk: Webpack.compilation.Chunk) => boolean;
6565
}
6666

6767
export interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase { }
@@ -94,7 +94,7 @@ export class AssetProcessor {
9494
const parsedAsset: IParseResult = AssetProcessor._parseStringToReconstructionSequence(
9595
options.plugin,
9696
assetSource,
97-
this._getJsonpFunction(options.chunk, options.noStringsLocaleName)
97+
this._getJsonpFunction(options.chunk, options.chunkHasLocalizedModules, options.noStringsLocaleName)
9898
);
9999
const reconstructedAsset: ILocalizedReconstructionResult = AssetProcessor._reconstructLocalized(
100100
parsedAsset.reconstructionSeries,
@@ -154,7 +154,7 @@ export class AssetProcessor {
154154
const parsedAsset: IParseResult = AssetProcessor._parseStringToReconstructionSequence(
155155
options.plugin,
156156
assetSource,
157-
this._getJsonpFunction(options.chunk, options.noStringsLocaleName)
157+
this._getJsonpFunction(options.chunk, options.chunkHasLocalizedModules, options.noStringsLocaleName)
158158
);
159159
const reconstructedAsset: INonLocalizedReconstructionResult = AssetProcessor._reconstructNonLocalized(
160160
parsedAsset.reconstructionSeries,
@@ -417,14 +417,15 @@ export class AssetProcessor {
417417

418418
private static _getJsonpFunction(
419419
chunk: Webpack.compilation.Chunk,
420+
chunkHasLocalizedModules: (chunk: Webpack.compilation.Chunk) => boolean,
420421
noStringsLocaleName: string
421422
): (locale: string, chunkIdToken: string | undefined) => string {
422423
const idsWithStrings: Set<string> = new Set<string>();
423424
const idsWithoutStrings: Set<string> = new Set<string>();
424425

425426
const asyncChunks: Set<Webpack.compilation.Chunk> = chunk.getAllAsyncChunks();
426427
for (const asyncChunk of asyncChunks) {
427-
if (EntityMarker.getMark(asyncChunk)) {
428+
if (chunkHasLocalizedModules(asyncChunk)) {
428429
idsWithStrings.add(asyncChunk.id);
429430
} else {
430431
idsWithoutStrings.add(asyncChunk.id);

webpack/localization-plugin/src/LocalizationPlugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ export class LocalizationPlugin implements Webpack.Plugin {
349349
assetName: chunkFilename,
350350
asset,
351351
chunk,
352+
chunkHasLocalizedModules: this._chunkHasLocalizedModules.bind(this),
352353
locales: this._locales,
353354
noStringsLocaleName: this._noStringsLocaleName,
354355
fillMissingTranslationStrings: this._fillMissingTranslationStrings,
@@ -392,7 +393,8 @@ export class LocalizationPlugin implements Webpack.Plugin {
392393
assetName: chunkFilename,
393394
asset,
394395
chunk,
395-
noStringsLocaleName: this._noStringsLocaleName
396+
noStringsLocaleName: this._noStringsLocaleName,
397+
chunkHasLocalizedModules: this._chunkHasLocalizedModules.bind(this)
396398
});
397399

398400
// Delete the existing asset because it's been renamed

0 commit comments

Comments
 (0)