@zohodesk/client_build_tool 0.0.11-exp.20.0 → 0.0.11-exp.21.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
|
@@ -82,6 +82,9 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
cachedI18nBase = ensureTrailingSlash(base);
|
|
85
|
+
if (typeof console !== 'undefined' && console.log) {
|
|
86
|
+
console.log('[i18n-group:base]', cachedI18nBase || '<empty>');
|
|
87
|
+
}
|
|
85
88
|
return cachedI18nBase;
|
|
86
89
|
}
|
|
87
90
|
|
|
@@ -124,12 +127,18 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
124
127
|
script.src = i18nUrl;
|
|
125
128
|
script.async = true;
|
|
126
129
|
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
script.onload = function() {
|
|
131
|
+
loadedGroups[groupName] = true;
|
|
132
|
+
if (typeof console !== 'undefined' && console.log) {
|
|
133
|
+
console.log('[i18n-group:loaded]', groupName, i18nUrl);
|
|
134
|
+
}
|
|
129
135
|
resolve();
|
|
130
136
|
};
|
|
131
|
-
|
|
137
|
+
|
|
132
138
|
script.onerror = function() {
|
|
139
|
+
if (typeof console !== 'undefined' && console.error) {
|
|
140
|
+
console.error('[i18n-group:error]', groupName, i18nUrl);
|
|
141
|
+
}
|
|
133
142
|
reject(new Error('Failed to load i18n group: ' + groupName));
|
|
134
143
|
};
|
|
135
144
|
|
|
@@ -148,6 +157,9 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
148
157
|
// Check if this chunk needs an i18n group
|
|
149
158
|
var groupName = chunkToGroup[chunkId];
|
|
150
159
|
if (groupName && !loadedGroups[groupName]) {
|
|
160
|
+
if (typeof console !== 'undefined' && console.log) {
|
|
161
|
+
console.log('[i18n-group:hook]', chunkId, '→', groupName);
|
|
162
|
+
}
|
|
151
163
|
// Load the i18n group before the chunk
|
|
152
164
|
var i18nPromise = loadI18nGroup(groupName);
|
|
153
165
|
// Chain the promises so i18n loads first
|
|
@@ -161,17 +173,14 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
161
173
|
}
|
|
162
174
|
|
|
163
175
|
// Also check for webpackI18nGroup comments in dynamic imports
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
__webpack_require__.l = function(url, done, key, chunkId) {
|
|
167
|
-
// Check if chunk has i18n group
|
|
176
|
+
function wrapLoadScript(originalLoadScript) {
|
|
177
|
+
return function(url, done, key, chunkId) {
|
|
168
178
|
var groupName = chunkToGroup[chunkId];
|
|
169
179
|
if (groupName && !loadedGroups[groupName]) {
|
|
170
|
-
// Load i18n before main chunk
|
|
171
180
|
var locale = ${localeVarName} || 'en_US';
|
|
172
181
|
var groupConfig = ${JSON.stringify(customGroups)};
|
|
173
182
|
var config = groupConfig[groupName];
|
|
174
|
-
|
|
183
|
+
|
|
175
184
|
if (config) {
|
|
176
185
|
var relativePath = config.filenameTemplate
|
|
177
186
|
.replace('[locale]', locale);
|
|
@@ -180,28 +189,54 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
180
189
|
if (typeof console !== 'undefined' && console.log) {
|
|
181
190
|
console.log('[i18n-group:preload]', groupName, i18nUrl);
|
|
182
191
|
}
|
|
183
|
-
|
|
184
|
-
// Load i18n first, then the chunk
|
|
192
|
+
|
|
185
193
|
var i18nScript = document.createElement('script');
|
|
186
194
|
i18nScript.src = i18nUrl;
|
|
187
195
|
i18nScript.onload = function() {
|
|
188
196
|
loadedGroups[groupName] = true;
|
|
189
|
-
|
|
197
|
+
if (typeof console !== 'undefined' && console.log) {
|
|
198
|
+
console.log('[i18n-group:loaded]', groupName, i18nUrl);
|
|
199
|
+
}
|
|
190
200
|
originalLoadScript.call(__webpack_require__, url, done, key, chunkId);
|
|
191
201
|
};
|
|
192
202
|
i18nScript.onerror = function() {
|
|
193
|
-
|
|
203
|
+
if (typeof console !== 'undefined' && console.error) {
|
|
204
|
+
console.error('[i18n-group:error]', groupName, i18nUrl);
|
|
205
|
+
}
|
|
194
206
|
originalLoadScript.call(__webpack_require__, url, done, key, chunkId);
|
|
195
207
|
};
|
|
196
208
|
document.head.appendChild(i18nScript);
|
|
197
209
|
return;
|
|
198
210
|
}
|
|
199
211
|
}
|
|
200
|
-
|
|
201
|
-
// Default behavior
|
|
212
|
+
|
|
202
213
|
return originalLoadScript.call(__webpack_require__, url, done, key, chunkId);
|
|
203
214
|
};
|
|
204
215
|
}
|
|
216
|
+
|
|
217
|
+
function installLoadScriptHook(loadScript) {
|
|
218
|
+
Object.defineProperty(__webpack_require__, 'l', {
|
|
219
|
+
configurable: true,
|
|
220
|
+
enumerable: true,
|
|
221
|
+
writable: true,
|
|
222
|
+
value: wrapLoadScript(loadScript)
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (typeof __webpack_require__.l === 'function') {
|
|
227
|
+
installLoadScriptHook(__webpack_require__.l);
|
|
228
|
+
} else {
|
|
229
|
+
Object.defineProperty(__webpack_require__, 'l', {
|
|
230
|
+
configurable: true,
|
|
231
|
+
enumerable: true,
|
|
232
|
+
set: function(newLoader) {
|
|
233
|
+
installLoadScriptHook(newLoader);
|
|
234
|
+
},
|
|
235
|
+
get: function() {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
205
240
|
})();
|
|
206
241
|
`;
|
|
207
242
|
}
|
package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js
CHANGED
|
@@ -52,7 +52,8 @@ class I18nNumericIndexPlugin {
|
|
|
52
52
|
compilation.addRuntimeModule(chunk, new _I18nGroupRuntimeModule.I18nGroupRuntimeModule({
|
|
53
53
|
customGroups: this.options.customGroups,
|
|
54
54
|
localeVarName: this.options.localeVarName,
|
|
55
|
-
jsonpFunc: this.options.jsonpFunc
|
|
55
|
+
jsonpFunc: this.options.jsonpFunc,
|
|
56
|
+
i18nPublicPathVar: this.options.i18nPublicPathVar
|
|
56
57
|
}));
|
|
57
58
|
}
|
|
58
59
|
});
|