@zohodesk/client_build_tool 0.0.11-exp.10 → 0.0.11-exp.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +2 -6
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +3 -5
- package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +0 -4
- package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +1 -2
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +4 -9
- package/package.json +1 -1
package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js
CHANGED
|
@@ -66,8 +66,7 @@ class I18nNumericIndexPlugin {
|
|
|
66
66
|
emitChunk(compilation, filename, locale, data, fileType = null) {
|
|
67
67
|
const content = decodeUnicodeEscapes(JSON.stringify(data));
|
|
68
68
|
const fileContent = `${this.options.jsonpFunc}(${content});`;
|
|
69
|
-
let outputPath = filename.replace(/\[locale\]/g, locale);
|
|
70
|
-
|
|
69
|
+
let outputPath = filename.replace(/\[locale\]/g, locale);
|
|
71
70
|
const hasContentHashPlaceholder = filename.includes('[contenthash]');
|
|
72
71
|
const shouldIncludeHash = hasContentHashPlaceholder || this.options.includeContentHash;
|
|
73
72
|
|
|
@@ -75,10 +74,8 @@ class I18nNumericIndexPlugin {
|
|
|
75
74
|
const contentHash = this.generateContentHash(fileContent, compilation);
|
|
76
75
|
|
|
77
76
|
if (hasContentHashPlaceholder) {
|
|
78
|
-
// Replace [contenthash] placeholder with actual hash
|
|
79
77
|
outputPath = outputPath.replace(/\[contenthash\]/g, contentHash);
|
|
80
78
|
} else {
|
|
81
|
-
// Legacy behavior: append hash before .js extension
|
|
82
79
|
outputPath = outputPath.replace(/\.js$/, `.${contentHash}.js`);
|
|
83
80
|
}
|
|
84
81
|
}
|
|
@@ -86,8 +83,7 @@ class I18nNumericIndexPlugin {
|
|
|
86
83
|
if (this.options.generateManifest) {
|
|
87
84
|
const cleanName = filename.replace(/\[locale\]/g, locale).replace(/\[contenthash\]/g, '').replace(/\.js$/, '.js');
|
|
88
85
|
const cleanNameWithType = fileType ? cleanName.replace(/\.js$/, `.${fileType}.js`) : cleanName;
|
|
89
|
-
const manifestKey = cleanNameWithType.split('/').pop();
|
|
90
|
-
|
|
86
|
+
const manifestKey = cleanNameWithType.split('/').pop();
|
|
91
87
|
this.manifest[manifestKey] = outputPath.split('/').pop();
|
|
92
88
|
}
|
|
93
89
|
|
package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js
CHANGED
|
@@ -46,10 +46,9 @@ function loadNumericMap(numericMapPath, compilation) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function loadAllLocaleFiles(propertiesPath,
|
|
49
|
+
function loadAllLocaleFiles(propertiesPath, compilation, jsResourceBase) {
|
|
50
50
|
const allI18n = {};
|
|
51
|
-
const locales = [];
|
|
52
|
-
|
|
51
|
+
const locales = [];
|
|
53
52
|
allI18n['en_US'] = jsResourceBase;
|
|
54
53
|
locales.push('en_US');
|
|
55
54
|
|
|
@@ -87,12 +86,11 @@ function loadAllLocaleFiles(propertiesPath, baseFileName, compilation, jsResourc
|
|
|
87
86
|
function loadI18nData(options, compilation) {
|
|
88
87
|
const jsResourcePath = path.resolve(compilation.compiler.context, options.jsResourcePath);
|
|
89
88
|
const propertiesPath = path.resolve(compilation.compiler.context, options.propertiesFolderPath);
|
|
90
|
-
const baseFileName = path.basename(options.jsResourcePath, '.properties');
|
|
91
89
|
const jsResourceBase = loadPropertiesFile(jsResourcePath, compilation, 'JS resources');
|
|
92
90
|
const {
|
|
93
91
|
allI18n,
|
|
94
92
|
locales
|
|
95
|
-
} = loadAllLocaleFiles(propertiesPath,
|
|
93
|
+
} = loadAllLocaleFiles(propertiesPath, compilation, jsResourceBase);
|
|
96
94
|
return {
|
|
97
95
|
jsResourceBase,
|
|
98
96
|
allI18n,
|
|
@@ -17,7 +17,6 @@ function configI18nNumericIndexPlugin(options) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const i18nOpts = options.i18nIndexing;
|
|
20
|
-
const cdnConfig = options.cdnMapping || {};
|
|
21
20
|
const requiredOptions = ['jsResourcePath', 'propertiesFolderPath', 'numericMapPath', 'jsonpFunc', 'htmlTemplateLabel', 'localeVarName', 'numericFilenameTemplate', 'dynamicFilenameTemplate'];
|
|
22
21
|
const missingOptions = requiredOptions.filter(opt => !i18nOpts[opt]);
|
|
23
22
|
|
|
@@ -40,17 +39,13 @@ function configI18nNumericIndexPlugin(options) {
|
|
|
40
39
|
|
|
41
40
|
if (!i18nOpts.dynamicFilenameTemplate.includes('[locale]')) {
|
|
42
41
|
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const i18nAssetsPublicPathPrefix = ''; // Smart contenthash detection based on template content
|
|
42
|
+
}
|
|
47
43
|
|
|
44
|
+
const i18nAssetsPublicPathPrefix = '';
|
|
48
45
|
const hasContentHashInNumeric = i18nOpts.numericFilenameTemplate.includes('[contenthash]');
|
|
49
46
|
const hasContentHashInDynamic = i18nOpts.dynamicFilenameTemplate.includes('[contenthash]');
|
|
50
|
-
const hasContentHashInSingle = i18nOpts.singleFileTemplate?.includes('[contenthash]');
|
|
51
|
-
|
|
52
|
-
const shouldIncludeContentHash = i18nOpts.singleFile ? hasContentHashInSingle : hasContentHashInNumeric || hasContentHashInDynamic; // Use explicit includeContentHash if provided, otherwise use smart detection
|
|
53
|
-
|
|
47
|
+
const hasContentHashInSingle = i18nOpts.singleFileTemplate?.includes('[contenthash]');
|
|
48
|
+
const shouldIncludeContentHash = i18nOpts.singleFile ? hasContentHashInSingle : hasContentHashInNumeric || hasContentHashInDynamic;
|
|
54
49
|
const finalIncludeContentHash = i18nOpts.includeContentHash !== undefined ? i18nOpts.includeContentHash : shouldIncludeContentHash;
|
|
55
50
|
const numericIndexPluginOptions = {
|
|
56
51
|
enable: i18nOpts.enable,
|