Skip to content

Commit 9029092

Browse files
committed
Fix a few issues with minification.
1 parent 080bb65 commit 9029092

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

webpack/localization-plugin/src/LocalizationPlugin.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ const PLUGIN_NAME: string = 'localization';
8383

8484
const PLACEHOLDER_PREFIX: string = Constants.STRING_PLACEHOLDER_PREFIX;
8585
const PLACEHOLDER_REGEX: RegExp = new RegExp(
86-
// The maximum length of quotemark escaping we can support is the length of the placeholder prefix
87-
`${PLACEHOLDER_PREFIX}_((?:[^_]){1,${PLACEHOLDER_PREFIX.length}})_(\\d+)`,
86+
`${PLACEHOLDER_PREFIX}(\\+(?:[^+]){2,})?\\+_(\\d+)`,
8887
'g'
8988
);
9089

@@ -227,8 +226,6 @@ export class LocalizationPlugin implements Webpack.Plugin {
227226
} else {
228227
return assetPath;
229228
}
230-
231-
// return source.replace(Constants.LOCALE_FILENAME_PLACEHOLDER_REGEX, this._localeNamePlaceholder.value);
232229
}
233230
);
234231

@@ -304,6 +301,7 @@ export class LocalizationPlugin implements Webpack.Plugin {
304301
const localizedChunkAssets: ILocaleElementMap = {};
305302
let alreadyProcessedAFileInThisChunk: boolean = false;
306303
for (const chunkFileName of chunk.files) {
304+
debugger;
307305
if (
308306
chunkFileName.indexOf(this._localeNamePlaceholder.value) !== -1 && // Ensure this is expected to be localized
309307
chunkFileName.endsWith('.js') && // Ensure this is a JS file
@@ -563,7 +561,7 @@ export class LocalizationPlugin implements Webpack.Plugin {
563561
};
564562
reconstructionSeries.push(staticElement);
565563

566-
const [placeholder, quotemark, placeholderSerialNumber] = regexResult;
564+
const [placeholder, capturedQuotemark, placeholderSerialNumber] = regexResult;
567565

568566
let localizedReconstructionElement: IReconstructionElement;
569567
if (placeholderSerialNumber === this._localeNamePlaceholder.suffix) {
@@ -590,6 +588,7 @@ export class LocalizationPlugin implements Webpack.Plugin {
590588
};
591589
localizedReconstructionElement = brokenLocalizedElement;
592590
} else {
591+
const quotemark: string = capturedQuotemark.substr(1, (capturedQuotemark.length - 1) / 2);
593592
const localizedElement: ILocalizedReconstructionElement = {
594593
kind: 'localized',
595594
values: values,
@@ -855,7 +854,7 @@ export class LocalizationPlugin implements Webpack.Plugin {
855854
private _getPlaceholderString(): IStringPlaceholder {
856855
const suffix: string = (this._stringPlaceholderCounter++).toString();
857856
return {
858-
value: `${Constants.STRING_PLACEHOLDER_PREFIX}_"_${suffix}`,
857+
value: `${Constants.STRING_PLACEHOLDER_PREFIX}+""+_${suffix}`,
859858
suffix: suffix
860859
};
861860
}

webpack/localization-plugin/src/utilities/Constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class Constants {
1515
lodash.escapeRegExp(Constants.LOCALE_FILENAME_PLACEHOLDER),
1616
'gi'
1717
);
18-
public static STRING_PLACEHOLDER_PREFIX: string = '-LOCALIZED-STRING-f12dy0i7-n4bo-dqwj-39gf-sasqehjmihz9';
18+
public static STRING_PLACEHOLDER_PREFIX: string = '_LOCALIZED_STRING_f12dy0i7_n4bo_dqwj_39gf_sasqehjmihz9';
1919

2020
public static RESX_REGEX: RegExp = /\.resx$/i;
2121
public static LOC_JSON_REGEX: RegExp = /\.loc\.json$/i;

0 commit comments

Comments
 (0)