@zohodesk/client_build_tool 0.0.11-exp.15 → 0.0.11-exp.15.2
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/CHANGELOG.md +28 -0
- package/README.md +28 -0
- package/docs/I18N_NUMERIC_INDEXING_PLUGIN.md +225 -0
- package/docs/client_build_tool_source_doc.md +390 -0
- package/lib/schemas/defaultConfigValues.js +17 -14
- package/lib/schemas/defaultConfigValuesOnly.js +4 -21
- package/lib/shared/babel/getBabelPlugin.js +3 -4
- package/lib/shared/babel/runBabelForTsFile.js +1 -1
- package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +10 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js +124 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +207 -145
- package/lib/shared/bundler/webpack/jsLoaders.js +2 -20
- package/lib/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +3 -2
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nIndexingPlugin.js +42 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericHtmlInjector.js +92 -0
- package/lib/shared/bundler/webpack/plugins.js +6 -2
- package/lib/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +1 -1
- package/lib/shared/server/mockApiHandler.js +7 -0
- package/lib/shared/server/urlConcat.js +4 -3
- package/npm-shrinkwrap.json +354 -38
- package/package.json +6 -5
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +0 -49
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +0 -106
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectAstKeys.js +0 -96
- package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +0 -71
- package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +0 -106
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +0 -84
- package/lib/shared/bundler/webpack/utils/propertiesParser.js +0 -81
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,35 @@ 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
|
|
104
132
|
|
|
105
133
|
**Feature:-**
|
|
106
134
|
- externals was added to Prevent bundling of certain imported packages and retrieve these external dependencies at runtime.
|
|
@@ -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
|