@zohodesk/client_build_tool 0.0.11-exp.18 → 0.0.11-exp.18.0

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 +28 -0
  2. package/README.md +130 -0
  3. package/README_backup.md +102 -0
  4. package/docs/DYNAMIC_TEMPLATE_EXAMPLE.md +129 -0
  5. package/docs/I18N_NUMERIC_INDEXING_PLUGIN.md +225 -0
  6. package/docs/I18N_SINGLE_FILE_MODE.md +126 -0
  7. package/docs/client_build_tool_source_doc.md +390 -0
  8. package/lib/schemas/defaultConfigValues.js +46 -1
  9. package/lib/schemas/defaultConfigValuesOnly.js +31 -4
  10. package/lib/shared/babel/getBabelPlugin.js +3 -4
  11. package/lib/shared/babel/runBabelForTsFile.js +1 -1
  12. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js +139 -0
  13. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +98 -0
  14. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +399 -0
  15. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +141 -0
  16. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +19 -1
  17. package/lib/shared/bundler/webpack/jsLoaders.js +24 -1
  18. package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +90 -0
  19. package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +146 -0
  20. package/lib/shared/bundler/webpack/pluginConfigs/configI18nIndexingPlugin.js +42 -0
  21. package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericHtmlInjector.js +92 -0
  22. package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +112 -0
  23. package/lib/shared/bundler/webpack/plugins.js +3 -1
  24. package/lib/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +1 -1
  25. package/lib/shared/server/mockApiHandler.js +7 -0
  26. package/lib/shared/server/urlConcat.js +4 -3
  27. package/npm-shrinkwrap.json +8225 -32
  28. package/package.json +6 -5
package/CHANGELOG.md CHANGED
@@ -1,6 +1,34 @@
1
1
  # Changelog and Release Notes
2
2
 
3
+ - remove babel-plugin-module-resolver dependencies
3
4
 
5
+ **Adjustments:-**
6
+ - Public Folder configuration is separated for development and production
7
+
8
+ **Bug Fix:-**
9
+ - Fixed the issue where the build log was not visible when `stats (bundle integrity)` was enabled. The problem was resolved by adding an error check in the `bundleIntegrity plugin`.
10
+ - Removed the babel-plugin-module-resolver dependency to resolve the alias resolution issue in the application.
11
+ - Fixed the issue where a space in the variable name causes it to return an undefined value.
12
+ - Fixed the URL path generation issue that occurred while using context in the development setup.
13
+
14
+
15
+
16
+ # v0.0.11
17
+
18
+ # v0.0.10 (12-05-2025)
19
+ **Feature:-**
20
+ - `alias` support for `build:es` and `build:lib`
21
+ - Add babel-plugin-module-resolver dependencies
22
+ - Modify getBabelPlugin to include module resolver with aliases
23
+
24
+ **Bug Fix:-**
25
+ - Enhance runBabelForTSFile to handle both .tsx and .ts file extensions
26
+ - Update mockApiHandler to ensure mock function is called correctly
27
+
28
+ **Change:-**
29
+ - Refactor defaultConfigValues.js to include cli options for enableRTLSplit
30
+
31
+ ## v0.0.9
4
32
 
5
33
  **Feature:-**
6
34
  - externals was added to Prevent bundling of certain imported packages and retrieve these external dependencies at runtime.
package/README.md CHANGED
@@ -100,7 +100,137 @@ fixes :-
100
100
 
101
101
  # Changelog and Release Notes
102
102
 
103
+ - remove babel-plugin-module-resolver dependencies
103
104
 
