@zohodesk/client_build_tool 0.0.1-0.exp.0.0.9 → 0.0.1-0.exp.1.0.3

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +0 -10
  2. package/README.md +0 -10
  3. package/lib/schemas/defaultConfigValues.js +14 -63
  4. package/lib/schemas/defaultConfigValuesOnly.js +6 -10
  5. package/lib/shared/babel/getBabelPlugin.js +4 -9
  6. package/lib/shared/babel/runBabelForTsFile.js +1 -1
  7. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +14 -12
  8. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +90 -426
  9. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin_simplified.js +129 -0
  10. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/i18nDataLoader.js +134 -0
  11. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +113 -0
  12. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +5 -66
  13. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +0 -3
  14. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectAstKeys.js +4 -6
  15. package/lib/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +1 -6
  16. package/lib/shared/bundler/webpack/jsLoaders.js +12 -7
  17. package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +37 -88
  18. package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +67 -191
  19. package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +27 -99
  20. package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +1 -4
  21. package/lib/shared/bundler/webpack/plugins.js +3 -20
  22. package/lib/shared/bundler/webpack/utils/i18n/collectAstKeys.js +96 -0
  23. package/lib/shared/bundler/webpack/utils/propertiesParser.js +1 -1
  24. package/lib/shared/server/mockApiHandler.js +0 -7
  25. package/npm-shrinkwrap.json +32 -8225
  26. package/package.json +5 -6
  27. package/lib/shared/bundler/webpack/common/hashUtils.js +0 -20
  28. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/CLAUDE.md +0 -0
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ const path = require('path');
4
+
5
+ const {
6
+ sources,
7
+ Compilation
8
+ } = require('webpack');
9
+
10
+ const {
11
+ decodeUnicodeEscapes
12
+ } = require('../../utils/propertiesParser');
13
+
14
+ const {
15
+ loadNumericMap,
16
+ loadI18nData
17
+ } = require('./utils/i18nDataLoader');
18
+
19
+ const {
20
+ RawSource
21
+ } = sources;
22
+ const pluginName = 'I18nNumericIndexPlugin';
23
+
24
+ class I18nNumericIndexPlugin {
25
+ constructor(options = {}) {
26
+ this.options = options;
27
+ this.numericMap = null;
28
+ this.i18nData = null;
29
+ }
30
+
31
+ getNumericMap(compilation) {
32
+ if (!this.numericMap) {
33
+ const mapPath = path.resolve(compilation.compiler.context, this.options.numericMapPath);
34
+ this.numericMap = loadNumericMap(mapPath, compilation);
35
+ }
36
+
37
+ return this.numericMap;
38
+ }
39
+
40
+ getI18nData(compilation) {
41
+ if (!this.i18nData) {
42
+ this.i18nData = loadI18nData(this.options, compilation);
43
+ }
44
+
45
+ return this.i18nData;
46
+ }
47
+
48
+ emitChunk(compilation, filename, locale, data) {
49
+ const content = decodeUnicodeEscapes(JSON.stringify(data));
50
+ const fileContent = `${this.options.jsonpFunc}(${content});`;
51
+ const outputPath = filename.replace(/\[locale\]/g, locale);
52
+ compilation.emitAsset(outputPath, new RawSource(fileContent));
53
+ }
54
+
55
+ apply(compiler) {
56
+ compiler.hooks.thisCompilation.tap(pluginName, compilation => {
57
+ compilation.hooks.processAssets.tapAsync({
58
+ name: pluginName,
59
+ stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
60
+ }, (assets, callback) => {
61
+ if (!this.options.enable) return callback();
62
+ const {
63
+ sortedKeys,
64
+ totalKeys
65
+ } = this.getNumericMap(compilation);
66
+ const {
67
+ jsResourceBase,
68
+ allI18n,
69
+ locales
70
+ } = this.getI18nData(compilation);
71
+ if (!locales.length) return callback(); // Collect dynamic keys used in comments
72
+
73
+ const dynamicKeys = new Set();
74
+
75
+ for (const module of compilation.modules) {
76
+ if (module.buildInfo?.loaderIdentifiedCommentI18nKeys) {
77
+ module.buildInfo.loaderIdentifiedCommentI18nKeys.forEach(key => dynamicKeys.add(key));
78
+ }
79
+ }
80
+
81
+ const numericKeysSet = new Set(sortedKeys);
82
+ const englishData = allI18n.en || jsResourceBase; // Process each locale
83
+
84
+ locales.forEach(locale => {
85
+ const localeData = allI18n[locale] || {}; // Build numeric data
86
+
87
+ const numericData = {};
88
+
89
+ for (let i = 0; i < totalKeys; i++) {
90
+ const key = sortedKeys[i];
91
+
92
+ if (key && jsResourceBase[key] !== undefined) {
93
+ numericData[i] = localeData[key] ?? englishData[key];
94
+ }
95
+ } // Build dynamic data
96
+
97
+
98
+ const dynamicData = {}; // Add comment keys
99
+
100
+ dynamicKeys.forEach(key => {
101
+ if (!numericKeysSet.has(key) && jsResourceBase[key] !== undefined) {
102
+ dynamicData[key] = localeData[key] ?? englishData[key];
103
+ }
104
+ }); // Add remaining keys
105
+
106
+ Object.keys(jsResourceBase).forEach(key => {
107
+ if (!numericKeysSet.has(key) && !dynamicData[key]) {
108
+ dynamicData[key] = localeData[key] ?? englishData[key];
109
+ }
110
+ }); // Emit chunks
111
+
112
+ if (Object.keys(numericData).length > 0) {
113
+ this.emitChunk(compilation, this.options.numericFilenameTemplate, locale, numericData);
114
+ }
115
+
116
+ if (Object.keys(dynamicData).length > 0) {
117
+ this.emitChunk(compilation, this.options.dynamicFilenameTemplate, locale, dynamicData);
118
+ }
119
+ });
120
+ callback();
121
+ });
122
+ });
123
+ }
124
+
125
+ }
126
+
127
+ module.exports = {
128
+ I18nNumericIndexPlugin
129
+ };
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ const fs = require('fs');
4
+
5
+ const path = require('path');
6
+
7
+ const {
8
+ parseProperties
9
+ } = require('../../utils/propertiesParser');
10
+ /**
11
+ * Loads and parses a properties file
12
+ * @param {string} filePath - Path to the properties file
13
+ * @param {Object} compilation - Webpack compilation object for error reporting
14
+ * @param {string} description - Description for error messages
15
+ * @returns {Object} Parsed properties object
16
+ */
17
+
18
+
19
+ function loadPropertiesFile(filePath, compilation, description) {
20
+ try {
21
+ const content = fs.readFileSync(filePath, 'utf-8');
22
+ return parseProperties(content);
23
+ } catch (err) {
24
+ if (compilation) {
25
+ compilation.errors.push(new Error(`I18nNumericIndexPlugin: Error loading ${description}: ${err.message}`));
26
+ }
27
+
28
+ return {};
29
+ }
30
+ }
31
+ /**
32
+ * Loads numeric mapping from JSON file
33
+ * @param {string} numericMapPath - Path to numeric map JSON file
34
+ * @param {Object} compilation - Webpack compilation object
35
+ * @returns {Object} Object with sortedKeys array and totalKeys count
36
+ */
37
+
38
+
39
+ function loadNumericMap(numericMapPath, compilation) {
40
+ try {
41
+ const fileContent = fs.readFileSync(numericMapPath, 'utf-8');
42
+ const parsedData = JSON.parse(fileContent);
43
+ const sortedKeys = new Array(parsedData.totalKeysInMap);
44
+ Object.entries(parsedData.originalKeyToNumericId).forEach(([key, id]) => {
45
+ sortedKeys[id] = key;
46
+ });
47
+ return {
48
+ sortedKeys,
49
+ totalKeys: parsedData.totalKeysInMap
50
+ };
51
+ } catch (err) {
52
+ if (compilation) {
53
+ compilation.errors.push(new Error(`I18nNumericIndexPlugin: Error loading numeric map: ${err.message}`));
54
+ }
55
+
56
+ return {
57
+ sortedKeys: [],
58
+ totalKeys: 0
59
+ };
60
+ }
61
+ }
62
+ /**
63
+ * Loads all locale-specific properties files
64
+ * @param {string} propertiesPath - Path to properties folder
65
+ * @param {string} baseFileName - Base filename (e.g., 'JSResources')
66
+ * @param {Object} compilation - Webpack compilation object
67
+ * @returns {Object} Object with allI18n translations and locales array
68
+ */
69
+
70
+
71
+ function loadAllLocaleFiles(propertiesPath, baseFileName, compilation) {
72
+ const allI18n = {};
73
+ const locales = [];
74
+
75
+ try {
76
+ const files = fs.readdirSync(propertiesPath);
77
+ files.forEach(file => {
78
+ if (!file.endsWith('.properties')) return;
79
+ const name = path.basename(file, '.properties');
80
+ let locale = null;
81
+
82
+ if (name === baseFileName) {
83
+ locale = 'en';
84
+ } else if (name.startsWith(baseFileName + '_')) {
85
+ locale = name.substring(baseFileName.length + 1);
86
+ }
87
+
88
+ if (locale) {
89
+ const filePath = path.join(propertiesPath, file);
90
+ allI18n[locale] = loadPropertiesFile(filePath, compilation, `locale ${locale}`);
91
+ locales.push(locale);
92
+ }
93
+ });
94
+ } catch (err) {
95
+ if (compilation) {
96
+ compilation.errors.push(new Error(`I18nNumericIndexPlugin: Error reading properties folder: ${err.message}`));
97
+ }
98
+ }
99
+
100
+ return {
101
+ allI18n,
102
+ locales
103
+ };
104
+ }
105
+ /**
106
+ * Loads all i18n data including base resources and locale-specific translations
107
+ * @param {Object} options - Plugin options
108
+ * @param {Object} compilation - Webpack compilation object
109
+ * @returns {Object} Object with jsResourceBase, allI18n, and locales
110
+ */
111
+
112
+
113
+ function loadI18nData(options, compilation) {
114
+ const jsResourcePath = path.resolve(compilation.compiler.context, options.jsResourcePath);
115
+ const propertiesPath = path.resolve(compilation.compiler.context, options.propertiesFolderPath);
116
+ const baseFileName = path.basename(options.jsResourcePath, '.properties');
117
+ const jsResourceBase = loadPropertiesFile(jsResourcePath, compilation, 'JS resources');
118
+ const {
119
+ allI18n,
120
+ locales
121
+ } = loadAllLocaleFiles(propertiesPath, baseFileName, compilation);
122
+ return {
123
+ jsResourceBase,
124
+ allI18n,
125
+ locales
126
+ };
127
+ }
128
+
129
+ module.exports = {
130
+ loadPropertiesFile,
131
+ loadNumericMap,
132
+ loadAllLocaleFiles,
133
+ loadI18nData
134
+ };
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ const fs = require('fs');
4
+
5
+ const path = require('path');
6
+
7
+ const {
8
+ parseProperties
9
+ } = require('../../../utils/propertiesParser');
10
+
11
+ function loadPropertiesFile(filePath, compilation, description) {
12
+ try {
13
+ const content = fs.readFileSync(filePath, 'utf-8');
14
+ const parsed = parseProperties(content);
15
+ return parsed;
16
+ } catch (err) {
17
+ if (compilation) {
18
+ compilation.errors.push(new Error(`I18nNumericIndexPlugin: Error loading ${description}: ${err.message}`));
19
+ }
20
+
21
+ return {};
22
+ }
23
+ }
24
+
25
+ function loadNumericMap(numericMapPath, compilation) {
26
+ try {
27
+ const fileContent = fs.readFileSync(numericMapPath, 'utf-8');
28
+ const parsedData = JSON.parse(fileContent);
29
+ const sortedKeys = new Array(parsedData.totalKeysInMap);
30
+ Object.entries(parsedData.originalKeyToNumericId).forEach(([key, id]) => {
31
+ sortedKeys[id] = key;
32
+ });
33
+ return {
34
+ sortedKeys,
35
+ totalKeys: parsedData.totalKeysInMap
36
+ };
37
+ } catch (err) {
38
+ if (compilation) {
39
+ compilation.errors.push(new Error(`I18nNumericIndexPlugin: Error loading numeric map: ${err.message}`));
40
+ }
41
+
42
+ return {
43
+ sortedKeys: [],
44
+ totalKeys: 0
45
+ };
46
+ }
47
+ }
48
+
49
+ function loadAllLocaleFiles(propertiesPath, baseFileName, compilation) {
50
+ const allI18n = {};
51
+ const locales = [];
52
+
53
+ try {
54
+ 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
+ files.forEach(file => {
64
+ if (!file.endsWith('.properties')) return;
65
+ const match = file.match(/^ApplicationResources_([a-z]{2}_[A-Z]{2})\.properties$/);
66
+
67
+ if (match) {
68
+ const locale = match[1];
69
+ const filePath = path.join(propertiesPath, file);
70
+ const localeData = loadPropertiesFile(filePath, compilation, `locale ${locale}`);
71
+ allI18n[locale] = { ...allI18n['en_US'],
72
+ ...localeData
73
+ };
74
+
75
+ if (!locales.includes(locale)) {
76
+ locales.push(locale);
77
+ }
78
+ }
79
+ });
80
+ } catch (err) {
81
+ if (compilation) {
82
+ compilation.errors.push(new Error(`I18nNumericIndexPlugin: Error reading properties folder: ${err.message}`));
83
+ }
84
+ }
85
+
86
+ return {
87
+ allI18n,
88
+ locales
89
+ };
90
+ }
91
+
92
+ function loadI18nData(options, compilation) {
93
+ const jsResourcePath = path.resolve(compilation.compiler.context, options.jsResourcePath);
94
+ const propertiesPath = path.resolve(compilation.compiler.context, options.propertiesFolderPath);
95
+ const baseFileName = path.basename(options.jsResourcePath, '.properties');
96
+ const jsResourceBase = loadPropertiesFile(jsResourcePath, compilation, 'JS resources');
97
+ const {
98
+ allI18n,
99
+ locales
100
+ } = loadAllLocaleFiles(propertiesPath, baseFileName, compilation);
101
+ return {
102
+ jsResourceBase,
103
+ allI18n,
104
+ locales
105
+ };
106
+ }
107
+
108
+ module.exports = {
109
+ loadPropertiesFile,
110
+ loadNumericMap,
111
+ loadAllLocaleFiles,
112
+ loadI18nData
113
+ };
@@ -7,10 +7,6 @@ exports.I18nFilesEmitPlugin = void 0;
7
7
 
