@zohodesk/client_build_tool 0.0.11-exp.10 → 0.0.11-exp.12
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 +3 -7
- 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/lib/shared/bundler/webpack/utils/propertiesParser.js +3 -25
- 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,19 +74,16 @@ 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
|
}
|
|
85
82
|
|
|
86
83
|
if (this.options.generateManifest) {
|
|
87
|
-
const cleanName = filename.replace(/\[locale\]/g, locale).replace(
|
|
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,
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Shared properties file parsing utility
|
|
5
|
-
* Handles consistent parsing across all i18n tools
|
|
6
|
-
*/
|
|
7
|
-
// Decode Unicode escape sequences (for values only)
|
|
8
3
|
function decodeUnicodeEscapes(str) {
|
|
9
4
|
if (typeof str !== 'string') {
|
|
10
5
|
return str;
|
|
@@ -14,12 +9,6 @@ function decodeUnicodeEscapes(str) {
|
|
|
14
9
|
return String.fromCharCode(parseInt(hex, 16));
|
|
15
10
|
});
|
|
16
11
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Parse properties file content into key-value pairs
|
|
19
|
-
* @param {string} content - Properties file content
|
|
20
|
-
* @returns {Object} Parsed key-value pairs
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
12
|
|
|
24
13
|
function parseProperties(content) {
|
|
25
14
|
const lines = content.split(/\r?\n/);
|
|
@@ -29,8 +18,7 @@ function parseProperties(content) {
|
|
|
29
18
|
|
|
30
19
|
if (trimmedLine.startsWith('#') || trimmedLine.startsWith('!') || trimmedLine === '') {
|
|
31
20
|
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
21
|
+
}
|
|
34
22
|
|
|
35
23
|
let separatorIndex = -1;
|
|
36
24
|
|
|
@@ -46,9 +34,7 @@ function parseProperties(content) {
|
|
|
46
34
|
let value = trimmedLine.substring(separatorIndex + 1).trim();
|
|
47
35
|
|
|
48
36
|
if (key) {
|
|
49
|
-
|
|
50
|
-
key = key.replace(/\\ /g, ' '); // Decode Unicode escape sequences ONLY in values, not keys
|
|
51
|
-
|
|
37
|
+
key = key.replace(/\\ /g, ' ');
|
|
52
38
|
value = decodeUnicodeEscapes(value);
|
|
53
39
|
data[key] = value;
|
|
54
40
|
}
|
|
@@ -56,12 +42,6 @@ function parseProperties(content) {
|
|
|
56
42
|
});
|
|
57
43
|
return data;
|
|
58
44
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Parse properties file content into a Set of keys only
|
|
61
|
-
* @param {string} content - Properties file content
|
|
62
|
-
* @returns {Set<string>} Set of keys
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
45
|
|
|
66
46
|
function parsePropertiesToKeySet(content) {
|
|
67
47
|
const lines = content.split(/\r?\n/);
|
|
@@ -71,8 +51,7 @@ function parsePropertiesToKeySet(content) {
|
|
|
71
51
|
|
|
72
52
|
if (trimmedLine.startsWith('#') || trimmedLine.startsWith('!') || trimmedLine === '') {
|
|
73
53
|
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
54
|
+
}
|
|
76
55
|
|
|
77
56
|
let separatorIndex = -1;
|
|
78
57
|
|
|
@@ -87,7 +66,6 @@ function parsePropertiesToKeySet(content) {
|
|
|
87
66
|
let key = trimmedLine.substring(0, separatorIndex).trim();
|
|
88
67
|
|
|
89
68
|
if (key) {
|
|
90
|
-
// Handle escaped spaces in keys only
|
|
91
69
|
key = key.replace(/\\ /g, ' ');
|
|
92
70
|
keys.add(key);
|
|
93
71
|
}
|