@zohodesk/client_build_tool 0.0.11-exp.24.0 → 0.0.11-exp.26.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.
package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js
CHANGED
|
@@ -18,29 +18,27 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
18
18
|
generate() {
|
|
19
19
|
const {
|
|
20
20
|
customGroups,
|
|
21
|
+
chunkIdToGroupMapping,
|
|
21
22
|
localeVarName,
|
|
22
23
|
jsonpFunc,
|
|
23
24
|
i18nPublicPathVar
|
|
24
|
-
} = this.options; //
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const groupToChunks = {};
|
|
28
|
-
Object.entries(customGroups || {}).forEach(([groupName, config]) => {
|
|
29
|
-
const chunkNames = config.chunks || [];
|
|
30
|
-
groupToChunks[groupName] = chunkNames;
|
|
31
|
-
chunkNames.forEach(chunkName => {
|
|
32
|
-
chunkToGroup[chunkName] = groupName;
|
|
33
|
-
});
|
|
34
|
-
});
|
|
25
|
+
} = this.options; // Use the pre-computed chunk ID to group mapping
|
|
26
|
+
|
|
27
|
+
const chunkIdToGroup = chunkIdToGroupMapping || {};
|
|
35
28
|
return `
|
|
36
29
|
// I18n Group Loading Runtime
|
|
37
30
|
(function() {
|
|
38
31
|
var loadedGroups = {};
|
|
39
|
-
var
|
|
40
|
-
var groupToChunkNames = ${JSON.stringify(groupToChunks)};
|
|
32
|
+
var chunkIdToGroup = ${JSON.stringify(chunkIdToGroup)};
|
|
41
33
|
var cachedI18nBase;
|
|
42
34
|
var loadReasonKey = '__i18nGroupLoadReason';
|
|
43
35
|
|
|
36
|
+
// Only log if we have actual mappings to track
|
|
37
|
+
if (Object.keys(chunkIdToGroup).length > 0) {
|
|
38
|
+
console.log('[i18n-group:runtime] I18n Group Runtime Module loaded');
|
|
39
|
+
console.log('[i18n-group:runtime] Chunk ID to Group mapping:', chunkIdToGroup);
|
|
40
|
+
}
|
|
41
|
+
|
|
44
42
|
function ensureTrailingSlash(path) {
|
|
45
43
|
if (!path) {
|
|
46
44
|
return '';
|
|
@@ -189,44 +187,9 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
189
187
|
});
|
|
190
188
|
}
|
|
191
189
|
|
|
192
|
-
function toLower(str) {
|
|
193
|
-
return typeof str === 'string' ? str.toLowerCase() : str;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
190
|
function findGroupByChunkId(chunkId) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return directGroup;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
var stringId = '' + chunkId;
|
|
203
|
-
if (chunkNameToGroup[stringId]) {
|
|
204
|
-
return chunkNameToGroup[stringId];
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (typeof __webpack_require__ !== 'undefined' && typeof __webpack_require__.u === 'function') {
|
|
208
|
-
var filename = __webpack_require__.u(chunkId) || '';
|
|
209
|
-
if (filename) {
|
|
210
|
-
var loweredFilename = toLower(filename);
|
|
211
|
-
for (var group in groupToChunkNames) {
|
|
212
|
-
if (!Object.prototype.hasOwnProperty.call(groupToChunkNames, group)) {
|
|
213
|
-
continue;
|
|
214
|
-
}
|
|
215
|
-
var chunkNames = groupToChunkNames[group] || [];
|
|
216
|
-
for (var i = 0; i < chunkNames.length; i++) {
|
|
217
|
-
var candidate = chunkNames[i];
|
|
218
|
-
if (candidate && loweredFilename.indexOf(toLower(candidate)) !== -1) {
|
|
219
|
-
if (typeof console !== 'undefined' && console.log) {
|
|
220
|
-
console.log('[i18n-group:match-by-filename]', chunkId, filename, 'matched', candidate, '→', group);
|
|
221
|
-
}
|
|
222
|
-
return group;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return undefined;
|
|
191
|
+
// Direct numeric chunk ID lookup
|
|
192
|
+
return chunkIdToGroup[chunkId];
|
|
230
193
|
}
|
|
231
194
|
|
|
232
195
|
// Store original webpack chunk loading function
|
|
@@ -235,10 +198,21 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
235
198
|
// Override webpack's chunk loading if it exists
|
|
236
199
|
if (originalEnsureChunk) {
|
|
237
200
|
__webpack_require__.e = function(chunkId) {
|
|
238
|
-
|
|
239
|
-
|
|
201
|
+
if (typeof console !== 'undefined' && console.log) {
|
|
202
|
+
console.log('[i18n-group:debug] Chunk loading called for ID:', chunkId);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Capture the arguments for later use
|
|
206
|
+
var args = arguments;
|
|
207
|
+
var self = this;
|
|
208
|
+
|
|
240
209
|
// Check if this chunk needs an i18n group
|
|
241
210
|
var groupName = findGroupByChunkId(chunkId);
|
|
211
|
+
if (typeof console !== 'undefined' && console.log) {
|
|
212
|
+
console.log('[i18n-group:debug] Found group for chunk', chunkId, ':', groupName);
|
|
213
|
+
console.log('[i18n-group:debug] Chunk mapping:', chunkIdToGroup);
|
|
214
|
+
}
|
|
215
|
+
|
|
242
216
|
if (groupName && !loadedGroups[groupName]) {
|
|
243
217
|
if (typeof console !== 'undefined' && console.log) {
|
|
244
218
|
var chunkFilename = typeof __webpack_require__ !== 'undefined' && typeof __webpack_require__.u === 'function'
|
|
@@ -246,16 +220,25 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
246
220
|
: '<no __webpack_require__.u>';
|
|
247
221
|
console.log('[i18n-group:hook]', chunkId, '→', groupName, '| reason:', (__webpack_require__[loadReasonKey] || 'require'), '| file:', chunkFilename);
|
|
248
222
|
}
|
|
249
|
-
// Load the i18n group
|
|
223
|
+
// Load the i18n group FIRST, then load the chunk
|
|
250
224
|
var loadReason = __webpack_require__[loadReasonKey] || 'require';
|
|
251
225
|
var i18nPromise = loadI18nGroup(groupName, loadReason);
|
|
252
|
-
// Chain
|
|
253
|
-
|
|
254
|
-
|
|
226
|
+
// Chain: i18n loads first, then chunk loads
|
|
227
|
+
return i18nPromise.then(function() {
|
|
228
|
+
// Only start loading the actual chunk after i18n is loaded
|
|
229
|
+
return originalEnsureChunk.apply(self, args);
|
|
255
230
|
});
|
|
231
|
+
} else {
|
|
232
|
+
if (typeof console !== 'undefined' && console.log) {
|
|
233
|
+
if (!groupName) {
|
|
234
|
+
console.log('[i18n-group:debug] No group found for chunk', chunkId);
|
|
235
|
+
} else if (loadedGroups[groupName]) {
|
|
236
|
+
console.log('[i18n-group:debug] Group', groupName, 'already loaded for chunk', chunkId);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// No i18n needed, just load the chunk normally
|
|
240
|
+
return originalEnsureChunk.apply(this, arguments);
|
|
256
241
|
}
|
|
257
|
-
|
|
258
|
-
return promise;
|
|
259
242
|
};
|
|
260
243
|
}
|
|
261
244
|
|
package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js
CHANGED
|
@@ -45,12 +45,25 @@ class I18nNumericIndexPlugin {
|
|
|
45
45
|
this.detectI18nGroupComments(compiler);
|
|
46
46
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
47
47
|
// Add runtime module for group-based loading
|
|
48
|
+
console.log('[I18nNumericIndexPlugin] customGroups:', this.options.customGroups);
|
|
49
|
+
|
|
48
50
|
if (this.options.customGroups) {
|
|
49
51
|
compilation.hooks.additionalTreeRuntimeRequirements.tap(pluginName, (chunk, set) => {
|
|
50
52
|
// Only add to the main/entry chunk to avoid duplication
|
|
51
53
|
if (chunk.name === 'main' || chunk.hasRuntime()) {
|
|
54
|
+
const chunkMapping = this.getChunkIdToGroupMapping(compilation); // Only log if we have actual mappings or it's the first time
|
|
55
|
+
|
|
56
|
+
const hasMapping = Object.keys(chunkMapping).length > 0;
|
|
57
|
+
|
|
58
|
+
if (hasMapping || !this._hasLoggedRuntime) {
|
|
59
|
+
console.log('[I18nNumericIndexPlugin] Adding runtime module to chunk:', chunk.name);
|
|
60
|
+
console.log('[I18nNumericIndexPlugin] Chunk mapping for runtime:', chunkMapping);
|
|
61
|
+
this._hasLoggedRuntime = true;
|
|
62
|
+
}
|
|
63
|
+
|
|
52
64
|
compilation.addRuntimeModule(chunk, new _I18nGroupRuntimeModule.I18nGroupRuntimeModule({
|
|
53
65
|
customGroups: this.options.customGroups,
|
|
66
|
+
chunkIdToGroupMapping: chunkMapping,
|
|
54
67
|
localeVarName: this.options.localeVarName,
|
|
55
68
|
jsonpFunc: this.options.jsonpFunc,
|
|
56
69
|
i18nPublicPathVar: this.options.i18nPublicPathVar
|
|
@@ -69,37 +82,99 @@ class I18nNumericIndexPlugin {
|
|
|
69
82
|
}
|
|
70
83
|
|
|
71
84
|
detectI18nGroupComments(compiler) {
|
|
85
|
+
console.log('[I18nNumericIndexPlugin] Setting up i18n group comment detection');
|
|
72
86
|
compiler.hooks.normalModuleFactory.tap(pluginName, factory => {
|
|
73
87
|
factory.hooks.parser.for('javascript/auto').tap(pluginName, parser => {
|
|
74
88
|
parser.hooks.importCall.tap(pluginName, expr => {
|
|
75
|
-
//
|
|
89
|
+
// Only log if comments exist to reduce noise
|
|
76
90
|
const comments = expr.leadingComments || [];
|
|
77
|
-
comments.forEach(comment => {
|
|
78
|
-
if (comment.value && comment.value.includes('webpackI18nGroup')) {
|
|
79
|
-
const match = comment.value.match(/webpackI18nGroup:\s*["']([^"']+)["']/);
|
|
80
91
|
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
if (comments.length > 0) {
|
|
93
|
+
console.log('[I18nNumericIndexPlugin] Import call with comments detected');
|
|
94
|
+
console.log('[I18nNumericIndexPlugin] Leading comments count:', comments.length);
|
|
95
|
+
comments.forEach((comment, index) => {
|
|
96
|
+
console.log(`[I18nNumericIndexPlugin] Comment ${index}:`, comment.value);
|
|
97
|
+
|
|
98
|
+
if (comment.value && comment.value.includes('webpackI18nGroup')) {
|
|
99
|
+
console.log('[I18nNumericIndexPlugin] Found webpackI18nGroup comment:', comment.value);
|
|
100
|
+
const match = comment.value.match(/webpackI18nGroup:\s*["']([^"']+)["']/);
|
|
101
|
+
|
|
102
|
+
if (match) {
|
|
103
|
+
const groupName = match[1];
|
|
104
|
+
console.log('[I18nNumericIndexPlugin] Extracted group name:', groupName); // Store this information for later use
|
|
83
105
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
106
|
+
if (!this.detectedGroups) {
|
|
107
|
+
this.detectedGroups = {};
|
|
108
|
+
} // Extract chunk name from webpackChunkName comment
|
|
87
109
|
|
|
88
110
|
|
|
89
|
-
|
|
111
|
+
const chunkNameMatch = comment.value.match(/webpackChunkName:\s*["']([^"']+)["']/);
|
|
90
112
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
113
|
+
if (chunkNameMatch) {
|
|
114
|
+
const chunkName = chunkNameMatch[1];
|
|
115
|
+
console.log('[I18nNumericIndexPlugin] Mapping chunk:', chunkName, '→', groupName);
|
|
116
|
+
this.detectedGroups[chunkName] = groupName;
|
|
117
|
+
} else {
|
|
118
|
+
console.log('[I18nNumericIndexPlugin] No webpackChunkName found in comment');
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
console.log('[I18nNumericIndexPlugin] webpackI18nGroup pattern did not match');
|
|
94
122
|
}
|
|
95
123
|
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
98
126
|
});
|
|
99
127
|
});
|
|
100
128
|
});
|
|
101
129
|
}
|
|
102
130
|
|
|
131
|
+
getChunkIdToGroupMapping(compilation) {
|
|
132
|
+
const chunkIdToGroup = {}; // Hardcoded chunk name to group mapping based on our setupAsync.js
|
|
133
|
+
|
|
134
|
+
const hardcodedMappings = {
|
|
135
|
+
'SetupHome': 'setup',
|
|
136
|
+
'preferencePopup': 'setup',
|
|
137
|
+
'auditloglist': 'setup'
|
|
138
|
+
};
|
|
139
|
+
let foundAnyMapping = false;
|
|
140
|
+
let hasRelevantChunks = false; // Process chunks to get their actual IDs and map to groups
|
|
141
|
+
|
|
142
|
+
for (const chunk of compilation.chunks) {
|
|
143
|
+
const chunkName = chunk.name; // Check if this chunk is relevant to setup
|
|
144
|
+
|
|
145
|
+
if (chunkName && (chunkName.toLowerCase().includes('setup') || chunkName.toLowerCase().includes('preference') || chunkName.toLowerCase().includes('audit'))) {
|
|
146
|
+
hasRelevantChunks = true;
|
|
147
|
+
} // First try detected groups, then fallback to hardcoded mappings
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
let groupName = null;
|
|
151
|
+
|
|
152
|
+
if (this.detectedGroups && this.detectedGroups[chunkName]) {
|
|
153
|
+
groupName = this.detectedGroups[chunkName];
|
|
154
|
+
console.log(`[I18nNumericIndexPlugin] Found detected mapping: ${chunkName} → ${groupName} (ID: ${chunk.id})`);
|
|
155
|
+
foundAnyMapping = true;
|
|
156
|
+
} else if (hardcodedMappings[chunkName]) {
|
|
157
|
+
groupName = hardcodedMappings[chunkName];
|
|
158
|
+
console.log(`[I18nNumericIndexPlugin] Found hardcoded mapping: ${chunkName} → ${groupName} (ID: ${chunk.id})`);
|
|
159
|
+
foundAnyMapping = true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (groupName) {
|
|
163
|
+
chunkIdToGroup[chunk.id] = groupName;
|
|
164
|
+
}
|
|
165
|
+
} // Only log summary if we found mappings or relevant chunks
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
if (foundAnyMapping || hasRelevantChunks || compilation.chunks.size > 0) {
|
|
169
|
+
console.log('[I18nNumericIndexPlugin] Building chunk ID to group mapping');
|
|
170
|
+
console.log('[I18nNumericIndexPlugin] Detected groups:', this.detectedGroups);
|
|
171
|
+
console.log('[I18nNumericIndexPlugin] Total chunks in compilation:', compilation.chunks.size);
|
|
172
|
+
console.log('[I18nNumericIndexPlugin] Final chunk ID to group mapping:', chunkIdToGroup);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return chunkIdToGroup;
|
|
176
|
+
}
|
|
177
|
+
|
|
103
178
|
processI18nFiles(compilation) {
|
|
104
179
|
const {
|
|
105
180
|
jsResourcePath,
|