@zohodesk/client_build_tool 0.0.11-exp.23.0 → 0.0.11-exp.25.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.
@@ -24,10 +24,8 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
24
24
  } = this.options; // Build chunk-to-group mapping from config
25
25
 
26
26
  const chunkToGroup = {};
27
- const groupToChunks = {};
28
27
  Object.entries(customGroups || {}).forEach(([groupName, config]) => {
29
28
  const chunkNames = config.chunks || [];
30
- groupToChunks[groupName] = chunkNames;
31
29
  chunkNames.forEach(chunkName => {
32
30
  chunkToGroup[chunkName] = groupName;
33
31
  });
@@ -37,8 +35,8 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
37
35
  (function() {
38
36
  var loadedGroups = {};
39
37
  var chunkNameToGroup = ${JSON.stringify(chunkToGroup)};
40
- var groupToChunkNames = ${JSON.stringify(groupToChunks)};
41
38
  var cachedI18nBase;
39
+ var loadReasonKey = '__i18nGroupLoadReason';
42
40
 
43
41
  function ensureTrailingSlash(path) {
44
42
  if (!path) {
@@ -59,6 +57,34 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
59
57
  return '';
60
58
  }
61
59
 
60
+ function withLoadReason(reason, fn) {
61
+ var previous = __webpack_require__[loadReasonKey];
62
+ __webpack_require__[loadReasonKey] = reason;
63
+ try {
64
+ return fn();
65
+ } finally {
66
+ __webpack_require__[loadReasonKey] = previous;
67
+ }
68
+ }
69
+
70
+ if (typeof __webpack_require__.pfc === 'function') {
71
+ var originalPrefetchChunk = __webpack_require__.pfc;
72
+ __webpack_require__.pfc = function(prefetchChunkId) {
73
+ return withLoadReason('prefetch', function() {
74
+ return originalPrefetchChunk(prefetchChunkId);
75
+ });
76
+ };
77
+ }
78
+
79
+ if (typeof __webpack_require__.plc === 'function') {
80
+ var originalPreloadChunk = __webpack_require__.plc;
81
+ __webpack_require__.plc = function(preloadChunkId) {
82
+ return withLoadReason('preload', function() {
83
+ return originalPreloadChunk(preloadChunkId);
84
+ });
85
+ };
86
+ }
87
+
62
88
  function resolveI18nBase() {
63
89
  if (cachedI18nBase !== undefined) {
64
90
  return cachedI18nBase;
@@ -104,37 +130,47 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
104
130
  }
105
131
 
106
132
  // Function to load i18n group
107
- function loadI18nGroup(groupName) {
133
+ function loadI18nGroup(groupName, loadReason) {
108
134
  if (loadedGroups[groupName]) {
109
135
  return Promise.resolve();
110
136
  }
111
-
137
+
112
138
  var locale = ${localeVarName} || 'en_US';
113
139
  var groupConfig = ${JSON.stringify(customGroups)};
114
140
  var config = groupConfig[groupName];
115
-
141
+
116
142
  if (!config) {
117
143
  return Promise.resolve();
118
144
  }
119
-
145
+
146
+ var shouldSkip =
147
+ (loadReason === 'prefetch' && config.prefetch === false) ||
148
+ (loadReason === 'preload' && config.preload === false);
149
+
150
+ if (shouldSkip) {
151
+ if (typeof console !== 'undefined' && console.log) {
152
+ console.log('[i18n-group:skip]', groupName, loadReason, 'prefetch/preload disabled');
153
+ }
154
+ return Promise.resolve();
155
+ }
156
+
120
157
  return new Promise(function(resolve, reject) {
121
158
  var relativePath = config.filenameTemplate
122
159
  .replace('[locale]', locale);
123
160
  var i18nUrl = buildI18nUrl(relativePath);
124
161
 
125
162
  if (typeof console !== 'undefined' && console.log) {
126
- console.log('[i18n-group:load]', groupName, i18nUrl);
163
+ console.log('[i18n-group:load]', groupName, loadReason || 'require', i18nUrl);
127
164
  }
128
165
 
129
-
130
166
  var script = document.createElement('script');
131
167
  script.src = i18nUrl;
132
168
  script.async = true;
133
169
 
134
- script.onload = function() {
135
- loadedGroups[groupName] = true;
170
+ script.onload = function() {
171
+ loadedGroups[groupName] = true;
136
172
  if (typeof console !== 'undefined' && console.log) {
137
- console.log('[i18n-group:loaded]', groupName, i18nUrl);
173
+ console.log('[i18n-group:loaded]', groupName, loadReason || 'require', i18nUrl);
138
174
  }
139
175
  resolve();
140
176
  };
@@ -150,10 +186,6 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
150
186
  });
151
187
  }
152
188
 
153
- function toLower(str) {
154
- return typeof str === 'string' ? str.toLowerCase() : str;
155
- }
156
-
157
189
  function findGroupByChunkId(chunkId) {
158
190
  var directGroup = chunkNameToGroup[chunkId];
159
191
  if (directGroup) {
@@ -165,25 +197,6 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
165
197
  return chunkNameToGroup[stringId];
166
198
  }
167
199
 
168
- if (typeof __webpack_require__ !== 'undefined' && typeof __webpack_require__.u === 'function') {
169
- var filename = __webpack_require__.u(chunkId) || '';
170
- if (filename) {
171
- var loweredFilename = toLower(filename);
172
- for (var group in groupToChunkNames) {
173
- if (!Object.prototype.hasOwnProperty.call(groupToChunkNames, group)) {
174
- continue;
175
- }
176
- var chunkNames = groupToChunkNames[group] || [];
177
- for (var i = 0; i < chunkNames.length; i++) {
178
- var candidate = chunkNames[i];
179
- if (candidate && loweredFilename.indexOf(toLower(candidate)) !== -1) {
180
- return group;
181
- }
182
- }
183
- }
184
- }
185
- }
186
-
187
200
  return undefined;
188
201
  }
189
202
 
@@ -194,21 +207,25 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
194
207
  if (originalEnsureChunk) {
195
208
  __webpack_require__.e = function(chunkId) {
196
209
  var promise = originalEnsureChunk.apply(this, arguments);
197
-
198
- // Check if this chunk needs an i18n group
199
- var groupName = findGroupByChunkId(chunkId);
200
- if (groupName && !loadedGroups[groupName]) {
201
- if (typeof console !== 'undefined' && console.log) {
202
- console.log('[i18n-group:hook]', chunkId, '', groupName);
210
+
211
+ // Check if this chunk needs an i18n group
212
+ var groupName = findGroupByChunkId(chunkId);
213
+ if (groupName && !loadedGroups[groupName]) {
214
+ if (typeof console !== 'undefined' && console.log) {
215
+ var chunkFilename = typeof __webpack_require__ !== 'undefined' && typeof __webpack_require__.u === 'function'
216
+ ? __webpack_require__.u(chunkId)
217
+ : '<no __webpack_require__.u>';
218
+ console.log('[i18n-group:hook]', chunkId, '→', groupName, '| reason:', (__webpack_require__[loadReasonKey] || 'require'), '| file:', chunkFilename);
219
+ }
220
+ // Load the i18n group before the chunk
221
+ var loadReason = __webpack_require__[loadReasonKey] || 'require';
222
+ var i18nPromise = loadI18nGroup(groupName, loadReason);
223
+ // Chain the promises so i18n loads first
224
+ promise = Promise.all([promise, i18nPromise]).then(function(results) {
225
+ return results[0]; // Return the original chunk promise result
226
+ });
203
227
  }
204
- // Load the i18n group before the chunk
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
-
228
+
212
229
  return promise;
213
230
  };
214
231
  }
@@ -227,6 +244,13 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
227
244
  .replace('[locale]', locale);
228
245
  var i18nUrl = buildI18nUrl(relativePath);
229
246
 
247
+ if (config.prefetch === false) {
248
+ if (typeof console !== 'undefined' && console.log) {
249
+ console.log('[i18n-group:skip-prefetch-loader]', groupName, chunkId, i18nUrl);
250
+ }
251
+ return originalLoadScript.call(__webpack_require__, url, done, key, chunkId);
252
+ }
253
+
230
254
  var i18nScript = document.createElement('script');
231
255
  i18nScript.src = i18nUrl;
232
256
  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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/client_build_tool",
3
- "version": "0.0.11-exp.23.0",
3
+ "version": "0.0.11-exp.25.0",
4
4
  "description": "A CLI tool to build web applications and client libraries",
5
5
  "main": "lib/index.js",
6
6
  "bin": {