@zohodesk/client_build_tool 0.0.11-exp.23.0 → 0.0.11-exp.24.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
|
@@ -39,6 +39,7 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
39
39
|
var chunkNameToGroup = ${JSON.stringify(chunkToGroup)};
|
|
40
40
|
var groupToChunkNames = ${JSON.stringify(groupToChunks)};
|
|
41
41
|
var cachedI18nBase;
|
|
42
|
+
var loadReasonKey = '__i18nGroupLoadReason';
|
|
42
43
|
|
|
43
44
|
function ensureTrailingSlash(path) {
|
|
44
45
|
if (!path) {
|
|
@@ -59,6 +60,34 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
59
60
|
return '';
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
function withLoadReason(reason, fn) {
|
|
64
|
+
var previous = __webpack_require__[loadReasonKey];
|
|
65
|
+
__webpack_require__[loadReasonKey] = reason;
|
|
66
|
+
try {
|
|
67
|
+
return fn();
|
|
68
|
+
} finally {
|
|
69
|
+
__webpack_require__[loadReasonKey] = previous;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (typeof __webpack_require__.pfc === 'function') {
|
|
74
|
+
var originalPrefetchChunk = __webpack_require__.pfc;
|
|
75
|
+
__webpack_require__.pfc = function(prefetchChunkId) {
|
|
76
|
+
return withLoadReason('prefetch', function() {
|
|
77
|
+
return originalPrefetchChunk(prefetchChunkId);
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (typeof __webpack_require__.plc === 'function') {
|
|
83
|
+
var originalPreloadChunk = __webpack_require__.plc;
|
|
84
|
+
__webpack_require__.plc = function(preloadChunkId) {
|
|
85
|
+
return withLoadReason('preload', function() {
|
|
86
|
+
return originalPreloadChunk(preloadChunkId);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
62
91
|
function resolveI18nBase() {
|
|
63
92
|
if (cachedI18nBase !== undefined) {
|
|
64
93
|
return cachedI18nBase;
|
|
@@ -104,37 +133,47 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
104
133
|
}
|
|
105
134
|
|
|
106
135
|
// Function to load i18n group
|
|
107
|
-
function loadI18nGroup(groupName) {
|
|
136
|
+
function loadI18nGroup(groupName, loadReason) {
|
|
108
137
|
if (loadedGroups[groupName]) {
|
|
109
138
|
return Promise.resolve();
|
|
110
139
|
}
|
|
111
|
-
|
|
140
|
+
|
|
112
141
|
var locale = ${localeVarName} || 'en_US';
|
|
113
142
|
var groupConfig = ${JSON.stringify(customGroups)};
|
|
114
143
|
var config = groupConfig[groupName];
|
|
115
|
-
|
|
144
|
+
|
|
116
145
|
if (!config) {
|
|
117
146
|
return Promise.resolve();
|
|
118
147
|
}
|
|
119
|
-
|
|
148
|
+
|
|
149
|
+
var shouldSkip =
|
|
150
|
+
(loadReason === 'prefetch' && config.prefetch === false) ||
|
|
151
|
+
(loadReason === 'preload' && config.preload === false);
|
|
152
|
+
|
|
153
|
+
if (shouldSkip) {
|
|
154
|
+
if (typeof console !== 'undefined' && console.log) {
|
|
155
|
+
console.log('[i18n-group:skip]', groupName, loadReason, 'prefetch/preload disabled');
|
|
156
|
+
}
|
|
157
|
+
return Promise.resolve();
|
|
158
|
+
}
|
|
159
|
+
|
|
120
160
|
return new Promise(function(resolve, reject) {
|
|
121
161
|
var relativePath = config.filenameTemplate
|
|
122
162
|
.replace('[locale]', locale);
|
|
123
163
|
var i18nUrl = buildI18nUrl(relativePath);
|
|
124
164
|
|
|
125
165
|
if (typeof console !== 'undefined' && console.log) {
|
|
126
|
-
console.log('[i18n-group:load]', groupName, i18nUrl);
|
|
166
|
+
console.log('[i18n-group:load]', groupName, loadReason || 'require', i18nUrl);
|
|
127
167
|
}
|
|
128
168
|
|
|
129
|
-
|
|
130
169
|
var script = document.createElement('script');
|
|
131
170
|
script.src = i18nUrl;
|
|
132
171
|
script.async = true;
|
|
133
172
|
|
|
134
|
-
|
|
135
|
-
|
|
173
|
+
script.onload = function() {
|
|
174
|
+
loadedGroups[groupName] = true;
|
|
136
175
|
if (typeof console !== 'undefined' && console.log) {
|
|
137
|
-
console.log('[i18n-group:loaded]', groupName, i18nUrl);
|
|
176
|
+
console.log('[i18n-group:loaded]', groupName, loadReason || 'require', i18nUrl);
|
|
138
177
|
}
|
|
139
178
|
resolve();
|
|
140
179
|
};
|
|
@@ -177,6 +216,9 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
177
216
|
for (var i = 0; i < chunkNames.length; i++) {
|
|
178
217
|
var candidate = chunkNames[i];
|
|
179
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
|
+
}
|
|
180
222
|
return group;
|
|
181
223
|
}
|
|
182
224
|
}
|
|
@@ -194,21 +236,25 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
194
236
|
if (originalEnsureChunk) {
|
|
195
237
|
__webpack_require__.e = function(chunkId) {
|
|
196
238
|
var promise = originalEnsureChunk.apply(this, arguments);
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
239
|
+
|
|
240
|
+
// Check if this chunk needs an i18n group
|
|
241
|
+
var groupName = findGroupByChunkId(chunkId);
|
|
242
|
+
if (groupName && !loadedGroups[groupName]) {
|
|
243
|
+
if (typeof console !== 'undefined' && console.log) {
|
|
244
|
+
var chunkFilename = typeof __webpack_require__ !== 'undefined' && typeof __webpack_require__.u === 'function'
|
|
245
|
+
? __webpack_require__.u(chunkId)
|
|
246
|
+
: '<no __webpack_require__.u>';
|
|
247
|
+
console.log('[i18n-group:hook]', chunkId, '→', groupName, '| reason:', (__webpack_require__[loadReasonKey] || 'require'), '| file:', chunkFilename);
|
|
248
|
+
}
|
|
249
|
+
// Load the i18n group before the chunk
|
|
250
|
+
var loadReason = __webpack_require__[loadReasonKey] || 'require';
|
|
251
|
+
var i18nPromise = loadI18nGroup(groupName, loadReason);
|
|
252
|
+
// Chain the promises so i18n loads first
|
|
253
|
+
promise = Promise.all([promise, i18nPromise]).then(function(results) {
|
|
254
|
+
return results[0]; // Return the original chunk promise result
|
|
255
|
+
});
|
|
203
256
|
}
|
|
204
|
-
|
|
205
|
-
var i18nPromise = loadI18nGroup(groupName);
|
|
206
|
-
// Chain the promises so i18n loads first
|
|
207
|
-
promise = Promise.all([promise, i18nPromise]).then(function(results) {
|
|
208
|
-
return results[0]; // Return the original chunk promise result
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
257
|
+
|
|
212
258
|
return promise;
|
|
213
259
|
};
|
|
214
260
|
}
|
|
@@ -227,6 +273,13 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
227
273
|
.replace('[locale]', locale);
|
|
228
274
|
var i18nUrl = buildI18nUrl(relativePath);
|
|
229
275
|
|
|
276
|
+
if (config.prefetch === false) {
|
|
277
|
+
if (typeof console !== 'undefined' && console.log) {
|
|
278
|
+
console.log('[i18n-group:skip-prefetch-loader]', groupName, chunkId, i18nUrl);
|
|
279
|
+
}
|
|
280
|
+
return originalLoadScript.call(__webpack_require__, url, done, key, chunkId);
|
|
281
|
+
}
|
|
282
|
+
|
|
230
283
|
var i18nScript = document.createElement('script');
|
|
231
284
|
i18nScript.src = i18nUrl;
|
|
232
285
|
i18nScript.onload = function() {
|
|
@@ -23,7 +23,10 @@ function optimizationConfig(options) {
|
|
|
23
23
|
} = options;
|
|
24
24
|
const {
|
|
25
25
|
chunkSplitEnable
|
|
26
|
-
} = options.i18nChunkSplit;
|
|
26
|
+
} = options.i18nChunkSplit; // TEMP: Test console logs for minification verification
|
|
27
|
+
|
|
28
|
+
console.log('MINIFY_TEST: optimizationConfig called in mode:', options.mode);
|
|
29
|
+
console.log('MINIFY_TEST: TerserPlugin and CSS minification active');
|
|
27
30
|
const i18nChunkFilename = (0, _nameTemplates.nameTemplates)('i18njs', options);
|
|
28
31
|
const chunkFilenameHasContentHash = (0, _hashUtils.hasContentHash)(i18nChunkFilename);
|
|
29
32
|
/**
|
|
@@ -55,6 +55,9 @@ var _configCustomScriptLoadingStrategyPlugin = require("./pluginConfigs/configCu
|
|
|
55
55
|
function plugins(options) {
|
|
56
56
|
const {
|
|
57
57
|
webpackPlugins
|
|
58
|
-
} = options;
|
|
58
|
+
} = options; // TEMP: Test console logs for minification verification
|
|
59
|
+
|
|
60
|
+
console.log('MINIFY_TEST: plugins function called with options:', options.mode);
|
|
61
|
+
console.log('MINIFY_TEST: This message should be visible if minification is disabled');
|
|
59
62
|
return [(0, _configEnvVariables.configEnvVariables)(options), (0, _configCustomAttributesPlugin.configCustomAttributesPlugin)(options), (0, _configTPHashMappingPlugin.configTPHashMappingPlugin)(options), (0, _configCopyPublicFolders.configCopyPublicFolders)(options), (0, _configIgnorePlugin.configIgnorePlugin)(options), (0, _configMiniCSSExtractPlugin.configMiniCSSExtractPlugin)(options), (0, _configSelectorWeightPlugin.configSelectorWeightPlugin)(options), (0, _configVariableConversionPlugin.configVariableConversionPlugin)(options), (0, _configI18nSplitPlugin.configI18nSplitPlugin)(options), ...((0, _configI18nNumericIndexPlugin.configI18nNumericIndexPlugin)(options) || []), (0, _configRtlCssPlugin.configRtlCssPlugin)(options), (0, _configHtmlWebpackPlugin.configHtmlWebpackPlugin)(options), (0, _configCustomScriptLoadingStrategyPlugin.configCustomScriptLoadingStrategyPlugin)(options), (0, _configCdnChangePlugin.configCdnChangePlugin)(options), (0, _configServiceWorkerPlugin.configServiceWorkerPlugin)(options), (0, _configEFCTemplatePlugin.configEFCTemplatePlugin)(options), (0, _configResourceHintsPlugin.configResourceHintsPlugin)(options), (0, _configBundleAnalyzer.configBundleAnalyzer)(options), (0, _configManifestJsonPlugin.configManifestJsonPlugin)(options), (0, _configSourceMapPlugin.configSourceMapPlugin)(options), (0, _configProgressPlugin.configProgressPlugin)(options), (0, _configBundleIntegrityReport.configBundleIntegrityReport)(options), (0, _configRuntimeResourceCleanup.configRuntimeResourceCleanup)(options), ...webpackPlugins].filter(Boolean);
|
|
60
63
|
}
|