@zohodesk/client_build_tool 0.0.11-exp.19.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.
@@ -10,9 +10,8 @@ var _webpack = require("webpack");
10
10
  class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
11
11
  constructor(options) {
12
12
  super('i18n-group-loader');
13
- this.options = {
14
- i18nPublicPathVar: 'window.__I18N_CDN__',
15
- ...options
13
+ this.options = { ...options,
14
+ i18nPublicPathVar: options.i18nPublicPathVar || '(typeof window !== "undefined" && window.__I18N_CDN__)'
16
15
  };
17
16
  }
18
17
 
@@ -77,9 +76,15 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
77
76
 
78
77
  if (!base) {
79
78
  base = __webpack_require__.p || '';
79
+ if (base && base.indexOf('/smap/') !== -1 && base.slice(-6) === '/smap/') {
80
+ base = base.slice(0, -6) + '/';
81
+ }
80
82
  }
81
83
 
82
84
  cachedI18nBase = ensureTrailingSlash(base);
85
+ if (typeof console !== 'undefined' && console.log) {
86
+ console.log('[i18n-group:base]', cachedI18nBase || '<empty>');
87
+ }
83
88
  return cachedI18nBase;
84
89
  }
85
90
 
@@ -113,8 +118,8 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
113
118
  .replace('[locale]', locale);
114
119
  var i18nUrl = buildI18nUrl(relativePath);
115
120
 
116
- if (typeof console !== 'undefined' && console.debug) {
117
- console.debug('[i18n-group:load]', groupName, i18nUrl);
121
+ if (typeof console !== 'undefined' && console.log) {
122
+ console.log('[i18n-group:load]', groupName, i18nUrl);
118
123
  }
119
124
 
120
125
 
@@ -122,12 +127,18 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
122
127
  script.src = i18nUrl;
123
128
  script.async = true;
124
129
 
125
- script.onload = function() {
126
- loadedGroups[groupName] = true;
130
+ script.onload = function() {
131
+ loadedGroups[groupName] = true;
132
+ if (typeof console !== 'undefined' && console.log) {
133
+ console.log('[i18n-group:loaded]', groupName, i18nUrl);
134
+ }
127
135
  resolve();
128
136
  };
129
-
137
+
130
138
  script.onerror = function() {
139
+ if (typeof console !== 'undefined' && console.error) {
140
+ console.error('[i18n-group:error]', groupName, i18nUrl);
141
+ }
131
142
  reject(new Error('Failed to load i18n group: ' + groupName));
132
143
  };
133
144
 
@@ -146,6 +157,9 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
146
157
  // Check if this chunk needs an i18n group
147
158
  var groupName = chunkToGroup[chunkId];
148
159
  if (groupName && !loadedGroups[groupName]) {
160
+ if (typeof console !== 'undefined' && console.log) {
161
+ console.log('[i18n-group:hook]', chunkId, '→', groupName);
162
+ }
149
163
  // Load the i18n group before the chunk
150
164
  var i18nPromise = loadI18nGroup(groupName);
151
165
  // Chain the promises so i18n loads first
@@ -159,47 +173,70 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
159
173
  }
160
174
 
161
175
  // Also check for webpackI18nGroup comments in dynamic imports
162
- if (typeof __webpack_require__.l !== 'undefined') {
163
- var originalLoadScript = __webpack_require__.l;
164
- __webpack_require__.l = function(url, done, key, chunkId) {
165
- // Check if chunk has i18n group
176
+ function wrapLoadScript(originalLoadScript) {
177
+ return function(url, done, key, chunkId) {
166
178
  var groupName = chunkToGroup[chunkId];
167
179
  if (groupName && !loadedGroups[groupName]) {
168
- // Load i18n before main chunk
169
180
  var locale = ${localeVarName} || 'en_US';
170
181
  var groupConfig = ${JSON.stringify(customGroups)};
171
182
  var config = groupConfig[groupName];
172
-
183
+
173
184
  if (config) {
174
185
  var relativePath = config.filenameTemplate
175
186
  .replace('[locale]', locale);
176
187
  var i18nUrl = buildI18nUrl(relativePath);
177
188
 
178
- if (typeof console !== 'undefined' && console.debug) {
179
- console.debug('[i18n-group:preload]', groupName, i18nUrl);
189
+ if (typeof console !== 'undefined' && console.log) {
190
+ console.log('[i18n-group:preload]', groupName, i18nUrl);
180
191
  }
181
-
182
- // Load i18n first, then the chunk
192
+
183
193
  var i18nScript = document.createElement('script');
184
194
  i18nScript.src = i18nUrl;
185
195
  i18nScript.onload = function() {
186
196
  loadedGroups[groupName] = true;
187
- // Now load the original chunk
197
+ if (typeof console !== 'undefined' && console.log) {
198
+ console.log('[i18n-group:loaded]', groupName, i18nUrl);
199
+ }
188
200
  originalLoadScript.call(__webpack_require__, url, done, key, chunkId);
189
201
  };
190
202
  i18nScript.onerror = function() {
191
- // Continue even if i18n fails
203
+ if (typeof console !== 'undefined' && console.error) {
204
+ console.error('[i18n-group:error]', groupName, i18nUrl);
205
+ }
192
206
  originalLoadScript.call(__webpack_require__, url, done, key, chunkId);
193
207
  };
194
208
  document.head.appendChild(i18nScript);
195
209
  return;
196
210
  }
197
211
  }
198
-
199
- // Default behavior
212
+
200
213
  return originalLoadScript.call(__webpack_require__, url, done, key, chunkId);
201
214
  };
202
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
+ }
203
240
  })();
204
241
  `;
205
242
  }
@@ -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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/client_build_tool",
3
- "version": "0.0.11-exp.19.0",
3
+ "version": "0.0.11-exp.21.0",
4
4
  "description": "A CLI tool to build web applications and client libraries",
5
5
  "main": "lib/index.js",
6
6
  "bin": {