@zohodesk/client_build_tool 0.0.11-exp.25.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,26 +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
|
-
Object.entries(customGroups || {}).forEach(([groupName, config]) => {
|
|
28
|
-
const chunkNames = config.chunks || [];
|
|
29
|
-
chunkNames.forEach(chunkName => {
|
|
30
|
-
chunkToGroup[chunkName] = groupName;
|
|
31
|
-
});
|
|
32
|
-
});
|
|
25
|
+
} = this.options; // Use the pre-computed chunk ID to group mapping
|
|
26
|
+
|
|
27
|
+
const chunkIdToGroup = chunkIdToGroupMapping || {};
|
|
33
28
|
return `
|
|
34
29
|
// I18n Group Loading Runtime
|
|
35
30
|
(function() {
|
|
36
31
|
var loadedGroups = {};
|
|
37
|
-
var
|
|
32
|
+
var chunkIdToGroup = ${JSON.stringify(chunkIdToGroup)};
|
|
38
33
|
var cachedI18nBase;
|
|
39
34
|
var loadReasonKey = '__i18nGroupLoadReason';
|
|
40
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
|
+
|
|
41
42
|
function ensureTrailingSlash(path) {
|
|
42
43
|
if (!path) {
|
|
43
44
|
return '';
|
|
@@ -187,17 +188,8 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
function findGroupByChunkId(chunkId) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return directGroup;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
var stringId = '' + chunkId;
|
|
196
|
-
if (chunkNameToGroup[stringId]) {
|
|
197
|
-
return chunkNameToGroup[stringId];
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return undefined;
|
|
191
|
+
// Direct numeric chunk ID lookup
|
|
192
|
+
return chunkIdToGroup[chunkId];
|
|
201
193
|
}
|
|
202
194
|
|
|
203
195
|
// Store original webpack chunk loading function
|
|
@@ -206,10 +198,21 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
206
198
|
// Override webpack's chunk loading if it exists
|
|
207
199
|
if (originalEnsureChunk) {
|
|
208
200
|
__webpack_require__.e = function(chunkId) {
|
|
209
|
-
|
|
210
|
-
|
|
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
|
+
|
|
211
209
|
// Check if this chunk needs an i18n group
|
|
212
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
|
+
|
|
213
216
|
if (groupName && !loadedGroups[groupName]) {
|
|
214
217
|
if (typeof console !== 'undefined' && console.log) {
|
|
215
218
|
var chunkFilename = typeof __webpack_require__ !== 'undefined' && typeof __webpack_require__.u === 'function'
|
|
@@ -217,16 +220,25 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
217
220
|
: '<no __webpack_require__.u>';
|
|
218
221
|
console.log('[i18n-group:hook]', chunkId, '→', groupName, '| reason:', (__webpack_require__[loadReasonKey] || 'require'), '| file:', chunkFilename);
|
|
219
222
|
}
|
|
220
|
-
// Load the i18n group
|
|
223
|
+
// Load the i18n group FIRST, then load the chunk
|
|
221
224
|
var loadReason = __webpack_require__[loadReasonKey] || 'require';
|
|
222
225
|
var i18nPromise = loadI18nGroup(groupName, loadReason);
|
|
223
|
-
// Chain
|
|
224
|
-
|
|
225
|
-
|
|
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);
|
|
226
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);
|
|
227
241
|
}
|
|
228
|
-
|
|
229
|
-
return promise;
|
|
230
242
|
};
|
|
231
243
|
}
|
|
232
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,
|