@zohodesk/client_build_tool 0.0.11-exp.33.0 → 0.0.11-exp.34.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/schemas/defaultConfigValues.js +1 -2
- package/lib/schemas/defaultConfigValuesOnly.js +1 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js +4 -77
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +30 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +16 -18
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +1 -8
- package/package.json +1 -1
|
@@ -199,8 +199,7 @@ var _default = {
|
|
|
199
199
|
emitFiles: true,
|
|
200
200
|
injectI18nUrlInIndex: true,
|
|
201
201
|
customGroups: null,
|
|
202
|
-
chunkToGroupMapping: {}
|
|
203
|
-
groupPublicPathRuntimeExpression: 'window.__SMAP_PATH__'
|
|
202
|
+
chunkToGroupMapping: {}
|
|
204
203
|
},
|
|
205
204
|
publicFolders: {
|
|
206
205
|
dev: ['...'],
|
|
@@ -116,8 +116,7 @@ var _default = {
|
|
|
116
116
|
emitFiles: true,
|
|
117
117
|
injectI18nUrlInIndex: true,
|
|
118
118
|
customGroups: null,
|
|
119
|
-
chunkToGroupMapping: {}
|
|
120
|
-
groupPublicPathRuntimeExpression: 'window.__SMAP_PATH__'
|
|
119
|
+
chunkToGroupMapping: {}
|
|
121
120
|
},
|
|
122
121
|
publicFolders: {
|
|
123
122
|
dev: ['...'],
|
package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js
CHANGED
|
@@ -19,101 +19,29 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
19
19
|
customGroups,
|
|
20
20
|
chunkIdToGroupMapping,
|
|
21
21
|
localeVarName,
|
|
22
|
-
groupAssetUrls
|
|
23
|
-
publicPathRuntimeExpression
|
|
22
|
+
groupAssetUrls
|
|
24
23
|
} = this.options;
|
|
25
24
|
const chunkIdToGroup = chunkIdToGroupMapping || {};
|
|
26
|
-
const runtimePublicPathResolver = publicPathRuntimeExpression ? `function(){ try { return ${publicPathRuntimeExpression}; } catch (err) { return undefined; } }` : 'function(){ return undefined; }';
|
|
27
25
|
return `
|
|
28
|
-
// I18n Group Loading Runtime
|
|
29
26
|
(function() {
|
|
30
27
|
var loadedGroups = {};
|
|
31
28
|
var chunkIdToGroup = ${JSON.stringify(chunkIdToGroup)};
|
|
32
29
|
var groupAssetUrls = ${JSON.stringify(groupAssetUrls || {})};
|
|
33
|
-
var runtimePublicPathResolver = ${runtimePublicPathResolver};
|
|
34
|
-
var cachedDocumentBase;
|
|
35
|
-
|
|
36
|
-
function ensureTrailingSlash(path) {
|
|
37
|
-
if (!path) return '';
|
|
38
|
-
return path.charAt(path.length - 1) === '/' ? path : path + '/';
|
|
39
|
-
}
|
|
40
30
|
|
|
41
31
|
function normalizeRelativePath(path) {
|
|
42
|
-
|
|
43
|
-
return path.charAt(0) === '/' ? path.slice(1) : path;
|
|
32
|
+
return path && path.charAt(0) === '/' ? path.slice(1) : path;
|
|
44
33
|
}
|
|
45
34
|
|
|
46
35
|
function isFullUrl(value) {
|
|
47
|
-
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
return value.indexOf('://') !== -1 || value.startsWith('//');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function getDocumentBase() {
|
|
54
|
-
if (cachedDocumentBase !== undefined) {
|
|
55
|
-
return cachedDocumentBase;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (typeof document === 'undefined') {
|
|
59
|
-
cachedDocumentBase = '';
|
|
60
|
-
return cachedDocumentBase;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var script = document.currentScript;
|
|
64
|
-
if (!script) {
|
|
65
|
-
var scripts = document.getElementsByTagName('script');
|
|
66
|
-
if (scripts.length) {
|
|
67
|
-
script = scripts[scripts.length - 1];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (script && script.src) {
|
|
72
|
-
var scriptUrl = script.src.replace(/[?#].*$/, '');
|
|
73
|
-
var lastSlash = scriptUrl.lastIndexOf('/');
|
|
74
|
-
var withoutFile = lastSlash >= 0 ? scriptUrl.slice(0, lastSlash + 1) : '';
|
|
75
|
-
var normalized = withoutFile.endsWith('js/')
|
|
76
|
-
? withoutFile.slice(0, withoutFile.length - 3)
|
|
77
|
-
: withoutFile;
|
|
78
|
-
cachedDocumentBase = ensureTrailingSlash(normalized);
|
|
79
|
-
} else {
|
|
80
|
-
cachedDocumentBase = '';
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return cachedDocumentBase;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function resolveRuntimePublicPath() {
|
|
87
|
-
var dynamicBase = runtimePublicPathResolver();
|
|
88
|
-
if (dynamicBase != null && dynamicBase !== '') {
|
|
89
|
-
return ensureTrailingSlash(String(dynamicBase));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
var webpackPublicPath = ${_webpack.RuntimeGlobals.publicPath};
|
|
93
|
-
if (typeof webpackPublicPath === 'string' && webpackPublicPath) {
|
|
94
|
-
return ensureTrailingSlash(webpackPublicPath);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
var documentBase = getDocumentBase();
|
|
98
|
-
if (documentBase) {
|
|
99
|
-
return documentBase;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return '';
|
|
36
|
+
return typeof value === 'string' && (value.indexOf('://') !== -1 || value.startsWith('//'));
|
|
103
37
|
}
|
|
104
38
|
|
|
105
39
|
function buildI18nUrl(relativePath) {
|
|
106
|
-
if (!relativePath) {
|
|
107
|
-
return resolveRuntimePublicPath();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
40
|
if (isFullUrl(relativePath)) {
|
|
111
41
|
return relativePath;
|
|
112
42
|
}
|
|
113
|
-
|
|
114
43
|
var normalizedPath = normalizeRelativePath(relativePath);
|
|
115
|
-
|
|
116
|
-
return base + normalizedPath;
|
|
44
|
+
return ${_webpack.RuntimeGlobals.publicPath} + normalizedPath;
|
|
117
45
|
}
|
|
118
46
|
|
|
119
47
|
function loadI18nGroup(groupName) {
|
|
@@ -185,7 +113,6 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
|
|
|
185
113
|
promises.push(loadI18nGroup(groupName));
|
|
186
114
|
}
|
|
187
115
|
};
|
|
188
|
-
|
|
189
116
|
function detectGroupFromUrl() {
|
|
190
117
|
if (typeof window === 'undefined') {
|
|
191
118
|
return null;
|
|
@@ -23,16 +23,12 @@ class I18nNumericIndexHtmlInjectorPlugin {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
apply(compiler) {
|
|
26
|
-
console.log(`[I18nNumericIndexHtmlInjectorPlugin] Plugin loaded - v1.0.0`);
|
|
27
26
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
28
|
-
_htmlWebpackPlugin.default.getHooks(compilation).
|
|
27
|
+
_htmlWebpackPlugin.default.getHooks(compilation).alterAssetTagGroups.tapAsync(pluginName, (data, cb) => {
|
|
29
28
|
if (!this.options.injectI18nUrlInIndex) {
|
|
30
|
-
return cb(null,
|
|
29
|
+
return cb(null, data);
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
const {
|
|
34
|
-
assets
|
|
35
|
-
} = hookData;
|
|
36
32
|
const {
|
|
37
33
|
outputFolder = 'i18n-chunk',
|
|
38
34
|
numericFilenameTemplate,
|
|
@@ -42,7 +38,7 @@ class I18nNumericIndexHtmlInjectorPlugin {
|
|
|
42
38
|
singleFile,
|
|
43
39
|
i18nAssetsPublicPathPrefix = ''
|
|
44
40
|
} = this.options;
|
|
45
|
-
const
|
|
41
|
+
const i18nScriptTags = [];
|
|
46
42
|
const emittedAssetNames = compilation.getAssets().map(asset => asset.name);
|
|
47
43
|
const recordedAssets = compilation[assetStoreKey] || [];
|
|
48
44
|
|
|
@@ -83,27 +79,48 @@ class I18nNumericIndexHtmlInjectorPlugin {
|
|
|
83
79
|
const combinedFilename = resolveAssetPath(singleFileTemplate, 'single');
|
|
84
80
|
|
|
85
81
|
if (combinedFilename) {
|
|
86
|
-
|
|
82
|
+
i18nScriptTags.push({
|
|
83
|
+
tagName: 'script',
|
|
84
|
+
voidTag: false,
|
|
85
|
+
attributes: {
|
|
86
|
+
src: combinedFilename,
|
|
87
|
+
nonce: '{{--CSP-nonce}}'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
87
90
|
}
|
|
88
91
|
} else {
|
|
89
92
|
const numericFilename = resolveAssetPath(numericFilenameTemplate, 'numeric');
|
|
90
93
|
|
|
91
94
|
if (numericFilename) {
|
|
92
|
-
|
|
95
|
+
i18nScriptTags.push({
|
|
96
|
+
tagName: 'script',
|
|
97
|
+
voidTag: false,
|
|
98
|
+
attributes: {
|
|
99
|
+
src: numericFilename,
|
|
100
|
+
nonce: '{{--CSP-nonce}}'
|
|
101
|
+
}
|
|
102
|
+
});
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
const dynamicFilename = resolveAssetPath(dynamicFilenameTemplate, 'dynamic');
|
|
96
106
|
|
|
97
107
|
if (dynamicFilename) {
|
|
98
|
-
|
|
108
|
+
i18nScriptTags.push({
|
|
109
|
+
tagName: 'script',
|
|
110
|
+
voidTag: false,
|
|
111
|
+
attributes: {
|
|
112
|
+
src: dynamicFilename,
|
|
113
|
+
nonce: '{{--CSP-nonce}}'
|
|
114
|
+
}
|
|
115
|
+
});
|
|
99
116
|
}
|
|
100
117
|
}
|
|
101
118
|
|
|
102
|
-
if (
|
|
103
|
-
|
|
119
|
+
if (i18nScriptTags.length > 0) {
|
|
120
|
+
data.headTags = [...i18nScriptTags, ...data.headTags];
|
|
104
121
|
}
|
|
105
122
|
|
|
106
|
-
|
|
123
|
+
cb(null, data);
|
|
107
124
|
});
|
|
108
125
|
});
|
|
109
126
|
}
|
package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js
CHANGED
|
@@ -53,8 +53,7 @@ class I18nNumericIndexPlugin {
|
|
|
53
53
|
outputFolder: options.outputFolder || 'i18n-chunk',
|
|
54
54
|
manifestPath: options.manifestPath || null,
|
|
55
55
|
emitFiles: options.emitFiles !== undefined ? options.emitFiles : true,
|
|
56
|
-
chunkToGroupMapping: options.chunkToGroupMapping || {}
|
|
57
|
-
groupPublicPathRuntimeExpression: options.groupPublicPathRuntimeExpression || ''
|
|
56
|
+
chunkToGroupMapping: options.chunkToGroupMapping || {}
|
|
58
57
|
};
|
|
59
58
|
this.numericMap = {};
|
|
60
59
|
this.customGroups = {};
|
|
@@ -67,7 +66,6 @@ class I18nNumericIndexPlugin {
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
apply(compiler) {
|
|
70
|
-
console.log(`[I18nNumericIndexPlugin] Plugin loaded - v1.0.0`);
|
|
71
69
|
this.detectI18nGroupComments(compiler);
|
|
72
70
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
73
71
|
this.groupAssetUrls = {};
|
|
@@ -86,10 +84,7 @@ class I18nNumericIndexPlugin {
|
|
|
86
84
|
customGroups: this.options.customGroups,
|
|
87
85
|
chunkIdToGroupMapping: chunkMapping,
|
|
88
86
|
localeVarName: this.options.localeVarName,
|
|
89
|
-
|
|
90
|
-
groupAssetUrls: this.groupAssetUrls,
|
|
91
|
-
includeContentHash: this.options.includeContentHash,
|
|
92
|
-
publicPathRuntimeExpression: this.options.groupPublicPathRuntimeExpression
|
|
87
|
+
groupAssetUrls: this.groupAssetUrls
|
|
93
88
|
}));
|
|
94
89
|
}
|
|
95
90
|
});
|
|
@@ -177,9 +172,7 @@ class I18nNumericIndexPlugin {
|
|
|
177
172
|
}
|
|
178
173
|
}
|
|
179
174
|
});
|
|
180
|
-
} catch (err) {
|
|
181
|
-
console.warn(`[I18nNumericIndexPlugin] Failed to read properties folder: ${err.message}`);
|
|
182
|
-
}
|
|
175
|
+
} catch (err) {}
|
|
183
176
|
|
|
184
177
|
return locales;
|
|
185
178
|
}
|
|
@@ -208,7 +201,6 @@ class I18nNumericIndexPlugin {
|
|
|
208
201
|
...this.normalizeObjectValues(localeProperties)
|
|
209
202
|
};
|
|
210
203
|
} catch (err) {
|
|
211
|
-
console.warn(`[I18nNumericIndexPlugin] Failed to load locale ${locale}: ${err.message}`);
|
|
212
204
|
return;
|
|
213
205
|
}
|
|
214
206
|
}
|
|
@@ -291,12 +283,20 @@ class I18nNumericIndexPlugin {
|
|
|
291
283
|
}
|
|
292
284
|
|
|
293
285
|
compilation.fileDependencies.add(_path.default.resolve(jsResourcePath));
|
|
294
|
-
compilation.fileDependencies.add(_path.default.resolve(propertiesFolderPath));
|
|
295
286
|
|
|
296
287
|
if (numericMapPath) {
|
|
297
288
|
compilation.fileDependencies.add(_path.default.resolve(numericMapPath));
|
|
298
|
-
}
|
|
289
|
+
}
|
|
299
290
|
|
|
291
|
+
try {
|
|
292
|
+
const propertiesFiles = _fs.default.readdirSync(propertiesFolderPath);
|
|
293
|
+
|
|
294
|
+
propertiesFiles.forEach(file => {
|
|
295
|
+
if (file.endsWith('.properties')) {
|
|
296
|
+
compilation.fileDependencies.add(_path.default.resolve(propertiesFolderPath, file));
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
} catch (err) {}
|
|
300
300
|
|
|
301
301
|
this.numericMap = {};
|
|
302
302
|
this.manifest = {};
|
|
@@ -322,10 +322,9 @@ class I18nNumericIndexPlugin {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
const availableLocales = this.getAvailableLocales(propertiesFolderPath);
|
|
325
|
-
console.log(`[I18nNumericIndexPlugin] Processing ${availableLocales.length} locales:`, availableLocales.join(', '));
|
|
326
325
|
availableLocales.forEach(locale => {
|
|
327
326
|
this.processLocale(locale, jsResourceKeys, propertiesFolderPath, compilation);
|
|
328
|
-
});
|
|
327
|
+
});
|
|
329
328
|
|
|
330
329
|
if (this.options.generateManifest && Object.keys(this.manifest).length > 0) {
|
|
331
330
|
const manifestPath = this.options.manifestPath || _path.default.join(this.options.outputFolder, 'manifest.json');
|
|
@@ -431,7 +430,7 @@ class I18nNumericIndexPlugin {
|
|
|
431
430
|
}
|
|
432
431
|
|
|
433
432
|
const content = this.generateChunkContent(data, jsonpFunc, groupName);
|
|
434
|
-
let outputPath = this.constructFilePath(filenameTemplate, locale);
|
|
433
|
+
let outputPath = this.constructFilePath(filenameTemplate, locale);
|
|
435
434
|
|
|
436
435
|
if (outputPath.includes('[contenthash]')) {
|
|
437
436
|
const contentHash = this.generateContentHash(content, compilation);
|
|
@@ -439,8 +438,7 @@ class I18nNumericIndexPlugin {
|
|
|
439
438
|
} else if (this.options.includeContentHash) {
|
|
440
439
|
const contentHash = this.generateContentHash(content, compilation);
|
|
441
440
|
outputPath = outputPath.replace(/\.js$/, `.${contentHash}.js`);
|
|
442
|
-
}
|
|
443
|
-
|
|
441
|
+
}
|
|
444
442
|
|
|
445
443
|
if (this.options.generateManifest) {
|
|
446
444
|
const manifestKey = this.options.singleFile ? `${locale}.js` : outputPath;
|
|
@@ -21,12 +21,6 @@ function configI18nNumericIndexPlugin(options) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const i18nOpts = options.i18nIndexing;
|
|
24
|
-
const cdnMapping = options.cdnMapping || {};
|
|
25
|
-
const cdnVariableName = cdnMapping.variableName || 'window.__SMAP_PATH__';
|
|
26
|
-
const {
|
|
27
|
-
groupPublicPathRuntimeExpression: configuredRuntimeExpression
|
|
28
|
-
} = i18nOpts;
|
|
29
|
-
const groupPublicPathRuntimeExpression = configuredRuntimeExpression !== undefined ? configuredRuntimeExpression : cdnVariableName;
|
|
30
24
|
|
|
31
25
|
try {
|
|
32
26
|
const result = (0, _i18nOptionsValidator.validateI18nIndexingOptions)(i18nOpts);
|
|
@@ -86,8 +80,7 @@ function configI18nNumericIndexPlugin(options) {
|
|
|
86
80
|
manifestPath: i18nOpts.manifestPath || null,
|
|
87
81
|
customGroups: i18nOpts.customGroups || null,
|
|
88
82
|
chunkToGroupMapping: i18nOpts.chunkToGroupMapping || {},
|
|
89
|
-
emitFiles
|
|
90
|
-
groupPublicPathRuntimeExpression
|
|
83
|
+
emitFiles
|
|
91
84
|
};
|
|
92
85
|
const htmlInjectorOptions = { ...sharedOptions,
|
|
93
86
|
htmlTemplateLabel: i18nOpts.htmlTemplateLabel,
|