8
8
  var _webpack = require("webpack");
9
9
 
10
- var _fs = _interopRequireDefault(require("fs"));
11
-
12
- var _path = _interopRequireDefault(require("path"));
13
-
14
10
  var _createHash = require("./createHash");
15
11
 
16
12
  var _pathCreator = require("./pathCreator");
@@ -19,8 +15,6 @@ var _propertiesUtils = require("./utils/propertiesUtils");
19
15
 
20
16
  var _LocaleChunkAssetsStore = require("./LocaleChunkAssetsStore");
21
17
 
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
18
  /* eslint-disable no-restricted-syntax */
25
19
  const pluginName = 'I18nFilesEmitPlugin';
26
20
  const {
@@ -29,57 +23,18 @@ const {
29
23
 
30
24
  class I18nFilesEmitPlugin {
31
25
  constructor(options) {
32
- this.options = options;
33
- this.numericIdMap = null; // this.options = {
26
+ this.options = options; // this.options = {
34
27
  // locales: options.locales,
35
28
  // chunkFilename: options.chunkFilename,
36
29
  // filename: options.filename,
37
30
  // allI18nObject: options.allI18nObject,
38
- // jsonpFunc: options.jsonpFunc,
39
- // useNumericIndexing: options.useNumericIndexing, // NEW OPTION
40
- // numericMapPath: options.numericMapPath // NEW OPTION
31
+ // jsonpFunc: options.jsonpFunc
41
32
  // };
42
33
  }
43
34
 
44
- loadNumericIdMap(compilation) {
45
- if (this.numericIdMap || !this.options.useNumericIndexing || !this.options.numericMapPath) {
46
- return this.numericIdMap;
47
- }
48
-
49
- const absoluteMapPath = _path.default.isAbsolute(this.options.numericMapPath) ? this.options.numericMapPath : _path.default.resolve(compilation.compiler.context, this.options.numericMapPath);
50
-
51
- try {
52
- if (_fs.default.existsSync(absoluteMapPath)) {
53
- const fileContent = _fs.default.readFileSync(absoluteMapPath, 'utf-8');
54
-
55
- const parsedData = JSON.parse(fileContent);
56
-
57
- if (parsedData && parsedData.originalKeyToNumericId && typeof parsedData.originalKeyToNumericId === 'object') {
58
- this.numericIdMap = parsedData.originalKeyToNumericId;
59
- } else {
60
- compilation.warnings.push(new Error(`${pluginName}: Invalid numeric map format in ${absoluteMapPath}`));
61
- this.numericIdMap = {};
62
- }
63
- } else {
64
- compilation.warnings.push(new Error(`${pluginName}: Numeric map file not found: ${absoluteMapPath}`));
65
- this.numericIdMap = {};
66
- }
67
- } catch (err) {
68
- compilation.errors.push(new Error(`${pluginName}: Error loading numeric map from ${absoluteMapPath}: ${err.message}`));
69
- this.numericIdMap = {};
70
- }
71
-
72
- return this.numericIdMap;
73
- }
74
-
75
35
  apply(compiler) {
76
36
  compiler.hooks.thisCompilation.tap(pluginName, compilation => {
77
- // Load numeric map if needed
78
- if (this.options.useNumericIndexing) {
79
- this.loadNumericIdMap(compilation);
80
- } // Get store for cache
81
-
82
-
37
+ // Get store for cache
83
38
  this.store = (0, _LocaleChunkAssetsStore.getLocaleChunkAssetsStore)(compilation);
84
39
  const i18nStore = this.store;
85
40
  compilation.hooks.beforeHash.tap(pluginName, () => {
@@ -195,28 +150,12 @@ class I18nFilesEmitPlugin {
195
150
 
196
151
  getI18nContentForkeys(i18nKeys, locale) {
197
152
  const {
198
- allI18nObject,
199
- useNumericIndexing
153
+ allI18nObject
200
154
  } = this.options;
201
155
  const data = {};
202
156
 
203
157
  for (const key of i18nKeys) {
204
- const value = allI18nObject[locale][key];
205
-
206
- if (useNumericIndexing && this.numericIdMap) {
207
- // Use numeric ID as key if available, otherwise keep original key
208
- const numericId = this.numericIdMap[key];
209
-
210
- if (numericId !== undefined) {
211
- data[numericId] = value;
212
- } else {
213
- // Keep original key if no numeric mapping exists
214
- data[key] = value;
215
- }
216
- } else {
217
- // Default behavior: use original key
218
- data[key] = value;
219
- }
158
+ data[key] = allI18nObject[locale][key];
220
159
  }
221
160
 
222
161
  return data;
@@ -40,9 +40,6 @@ function optionsHandler(options) {
40
40
  jsResourceI18nKeys,
41
41
  allI18nObject,
42
42
  locales,
43
- // NEW OPTIONS FOR NUMERIC INDEXING
44
- useNumericIndexing: options.useNumericIndexing,
45
- numericMapPath: options.numericMapPath,
46
43
  // template: (object, locale) => `window.loadI18n(${JSON.stringify(object)}, ${JSON.stringify(locale)})`,
47
44
  runtime: true,
48
45
  runtimeOptions: {
@@ -7,8 +7,7 @@ const {
7
7
  const PREFIX_I18N_COMMENT = 'I18N';
8
8
  const PREFIX_I18N_COMMENT_DYNAMIC = 'dynamic-i18n-key';
9
9
 
10
- function getI18nKeysFromSingleComment(commentNode, validKeysSet, isDebug = false) {
11
- const functionName = '[getI18nKeysFromSingleComment]';
10
+ function getI18nKeysFromSingleComment(commentNode, validKeysSet) {
12
11
  const foundKeysInComment = [];
13
12
 
14
13
  if (!commentNode || typeof commentNode.value !== 'string') {
@@ -50,13 +49,12 @@ function getI18nKeysFromSingleComment(commentNode, validKeysSet, isDebug = false
50
49
 
51
50
 
52
51
  function collectAndCategorizeUsedI18nKeys(astProgramNode, commentsArray, allI18nKeysMasterMap, isDebug = false) {
53
- const functionName = '[collectAndCategorizeUsedI18nKeys]';
54
52
  const foundLiteralKeys = new Set();
55
53
  const foundCommentKeys = new Set();
56
54
  const validKeysSet = new Set(Object.keys(allI18nKeysMasterMap || {}));
57
55
 
58
56
  if (validKeysSet.size === 0 && isDebug) {
59
- console.warn(`${functionName} allI18nKeysMasterMap is empty. No keys can be collected.`);
57
+ console.warn('[collectAndCategorizeUsedI18nKeys] allI18nKeysMasterMap is empty. No keys can be collected.');
60
58
  } // 1. Collect keys from AST string literals
61
59
 
62
60
 
@@ -73,14 +71,14 @@ function collectAndCategorizeUsedI18nKeys(astProgramNode, commentsArray, allI18n
73
71
 
74
72
  });
75
73
  } catch (error) {
76
- console.error(`${functionName} Error during AST walk:`, error);
74
+ console.error('[collectAndCategorizeUsedI18nKeys] Error during AST walk:', error);
77
75
  }
78
76
  } // 2. Collect keys from comments
79
77
 
80
78
 
81
79
  if (commentsArray && Array.isArray(commentsArray)) {
82
80
  commentsArray.forEach(commentNode => {
83
- const keysFromComment = getI18nKeysFromSingleComment(commentNode, validKeysSet, isDebug);
81
+ const keysFromComment = getI18nKeysFromSingleComment(commentNode, validKeysSet);
84
82
  keysFromComment.forEach(key => {
85
83
  foundCommentKeys.add(key);
86
84
  });
@@ -36,7 +36,7 @@ function getI18nAssetsForChunkAsArrayStr({
36
36
  chunkSplitEnable,
37
37
  i18nFileNameTemplate
38
38
  }) {
39
- if (!chunkSplitEnable || !i18nStore) {
39
+ if (!chunkSplitEnable) {
40
40
  // NOTE: we have used lang variable inside
41
41
  // NOTE: below code for full i18n for now it is not implemented
42
42
  // if (!chunkSplitEnable) {
@@ -71,11 +71,6 @@ function getI18nAssetForChunkAsStr({
71
71
  i18nStore,
72
72
  i18nFileNameTemplate
73
73
  }) {
74
- // Handle case where i18nStore is undefined (when i18nChunkSplit is disabled or not initialized)
75
- if (!i18nStore || !i18nStore.isChunkHasI18n) {
76
- return '';
77
- }
78
-
79
74
  if (!i18nStore.isChunkHasI18n(chunk)) {
80
75
  return '';
81
76
  }
@@ -7,18 +7,23 @@ exports.jsLoaders = jsLoaders;
7
7
 
8
8
  var _babelLoaderConfig = require("./loaderConfigs/babelLoaderConfig");
9
9
 
10
- var {
10
+ const {
11
11
  i18nIdReplaceLoaderConfig
12
- } = require("./loaderConfigs/i18nIdReplaceLoaderConfig");
12
+ } = require('./loaderConfigs/i18nIdReplaceLoaderConfig');
13
13
 
14
14
  function jsLoaders(options) {
15
- const useLoaders = [(0, _babelLoaderConfig.babelLoaderConfig)(options)];
15
+ const useLoaders = [];
16
+ useLoaders.push((0, _babelLoaderConfig.babelLoaderConfig)(options));
17
+ const shouldUseNumericIndexing = options.i18nIndexing && options.i18nIndexing.enable || options.i18nChunkSplit && options.i18nChunkSplit.chunkSplitEnable && options.i18nChunkSplit.useNumericIndexing;
16
18
 
17
- if (options.i18nIndexing && options.i18nIndexing.enable) {
18
- const i18nLoader = i18nIdReplaceLoaderConfig(options);
19
+ if (shouldUseNumericIndexing) {
20
+ try {
21
+ const loaderConfig = i18nIdReplaceLoaderConfig(options, options.context);
19
22
 
20
- if (i18nLoader) {
21
- useLoaders.push(i18nLoader);
23
+ if (loaderConfig) {
24
+ useLoaders.push(loaderConfig);
25
+ }
26
+ } catch (err) {// Silently skip if configuration fails
22
27
  }
23
28
  }
24
29