105
+ **Adjustments:-**
106
+ - Public Folder configuration is separated for development and production
107
+
108
+ **Bug Fix:-**
109
+ - Fixed the issue where the build log was not visible when `stats (bundle integrity)` was enabled. The problem was resolved by adding an error check in the `bundleIntegrity plugin`.
110
+ - Removed the babel-plugin-module-resolver dependency to resolve the alias resolution issue in the application.
111
+ - Fixed the issue where a space in the variable name causes it to return an undefined value.
112
+ - Fixed the URL path generation issue that occurred while using context in the development setup.
113
+
114
+
115
+
116
+ # v0.0.11
117
+
118
+ # v0.0.10 (12-05-2025)
119
+ **Feature:-**
120
+ - `alias` support for `build:es` and `build:lib`
121
+ - Add babel-plugin-module-resolver dependencies
122
+ - Modify getBabelPlugin to include module resolver with aliases
123
+
124
+ **Bug Fix:-**
125
+ - Enhance runBabelForTSFile to handle both .tsx and .ts file extensions
126
+ - Update mockApiHandler to ensure mock function is called correctly
127
+
128
+ **Change:-**
129
+ - Refactor defaultConfigValues.js to include cli options for enableRTLSplit
130
+
131
+ ## v0.0.9
132
+
133
+ **Feature:-**
134
+ - externals was added to Prevent bundling of certain imported packages and retrieve these external dependencies at runtime.
135
+ - to use externals, we use the following pattern in `app > externals` :
136
+
137
+ For example
138
+ ```
139
+ externals: {
140
+ <key> : <value>
141
+ }
142
+ ```
143
+
144
+ ## v0.0.6 (4-09-2023)
145
+
146
+ **Feature:-**
147
+ - Generating bundle integrity report json file for the build assets only in production mode. To use this feature we need to add `stats > enable` or cli flags `enable_stats`.
148
+ - Added Resource Cleanup plugin to cleanup resource retained by build tool. this plugin is controlled by efc flag resourcecleanup flag.
149
+ - added support for using regex expression to get group of chunks chunkId via Resource Hint plugin prefetch/preload hook.
150
+ only will be activate when `resourceHints` => `allowPrefetchingMultipleChunks` as `true`
151
+ - added support for glob pattern for custom chunks split logic.
152
+ - added options to split chunks base config in the key `app` => `customChunksBaseConfig` as object
153
+
154
+ **Change:-**
155
+ - i18n name not generated issue fix.
156
+ - public path not correctly set issue fix.
157
+ - changing plugin hook stages in i18nRuntimePlugin and sourceMapPlugin
158
+ ## v0.0.5 (6-08-2023)
159
+
160
+ **Changes:--**
161
+ - Typo fix in i18nRuntimeDealerPlugin.js
162
+ - fixing some bugs in resolvers.js file
163
+
164
+ ## v0.0.3 (1-08-2023)
165
+
166
+ **Changes:--**
167
+ - `devtool` default value changed from `hidden-cheap-source-map` to `source-map`
168
+ - unwanted files deleted from build
169
+
170
+ **Issue Fix:--**
171
+ - The issue with the source map not being created in the build has been fixed."
172
+
173
+
174
+ ## v0.0.2 (28-04-2023)
175
+
176
+ **Features:-**
177
+
178
+ - `devModeContentHashAllowedTypes` support added for some project there will be a need for hash even though they run dev mode. for details [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/3.0.0/packages/client_build_tool/ConfigurationDocumentation.md#devModeContentHashAllowedTypes)
179
+ - `devLikeHash` support for disable content hash for file names in production mode. for details [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/3.0.0/packages/client_build_tool/ConfigurationDocumentation.md#devLikeHash)
180
+ - `disableReactDevWarning` disable react dev warning such as prop-type warnings will be removed in dev mode build or server. for details [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/3.0.0/packages/client_build_tool/ConfigurationDocumentation.md#disableReactDevWarning) can be enabled via `--disable_react_dev_warning` too.
181
+ - `statsLogConfig` support to customize default webpack log after build finished. for details [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/3.0.0/packages/client_build_tool/ConfigurationDocumentation.md#statsLogConfig) can be enabled via `--disable_react_dev_warning` too.
182
+ - `enableChunkHash` renamed as `enableFileNameHashing`
183
+
184
+ - `pre_processor` command to run the preprocessor.js file.preProcessor runs in build, start, buildEs, buildLib commands bu default. and we have watch mode support as well with the option (`-w`)
185
+ - `createSeparateSmap` flag `source_map_enable` renamed as `enable_smap`
186
+ - `removeAttribute` option changes as `babelCustomizations.removeAttribute`
187
+ - `removePropTypes` support for remove the prop types package in the output build.
188
+ - `devConsoleExclude` support for remove the _console statements_ such as _console.log_, _console.warn_ in the output build.
189
+ - `manifestJson` default value set as false.
190
+ - `customAttributes` support for add attributes to html, link , script tag in the output build.
191
+
192
+
193
+ ## v0.0.1 (18-04-2023)
194
+
195
+ First Release
196
+ **Features:-**
197
+
198
+ - 'start' command to run react app
199
+ - 'build' command to create build for react app
200
+ - 'build:lib' command to create lib for react library
201
+ - 'build:es' command to create es for react library
202
+ - 'templates' command to create es for react library
203
+ # Changelog and Release Notes
204
+
205
+ - remove babel-plugin-module-resolver dependencies
206
+
207
+ **Adjustments:-**
208
+ - Public Folder configuration is separated for development and production
209
+
210
+ **Bug Fix:-**
211
+ - Fixed the issue where the build log was not visible when `stats (bundle integrity)` was enabled. The problem was resolved by adding an error check in the `bundleIntegrity plugin`.
212
+ - Removed the babel-plugin-module-resolver dependency to resolve the alias resolution issue in the application.
213
+ - Fixed the issue where a space in the variable name causes it to return an undefined value.
214
+ - Fixed the URL path generation issue that occurred while using context in the development setup.
215
+
216
+
217
+
218
+ # v0.0.11
219
+
220
+ # v0.0.10 (12-05-2025)
221
+ **Feature:-**
222
+ - `alias` support for `build:es` and `build:lib`
223
+ - Add babel-plugin-module-resolver dependencies
224
+ - Modify getBabelPlugin to include module resolver with aliases
225
+
226
+ **Bug Fix:-**
227
+ - Enhance runBabelForTSFile to handle both .tsx and .ts file extensions
228
+ - Update mockApiHandler to ensure mock function is called correctly
229
+
230
+ **Change:-**
231
+ - Refactor defaultConfigValues.js to include cli options for enableRTLSplit
232
+
233
+ ## v0.0.9
104
234
 
105
235
  **Feature:-**
106
236
  - externals was added to Prevent bundling of certain imported packages and retrieve these external dependencies at runtime.
package/README_backup.md CHANGED
@@ -98,3 +98,105 @@ fixes :-
98
98
 
99
99
  - preload plc undefined url fixed
100
100
 
101
+ # Changelog and Release Notes
102
+
103
+ - remove babel-plugin-module-resolver dependencies
104
+
105
+ **Adjustments:-**
106
+ - Public Folder configuration is separated for development and production
107
+
108
+ **Bug Fix:-**
109
+ - Fixed the issue where the build log was not visible when `stats (bundle integrity)` was enabled. The problem was resolved by adding an error check in the `bundleIntegrity plugin`.
110
+ - Removed the babel-plugin-module-resolver dependency to resolve the alias resolution issue in the application.
111
+ - Fixed the issue where a space in the variable name causes it to return an undefined value.
112
+ - Fixed the URL path generation issue that occurred while using context in the development setup.
113
+
114
+
115
+
116
+ # v0.0.11
117
+
118
+ # v0.0.10 (12-05-2025)
119
+ **Feature:-**
120
+ - `alias` support for `build:es` and `build:lib`
121
+ - Add babel-plugin-module-resolver dependencies
122
+ - Modify getBabelPlugin to include module resolver with aliases
123
+
124
+ **Bug Fix:-**
125
+ - Enhance runBabelForTSFile to handle both .tsx and .ts file extensions
126
+ - Update mockApiHandler to ensure mock function is called correctly
127
+
128
+ **Change:-**
129
+ - Refactor defaultConfigValues.js to include cli options for enableRTLSplit
130
+
131
+ ## v0.0.9
132
+
133
+ **Feature:-**
134
+ - externals was added to Prevent bundling of certain imported packages and retrieve these external dependencies at runtime.
135
+ - to use externals, we use the following pattern in `app > externals` :
136
+
137
+ For example
138
+ ```
139
+ externals: {
140
+ <key> : <value>
141
+ }
142
+ ```
143
+
144
+ ## v0.0.6 (4-09-2023)
145
+
146
+ **Feature:-**
147
+ - Generating bundle integrity report json file for the build assets only in production mode. To use this feature we need to add `stats > enable` or cli flags `enable_stats`.
148
+ - Added Resource Cleanup plugin to cleanup resource retained by build tool. this plugin is controlled by efc flag resourcecleanup flag.
149
+ - added support for using regex expression to get group of chunks chunkId via Resource Hint plugin prefetch/preload hook.
150
+ only will be activate when `resourceHints` => `allowPrefetchingMultipleChunks` as `true`
151
+ - added support for glob pattern for custom chunks split logic.
152
+ - added options to split chunks base config in the key `app` => `customChunksBaseConfig` as object
153
+
154
+ **Change:-**
155
+ - i18n name not generated issue fix.
156
+ - public path not correctly set issue fix.
157
+ - changing plugin hook stages in i18nRuntimePlugin and sourceMapPlugin
158
+ ## v0.0.5 (6-08-2023)
159
+
160
+ **Changes:--**
161
+ - Typo fix in i18nRuntimeDealerPlugin.js
162
+ - fixing some bugs in resolvers.js file
163
+
164
+ ## v0.0.3 (1-08-2023)
165
+
166
+ **Changes:--**
167
+ - `devtool` default value changed from `hidden-cheap-source-map` to `source-map`
168
+ - unwanted files deleted from build
169
+
170
+ **Issue Fix:--**
171
+ - The issue with the source map not being created in the build has been fixed."
172
+
173
+
174
+ ## v0.0.2 (28-04-2023)
175
+
176
+ **Features:-**
177
+
178
+ - `devModeContentHashAllowedTypes` support added for some project there will be a need for hash even though they run dev mode. for details [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/3.0.0/packages/client_build_tool/ConfigurationDocumentation.md#devModeContentHashAllowedTypes)
179
+ - `devLikeHash` support for disable content hash for file names in production mode. for details [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/3.0.0/packages/client_build_tool/ConfigurationDocumentation.md#devLikeHash)
180
+ - `disableReactDevWarning` disable react dev warning such as prop-type warnings will be removed in dev mode build or server. for details [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/3.0.0/packages/client_build_tool/ConfigurationDocumentation.md#disableReactDevWarning) can be enabled via `--disable_react_dev_warning` too.
181
+ - `statsLogConfig` support to customize default webpack log after build finished. for details [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/3.0.0/packages/client_build_tool/ConfigurationDocumentation.md#statsLogConfig) can be enabled via `--disable_react_dev_warning` too.
182
+ - `enableChunkHash` renamed as `enableFileNameHashing`
183
+
184
+ - `pre_processor` command to run the preprocessor.js file.preProcessor runs in build, start, buildEs, buildLib commands bu default. and we have watch mode support as well with the option (`-w`)
185
+ - `createSeparateSmap` flag `source_map_enable` renamed as `enable_smap`
186
+ - `removeAttribute` option changes as `babelCustomizations.removeAttribute`
187
+ - `removePropTypes` support for remove the prop types package in the output build.
188
+ - `devConsoleExclude` support for remove the _console statements_ such as _console.log_, _console.warn_ in the output build.
189
+ - `manifestJson` default value set as false.
190
+ - `customAttributes` support for add attributes to html, link , script tag in the output build.
191
+
192
+
193
+ ## v0.0.1 (18-04-2023)
194
+
195
+ First Release
196
+ **Features:-**
197
+
198
+ - 'start' command to run react app
199
+ - 'build' command to create build for react app
200
+ - 'build:lib' command to create lib for react library
201
+ - 'build:es' command to create es for react library
202
+ - 'templates' command to create es for react library
@@ -0,0 +1,129 @@
1
+ # Dynamic singleFileTemplate Configuration
2
+
3
+ ## Overview
4
+ The `singleFileTemplate` option now supports both static strings and dynamic functions, allowing different filename patterns based on build mode.
5
+
6
+ ## Configuration Options
7
+
8
+ ### 1. Static Template (Simple)
9
+ ```javascript
10
+ i18nIndexing: {
11
+ singleFileTemplate: '[locale].js' // Always uses this format
12
+ }
13
+ ```
14
+
15
+ ### 2. Dynamic Template with Function
16
+ ```javascript
17
+ i18nIndexing: {
18
+ isDevelopment: isDevelopment, // Pass from your app
19
+ singleFileTemplate: (isDev) =>
20
+ isDev ? '[locale].js' : '[locale].[contenthash].js'
21
+ }
22
+ ```
23
+
24
+ ### 3. Inline Conditional (Pre-resolved)
25
+ ```javascript
26
+ i18nIndexing: {
27
+ isDevelopment: isDevelopment, // Pass from your app
28
+ singleFileTemplate: isDevelopment
29
+ ? '[locale].js'
30
+ : '[locale].[contenthash].js'
31
+ }
32
+ ```
33
+
34
+ ## Template Placeholders
35
+
36
+ - `[locale]` - Replaced with actual locale code (e.g., en_US, fr_FR)
37
+ - `[contenthash]` - Replaced with content-based hash for cache busting
38
+
39
+ ## Output Examples
40
+
41
+ ### Development Mode (isDevelopment = true)
42
+ ```
43
+ Template: '[locale].js'
44
+ Output:
45
+ i18n/en_US.js
46
+ i18n/fr_FR.js
47
+ i18n/de_DE.js
48
+ ```
49
+
50
+ ### Production Mode (isDevelopment = false)
51
+ ```
52
+ Template: '[locale].[contenthash].js'
53
+ Output:
54
+ i18n/en_US.b9ef890a.js
55
+ i18n/fr_FR.3452451e.js
56
+ i18n/de_DE.e8b84364.js
57
+ ```
58
+
59
+ ## Complete Example Configuration
60
+
61
+ ```javascript
62
+ exports.config = {
63
+ context: 'src',
64
+ output: 'build',
65
+ mode: process.env.NODE_ENV || 'production',
66
+
67
+ // Pass isDevelopment from your app
68
+ isDevelopment: process.env.NODE_ENV === 'development',
69
+
70
+ i18nIndexing: {
71
+ enable: true,
72
+ outputFolder: 'i18n',
73
+ jsResourcePath: './resources/ApplicationResources.properties',
74
+ propertiesFolderPath: './resources',
75
+ numericMapPath: './numericMap.json',
76
+
77
+ // Dynamic template based on build mode
78
+ singleFileTemplate: function(isDevelopment) {
79
+ return isDevelopment ? '[locale].js' : '[locale].[contenthash].js';
80
+ },
81
+
82
+ // Or using arrow function
83
+ // singleFileTemplate: (isDev) => isDev ? '[locale].js' : '[locale].[contenthash].js',
84
+
85
+ // Or pre-resolved
86
+ // singleFileTemplate: isDevelopment ? '[locale].js' : '[locale].[contenthash].js',
87
+
88
+ singleFile: true,
89
+ jsonpFunc: 'var imAppI18n=',
90
+ htmlTemplateLabel: '{{--user-locale}}',
91
+ localeVarName: 'window.userLangCode',
92
+ generateManifest: true,
93
+ manifestPath: 'i18n/manifest.json'
94
+
95
+ // Note: includeContentHash is now optional when using [contenthash] in template
96
+ // includeContentHash: true // Not needed with [contenthash] placeholder
97
+ }
98
+ };
99
+ ```
100
+
101
+ ## Benefits
102
+
103
+ 1. **Development**: Clean, readable filenames without hashes for easier debugging
104
+ 2. **Production**: Content-hashed filenames for optimal caching
105
+ 3. **Flexibility**: Single configuration handles both environments
106
+ 4. **No Redundancy**: Using `[contenthash]` in template eliminates need for `includeContentHash` option
107
+
108
+ ## Migration from includeContentHash
109
+
110
+ ### Old Way
111
+ ```javascript
112
+ singleFileTemplate: '[locale].js',
113
+ includeContentHash: true // Adds hash before .js
114
+ // Output: en_US.abc123.js
115
+ ```
116
+
117
+ ### New Way (Recommended)
118
+ ```javascript
119
+ singleFileTemplate: isDevelopment ? '[locale].js' : '[locale].[contenthash].js'
120
+ // Output: en_US.abc123.js (production) or en_US.js (development)
121
+ ```
122
+
123
+ ## Notes
124
+
125
+ - The function receives `isDevelopment` as a boolean parameter
126
+ - You must pass `isDevelopment` in your main options object
127
+ - The `[contenthash]` placeholder is automatically replaced with the actual hash
128
+ - For HTML injection, the hash placeholder is removed since the exact hash isn't known at HTML generation time
129
+ - The manifest will map clean names to hashed versions for deployment scripts
@@ -0,0 +1,225 @@
1
+ # I18n Numeric Indexing Plugin Documentation
2
+
3
+ ## Overview
4
+ The I18nNumericIndexPlugin is a webpack plugin that implements lazy loading for i18n translations with numeric indexing to reduce bundle size. It separates translations into multiple chunks that load on-demand.
5
+
6
+ ## Features
7
+
8
+ ### 1. **Numeric Indexing**
9
+ - Replaces string keys with numeric IDs (e.g., "support.label.home" → "1")
10
+ - Reduces bundle size by ~40%
11
+ - Maintains backward compatibility
12
+
13
+ ### 2. **Custom Group Support**
14
+ - Define translation groups using banner markers in JSResources.properties
15
+ - Each group generates a separate chunk
16
+ - Groups load automatically when their associated code chunks load
17
+
18
+ ### 3. **Lazy Loading**
19
+ - Initial load: Only numeric.i18n.js and dynamic.i18n.js
20
+ - Setup translations: Load only when SetupHome chunk loads
21
+ - Other groups: Load on-demand based on configuration
22
+
23
+ ## Configuration
24
+
25
+ ### In `cbt.config.js`:
26
+
27
+ ```javascript
28
+ exports.config = {
29
+ i18nIndexing: {
30
+ enable: true,
31
+ jsResourcePath: './deskapp/properties/JSResources.properties',
32
+ propertiesFolderPath: './deskapp/properties',
33
+ numericMapPath: './deskapp/properties/i18n-numeric-map.json',
34
+ numericFilenameTemplate: 'i18n-chunk/[locale]/numeric.i18n.js',
35
+ dynamicFilenameTemplate: 'i18n-chunk/[locale]/dynamic.i18n.js',
36
+ jsonpFunc: 'window.loadI18nChunk',
37
+ htmlTemplateLabel: '{{--user-locale}}',
38
+ localeVarName: 'window.userLangCode',
39
+ customGroups: {
40
+ setup: {
41
+ bannerStart: '#SETUP_LAZY_KEYS STARTS',
42
+ bannerEnd: '#SETUP_LAZY_KEYS ENDS',
43
+ chunks: ['SetupHome'], // Webpack chunks that trigger this group
44
+ filenameTemplate: 'i18n-chunk/[locale]/setup.i18n.js',
45
+ preload: false,
46
+ prefetch: true
47
+ }
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### In `JSResources.properties`:
54
+
55
+ ```properties
56
+ # Regular translations
57
+ support.label.home=Home
58
+ support.label.tickets=Tickets
59
+
60
+ #SETUP_LAZY_KEYS STARTS
61
+ # These will be lazy loaded
62
+ support.setup.label.phone=Phone
63
+ support.setup.label.layouts_fields=Layouts and Fields
64
+ #SETUP_LAZY_KEYS ENDS
65
+
66
+ # More regular translations
67
+ support.label.chat=Chat
68
+ ```
69
+
70
+ ### In `index.html`:
71
+
72
+ ```javascript
73
+ window.loadI18nChunk = function(translations, groupName) {
74
+ // Merge translations
75
+ window.i18n = Object.assign(window.i18n, translations);
76
+
77
+ // Track loaded groups
78
+ if (groupName) {
79
+ console.log('[I18n] Loaded group:', groupName);
80
+ }
81
+
82
+ // Notify framework
83
+ window.dispatchEvent(new CustomEvent('i18nLoaded', {
84
+ detail: { group: groupName }
85
+ }));
86
+ };
87
+ ```
88
+
89
+ ## How It Works
90
+
91
+ ### Build Time:
92
+ 1. Plugin reads JSResources.properties
93
+ 2. Parses banner markers to identify custom groups
94
+ 3. Generates numeric mapping for all keys
95
+ 4. Creates separate chunks:
96
+ - `numeric.i18n.js` - Main translations with numeric keys
97
+ - `dynamic.i18n.js` - Keys with placeholders (keep string keys)
98
+ - `setup.i18n.js` - Setup-specific translations (lazy loaded)
99
+
100
+ ### Runtime:
101
+ 1. Initial page load → Loads numeric.i18n.js + dynamic.i18n.js
102
+ 2. User clicks Setup → Webpack loads SetupHome.js
103
+ 3. Plugin runtime detects SetupHome needs 'setup' group
104
+ 4. Automatically loads setup.i18n.js
105
+ 5. Calls window.loadI18nChunk() with translations
106
+
107
+ ## Output Structure
108
+
109
+ ```
110
+ agent/
111
+ └── i18n-chunk/
112
+ ├── en_US/
113
+ │ ├── numeric.i18n.js (396KB - main translations)
114
+ │ ├── dynamic.i18n.js (201KB - dynamic keys)
115
+ │ └── setup.i18n.js (217B - setup keys only!)
116
+ └── [other locales]/
117
+ ```
118
+
119
+ ## Generated Files
120
+
121
+ ### numeric.i18n.js:
122
+ ```javascript
123
+ window.loadI18nChunk({
124
+ "1": "Home",
125
+ "2": "Tickets",
126
+ "3": "Chat"
127
+ // ... thousands more
128
+ });
129
+ ```
130
+
131
+ ### setup.i18n.js:
132
+ ```javascript
133
+ window.loadI18nChunk({
134
+ "4547": "Phone",
135
+ "4548": "Zia",
136
+ "4549": "Layouts and Fields"
137
+ // ... setup-specific keys
138
+ }, "setup");
139
+ ```
140
+
141
+ ### i18n-numeric-map.json:
142
+ ```json
143
+ {
144
+ "support.label.home": 1,
145
+ "support.label.tickets": 2,
146
+ "support.setup.label.phone": 4547
147
+ }
148
+ ```
149
+
150
+ ## Using webpackI18nGroup Comments
151
+
152
+ You can also mark chunks for i18n groups using comments:
153
+
154
+ ```javascript
155
+ const SetupHome = lazy(() =>
156
+ import(
157
+ /* webpackChunkName: "SetupHome" */
158
+ /* webpackI18nGroup: "setup" */
159
+ './pages/SetupHome'
160
+ )
161
+ );
162
+ ```
163
+
164
+ ## Performance Benefits
165
+
166
+ 1. **Initial Bundle**: ~40% smaller due to numeric indexing
167
+ 2. **Setup Keys**: Only 217 bytes, loaded on-demand
168
+ 3. **Network**: Fewer bytes transferred
169
+ 4. **Memory**: Reduced memory footprint
170
+
171
+ ## Adding New Groups
172
+
173
+ To add a new lazy-loaded group (e.g., "reports"):
174
+
175
+ 1. Add banner markers in JSResources.properties:
176
+ ```properties
177
+ #REPORTS_LAZY_KEYS STARTS
178
+ support.reports.label.dashboard=Dashboard
179
+ #REPORTS_LAZY_KEYS ENDS
180
+ ```
181
+
182
+ 2. Update cbt.config.js:
183
+ ```javascript
184
+ customGroups: {
185
+ setup: { /* ... */ },
186
+ reports: {
187
+ bannerStart: '#REPORTS_LAZY_KEYS STARTS',
188
+ bannerEnd: '#REPORTS_LAZY_KEYS ENDS',
189
+ chunks: ['ReportsHome'],
190
+ filenameTemplate: 'i18n-chunk/[locale]/reports.i18n.js'
191
+ }
192
+ }
193
+ ```
194
+
195
+ ## Troubleshooting
196
+
197
+ ### Keys not in setup chunk:
198
+ - Check banner markers are correct in JSResources.properties
199
+ - Verify key is between STARTS and ENDS markers
200
+
201
+ ### Setup chunk not loading:
202
+ - Ensure SetupHome is in the chunks array
203
+ - Check browser DevTools Network tab
204
+ - Verify window.loadI18nChunk is defined
205
+
206
+ ### Numeric mapping issues:
207
+ - Check i18n-numeric-map.json is generated
208
+ - Verify no duplicate keys
209
+ - Ensure jsResourcePath is correct
210
+
211
+ ## Migration Guide
212
+
213
+ 1. Enable i18nIndexing in cbt.config.js
214
+ 2. Add banner markers to JSResources.properties
215
+ 3. Update index.html with loadI18nChunk function
216
+ 4. Build and test
217
+ 5. Monitor Network tab to verify lazy loading
218
+
219
+ ## Best Practices
220
+
221
+ 1. **Group Related Keys**: Keep setup keys together
222
+ 2. **Use Root Chunks**: Configure the main entry chunk for each section
223
+ 3. **Monitor Bundle Size**: Check generated file sizes
224
+ 4. **Test Loading**: Verify chunks load when expected
225
+ 5. **Keep Groups Small**: Aim for <1KB per lazy group