@zohodesk/client_build_tool 0.0.11-exp.7 → 0.0.11-exp.9

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.
@@ -181,6 +181,7 @@ var _default = {
181
181
  numericMapPath: './deskapp/properties/i18n-numeric-map.json',
182
182
  numericFilenameTemplate: 'i18n-chunk/[locale]/numeric.i18n.js',
183
183
  dynamicFilenameTemplate: 'i18n-chunk/[locale]/dynamic.i18n.js',
184
+ singleFileTemplate: 'i18n/[locale].js',
184
185
  jsonpFunc: 'window.loadI18nChunk',
185
186
  htmlTemplateLabel: '{{--user-locale}}',
186
187
  localeVarName: 'window.userLangCode',
@@ -26,6 +26,7 @@ class I18nNumericIndexPlugin {
26
26
  constructor(options = {}) {
27
27
  this.options = { ...options,
28
28
  singleFile: options.singleFile || false,
29
+ singleFileTemplate: options.singleFileTemplate,
29
30
  includeContentHash: options.includeContentHash || false,
30
31
  generateManifest: options.generateManifest || false
31
32
  };
@@ -65,11 +66,21 @@ class I18nNumericIndexPlugin {
65
66
  emitChunk(compilation, filename, locale, data, fileType = null) {
66
67
  const content = decodeUnicodeEscapes(JSON.stringify(data));
67
68
  const fileContent = `${this.options.jsonpFunc}(${content});`;
68
- let outputPath = filename.replace(/\[locale\]/g, locale);
69
+ let outputPath = filename.replace(/\[locale\]/g, locale); // Check if template contains [contenthash] placeholder or use legacy includeContentHash flag
69
70
 
70
- if (this.options.includeContentHash) {
71
+ const hasContentHashPlaceholder = filename.includes('[contenthash]');
72
+ const shouldIncludeHash = hasContentHashPlaceholder || this.options.includeContentHash;
73
+
74
+ if (shouldIncludeHash) {
71
75
  const contentHash = this.generateContentHash(fileContent, compilation);
72
- outputPath = outputPath.replace(/\.js$/, `.${contentHash}.js`);
76
+
77
+ if (hasContentHashPlaceholder) {
78
+ // Replace [contenthash] placeholder with actual hash
79
+ outputPath = outputPath.replace(/\[contenthash\]/g, contentHash);
80
+ } else {
81
+ // Legacy behavior: append hash before .js extension
82
+ outputPath = outputPath.replace(/\.js$/, `.${contentHash}.js`);
83
+ }
73
84
  }
74
85
 
75
86
  if (this.options.generateManifest) {
@@ -131,7 +142,7 @@ class I18nNumericIndexPlugin {
131
142
  };
132
143
 
133
144
  if (Object.keys(combinedData).length > 0) {
134
- const filename = this.options.numericFilenameTemplate || this.options.dynamicFilenameTemplate;
145
+ const filename = this.options.singleFileTemplate || this.options.numericFilenameTemplate || this.options.dynamicFilenameTemplate;
135
146
  this.emitChunk(compilation, filename, locale, combinedData);
136
147
  }
137
148
  } else {
@@ -46,20 +46,15 @@ function loadNumericMap(numericMapPath, compilation) {
46
46
  }
47
47
  }
48
48
 
49
- function loadAllLocaleFiles(propertiesPath, baseFileName, compilation) {
49
+ function loadAllLocaleFiles(propertiesPath, baseFileName, compilation, jsResourceBase) {
50
50
  const allI18n = {};
51
- const locales = [];
51
+ const locales = []; // Always use the jsResourceBase as en_US base
52
+
53
+ allI18n['en_US'] = jsResourceBase;
54
+ locales.push('en_US');
52
55
 
53
56
  try {
54
57
  const files = fs.readdirSync(propertiesPath);
55
- files.forEach(file => {
56
- if (file === baseFileName + '.properties') {
57
- const filePath = path.join(propertiesPath, file);
58
- const baseData = loadPropertiesFile(filePath, compilation, 'JSResources base');
59
- allI18n['en_US'] = baseData;
60
- locales.push('en_US');
61
- }
62
- });
63
58
  files.forEach(file => {
64
59
  if (!file.endsWith('.properties')) return;
65
60
  const match = file.match(/^ApplicationResources_([a-z]{2}_[A-Z]{2})\.properties$/);
@@ -68,7 +63,7 @@ function loadAllLocaleFiles(propertiesPath, baseFileName, compilation) {
68
63
  const locale = match[1];
69
64
  const filePath = path.join(propertiesPath, file);
70
65
  const localeData = loadPropertiesFile(filePath, compilation, `locale ${locale}`);
71
- allI18n[locale] = { ...allI18n['en_US'],
66
+ allI18n[locale] = { ...jsResourceBase,
72
67
  ...localeData
73
68
  };
74
69
 
@@ -97,7 +92,7 @@ function loadI18nData(options, compilation) {
97
92
  const {
98
93
  allI18n,
99
94
  locales
100
- } = loadAllLocaleFiles(propertiesPath, baseFileName, compilation);
95
+ } = loadAllLocaleFiles(propertiesPath, baseFileName, compilation, jsResourceBase);
101
96
  return {
102
97
  jsResourceBase,
103
98
  allI18n,
@@ -43,7 +43,15 @@ function configI18nNumericIndexPlugin(options) {
43
43
  } // Empty prefix - HtmlWebpackPlugin handles publicPath
44
44
 
45
45
 
46
- const i18nAssetsPublicPathPrefix = '';
46
+ const i18nAssetsPublicPathPrefix = ''; // Smart contenthash detection based on template content
47
+
48
+ const hasContentHashInNumeric = i18nOpts.numericFilenameTemplate.includes('[contenthash]');
49
+ const hasContentHashInDynamic = i18nOpts.dynamicFilenameTemplate.includes('[contenthash]');
50
+ const hasContentHashInSingle = i18nOpts.singleFileTemplate?.includes('[contenthash]'); // Determine if hashing should be enabled based on template content
51
+
52
+ const shouldIncludeContentHash = i18nOpts.singleFile ? hasContentHashInSingle : hasContentHashInNumeric || hasContentHashInDynamic; // Use explicit includeContentHash if provided, otherwise use smart detection
53
+
54
+ const finalIncludeContentHash = i18nOpts.includeContentHash !== undefined ? i18nOpts.includeContentHash : shouldIncludeContentHash;
47
55
  const numericIndexPluginOptions = {
48
56
  enable: i18nOpts.enable,
49
57
  jsResourcePath: i18nOpts.jsResourcePath,
@@ -53,9 +61,10 @@ function configI18nNumericIndexPlugin(options) {
53
61
  allI18nObject,
54
62
  numericFilenameTemplate: i18nOpts.numericFilenameTemplate,
55
63
  dynamicFilenameTemplate: i18nOpts.dynamicFilenameTemplate,
64
+ singleFileTemplate: i18nOpts.singleFileTemplate,
56
65
  jsonpFunc: i18nOpts.jsonpFunc,
57
66
  singleFile: i18nOpts.singleFile || false,
58
- includeContentHash: i18nOpts.includeContentHash || false,
67
+ includeContentHash: finalIncludeContentHash,
59
68
  generateManifest: i18nOpts.generateManifest || false
60
69
  };
61
70
  const htmlInjectorOptions = {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@zohodesk/client_build_tool",
3
- "version": "0.0.11-exp.6.kiren",
3
+ "version": "0.0.11-exp.7",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@zohodesk/client_build_tool",
9
- "version": "0.0.11-exp.6.kiren",
9
+ "version": "0.0.11-exp.7",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@babel/cli": "7.17.10",
@@ -9577,8 +9577,7 @@
9577
9577
  "@webpack-cli/configtest": {
9578
9578
  "version": "1.2.0",
9579
9579
  "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz",
9580
- "integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==",
9581
- "requires": {}
9580
+ "integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg=="
9582
9581
  },
9583
9582
  "@webpack-cli/info": {
9584
9583
  "version": "1.5.0",
@@ -9591,8 +9590,7 @@
9591
9590
  "@webpack-cli/serve": {
9592
9591
  "version": "1.7.0",
9593
9592
  "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz",
9594
- "integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==",
9595
- "requires": {}
9593
+ "integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q=="
9596
9594
  },
9597
9595
  "@xtuc/ieee754": {
9598
9596
  "version": "1.2.0",
@@ -9679,8 +9677,7 @@
9679
9677
  "acorn-import-assertions": {
9680
9678
  "version": "1.8.0",
9681
9679
  "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz",
9682
- "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==",
9683
- "requires": {}
9680
+ "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw=="
9684
9681
  },
9685
9682
  "acorn-walk": {
9686
9683
  "version": "8.2.0",
@@ -9727,8 +9724,7 @@
9727
9724
  "ajv-keywords": {
9728
9725
  "version": "3.5.2",
9729
9726
  "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
9730
- "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
9731
- "requires": {}
9727
+ "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ=="
9732
9728
  },
9733
9729
  "ansi-regex": {
9734
9730
  "version": "5.0.1",
@@ -10260,8 +10256,7 @@
10260
10256
  "css-declaration-sorter": {
10261
10257
  "version": "6.3.1",
10262
10258
  "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.3.1.tgz",
10263
- "integrity": "sha512-fBffmak0bPAnyqc/HO8C3n2sHrp9wcqQz6ES9koRF2/mLOVAx9zIQ3Y7R29sYCteTPqMCwns4WYQoCX91Xl3+w==",
10264
- "requires": {}
10259
+ "integrity": "sha512-fBffmak0bPAnyqc/HO8C3n2sHrp9wcqQz6ES9koRF2/mLOVAx9zIQ3Y7R29sYCteTPqMCwns4WYQoCX91Xl3+w=="
10265
10260
  },
10266
10261
  "css-loader": {
10267
10262
  "version": "6.7.1",
@@ -10429,8 +10424,7 @@
10429
10424
  "cssnano-utils": {
10430
10425
  "version": "3.1.0",
10431
10426
  "resolved": "https://registry.npmjs.org/cssnano-utils/-/cssnano-utils-3.1.0.tgz",
10432
- "integrity": "sha512-JQNR19/YZhz4psLX/rQ9M83e3z2Wf/HdJbryzte4a3NSuafyp9w/I4U+hx5C2S9g41qlstH7DEWnZaaj83OuEA==",
10433
- "requires": {}
10427
+ "integrity": "sha512-JQNR19/YZhz4psLX/rQ9M83e3z2Wf/HdJbryzte4a3NSuafyp9w/I4U+hx5C2S9g41qlstH7DEWnZaaj83OuEA=="
10434
10428
  },
10435
10429
  "csso": {
10436
10430
  "version": "4.2.0",
@@ -11128,8 +11122,7 @@
11128
11122
  "icss-utils": {
11129
11123
  "version": "5.1.0",
11130
11124
  "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz",
11131
- "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==",
11132
- "requires": {}
11125
+ "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA=="
11133
11126
  },
11134
11127
  "ignore": {
11135
11128
  "version": "5.2.4",
@@ -11945,26 +11938,22 @@
11945
11938
  "postcss-discard-comments": {
11946
11939
  "version": "5.1.2",
11947
11940
  "resolved": "https://registry.npmjs.org/postcss-discard-comments/-/postcss-discard-comments-5.1.2.tgz",
11948
- "integrity": "sha512-+L8208OVbHVF2UQf1iDmRcbdjJkuBF6IS29yBDSiWUIzpYaAhtNl6JYnYm12FnkeCwQqF5LeklOu6rAqgfBZqQ==",
11949
- "requires": {}
11941
+ "integrity": "sha512-+L8208OVbHVF2UQf1iDmRcbdjJkuBF6IS29yBDSiWUIzpYaAhtNl6JYnYm12FnkeCwQqF5LeklOu6rAqgfBZqQ=="
11950
11942
  },
11951
11943
  "postcss-discard-duplicates": {
11952
11944
  "version": "5.1.0",
11953
11945
  "resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-5.1.0.tgz",
11954
- "integrity": "sha512-zmX3IoSI2aoenxHV6C7plngHWWhUOV3sP1T8y2ifzxzbtnuhk1EdPwm0S1bIUNaJ2eNbWeGLEwzw8huPD67aQw==",
11955
- "requires": {}
11946
+ "integrity": "sha512-zmX3IoSI2aoenxHV6C7plngHWWhUOV3sP1T8y2ifzxzbtnuhk1EdPwm0S1bIUNaJ2eNbWeGLEwzw8huPD67aQw=="
11956
11947
  },
11957
11948
  "postcss-discard-empty": {
11958
11949
  "version": "5.1.1",
11959
11950
  "resolved": "https://registry.npmjs.org/postcss-discard-empty/-/postcss-discard-empty-5.1.1.tgz",
11960
- "integrity": "sha512-zPz4WljiSuLWsI0ir4Mcnr4qQQ5e1Ukc3i7UfE2XcrwKK2LIPIqE5jxMRxO6GbI3cv//ztXDsXwEWT3BHOGh3A==",
11961
- "requires": {}
11951
+ "integrity": "sha512-zPz4WljiSuLWsI0ir4Mcnr4qQQ5e1Ukc3i7UfE2XcrwKK2LIPIqE5jxMRxO6GbI3cv//ztXDsXwEWT3BHOGh3A=="
11962
11952
  },
11963
11953
  "postcss-discard-overridden": {
11964
11954
  "version": "5.1.0",
11965
11955
  "resolved": "https://registry.npmjs.org/postcss-discard-overridden/-/postcss-discard-overridden-5.1.0.tgz",
11966
- "integrity": "sha512-21nOL7RqWR1kasIVdKs8HNqQJhFxLsyRfAnUDm4Fe4t4mCWL9OJiHvlHPjcd8zc5Myu89b/7wZDnOSjFgeWRtw==",
11967
- "requires": {}
11956
+ "integrity": "sha512-21nOL7RqWR1kasIVdKs8HNqQJhFxLsyRfAnUDm4Fe4t4mCWL9OJiHvlHPjcd8zc5Myu89b/7wZDnOSjFgeWRtw=="
11968
11957
  },
11969
11958
  "postcss-loader": {
11970
11959
  "version": "7.0.2",
@@ -12045,8 +12034,7 @@
12045
12034
  "postcss-modules-extract-imports": {
12046
12035
  "version": "3.0.0",
12047
12036
  "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz",
12048
- "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==",
12049
- "requires": {}
12037
+ "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw=="
12050
12038
  },
12051
12039
  "postcss-modules-local-by-default": {
12052
12040
  "version": "4.0.0",
@@ -12077,8 +12065,7 @@
12077
12065
  "postcss-normalize-charset": {
12078
12066
  "version": "5.1.0",
12079
12067
  "resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-5.1.0.tgz",
12080
- "integrity": "sha512-mSgUJ+pd/ldRGVx26p2wz9dNZ7ji6Pn8VWBajMXFf8jk7vUoSrZ2lt/wZR7DtlZYKesmZI680qjr2CeFF2fbUg==",
12081
- "requires": {}
12068
+ "integrity": "sha512-mSgUJ+pd/ldRGVx26p2wz9dNZ7ji6Pn8VWBajMXFf8jk7vUoSrZ2lt/wZR7DtlZYKesmZI680qjr2CeFF2fbUg=="
12082
12069
  },
12083
12070
  "postcss-normalize-display-values": {
12084
12071
  "version": "5.1.0",
@@ -13294,8 +13281,7 @@
13294
13281
  "ws": {
13295
13282
  "version": "7.5.9",
13296
13283
  "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
13297
- "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
13298
- "requires": {}
13284
+ "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q=="
13299
13285
  }
13300
13286
  }
13301
13287
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/client_build_tool",
3
- "version": "0.0.11-exp.7",
3
+ "version": "0.0.11-exp.9",
4
4
  "description": "A CLI tool to build web applications and client libraries",
5
5
  "main": "lib/index.js",
6
6
  "bin": {