@zohodesk/client_build_tool 0.0.9-exp.8 → 0.0.10-exp.1
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/README.md +74 -0
- package/README_backup.md +74 -0
- package/lib/schemas/defaultConfigValues.js +0 -41
- package/lib/schemas/defaultConfigValuesOnly.js +0 -13
- package/lib/shared/bundler/webpack/jsLoaders.js +2 -15
- package/lib/shared/bundler/webpack/plugins.js +2 -21
- package/npm-shrinkwrap.json +8661 -33
- package/package.json +2 -2
- package/lib/shared/bundler/webpack/common/hashUtils.js +0 -20
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +0 -47
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +0 -190
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectAstKeys.js +0 -98
- package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +0 -94
- package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +0 -201
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +0 -113
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.configI18nNumericIndexPlugin = configI18nNumericIndexPlugin;
|
|
7
|
-
|
|
8
|
-
var {
|
|
9
|
-
I18nNumericIndexPlugin
|
|
10
|
-
} = require("@zohodesk/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin");
|
|
11
|
-
|
|
12
|
-
var {
|
|
13
|
-
I18nNumericIndexHtmlInjectorPlugin
|
|
14
|
-
} = require("../custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin");
|
|
15
|
-
|
|
16
|
-
var {
|
|
17
|
-
readI18nValues
|
|
18
|
-
} = require('../custom_plugins/I18nSplitPlugin/readI18nValues');
|
|
19
|
-
|
|
20
|
-
const path = require('path');
|
|
21
|
-
|
|
22
|
-
function urlConcat(strPath) {
|
|
23
|
-
if (strPath && typeof strPath === 'string' && !strPath.endsWith('/')) {
|
|
24
|
-
return strPath + '/';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return strPath;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function urlJoin(...args) {
|
|
31
|
-
return args.map(part => typeof part === 'string' ? part.replace(/(^\/+|\/+$)/g, '') : '').filter(part => part !== '').join('/');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function configI18nNumericIndexPlugin(options) {
|
|
35
|
-
if (!(options.i18nIndexing && options.i18nIndexing.enable)) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const i18nOpts = options.i18nIndexing;
|
|
40
|
-
const cdnConfig = options.cdnMapping || {};
|
|
41
|
-
const {
|
|
42
|
-
locales,
|
|
43
|
-
allI18nObject
|
|
44
|
-
} = readI18nValues({
|
|
45
|
-
jsResource: i18nOpts.jsResourcePath,
|
|
46
|
-
propertiesFolder: i18nOpts.propertiesFolderPath,
|
|
47
|
-
disableDefault: i18nOpts.disableDefaultMerge !== undefined ? i18nOpts.disableDefaultMerge : false
|
|
48
|
-
});
|
|
49
|
-
const hardcodedDefaultNumericTemplate = 'i18n-chunks/[locale]/numeric.i18n.js';
|
|
50
|
-
const hardcodedDefaultDynamicTemplate = 'i18n-chunks/[locale]/dynamic.i18n.js';
|
|
51
|
-
let numericFilenameTemplate = i18nOpts.numericFilenameTemplate || hardcodedDefaultNumericTemplate;
|
|
52
|
-
let dynamicFilenameTemplate = i18nOpts.dynamicFilenameTemplate || hardcodedDefaultDynamicTemplate;
|
|
53
|
-
|
|
54
|
-
if (i18nOpts.numericFilenameTemplate === undefined) {
|
|
55
|
-
// Check if explicitly undefined or missing
|
|
56
|
-
const i18nSplitFilename = options.i18nChunkSplit && options.i18nChunkSplit.filename;
|
|
57
|
-
|
|
58
|
-
if (i18nSplitFilename && typeof i18nSplitFilename === 'string') {
|
|
59
|
-
// This adaptation logic might need to be more robust
|
|
60
|
-
numericFilenameTemplate = `i18n-chunks/[locale]/${path.basename(i18nSplitFilename).replace(/(\.i18n)?\.js$/, '.numeric.i18n.js')}`;
|
|
61
|
-
} else {
|
|
62
|
-
numericFilenameTemplate = hardcodedDefaultNumericTemplate;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (i18nOpts.dynamicFilenameTemplate === undefined) {
|
|
67
|
-
const i18nSplitFilename = options.i18nChunkSplit && options.i18nChunkSplit.filename;
|
|
68
|
-
|
|
69
|
-
if (i18nSplitFilename && typeof i18nSplitFilename === 'string') {
|
|
70
|
-
dynamicFilenameTemplate = `i18n-chunks/[locale]/${path.basename(i18nSplitFilename).replace(/(\.i18n)?\.js$/, '.dynamic.i18n.js')}`;
|
|
71
|
-
} else {
|
|
72
|
-
dynamicFilenameTemplate = hardcodedDefaultDynamicTemplate;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const htmlTemplateLabel = i18nOpts.htmlTemplateLabel || '{{--user-locale}}';
|
|
77
|
-
const defaultJsonpFunc = options.i18nChunkSplit && options.i18nChunkSplit.jsonpFunc || 'window.loadI18nChunk';
|
|
78
|
-
let i18nAssetsPublicPathPrefix = '';
|
|
79
|
-
|
|
80
|
-
if (cdnConfig.isCdnEnabled) {
|
|
81
|
-
if (cdnConfig.i18nTemplate) {
|
|
82
|
-
i18nAssetsPublicPathPrefix = urlConcat(cdnConfig.i18nTemplate);
|
|
83
|
-
} else if (cdnConfig.jsTemplate) {
|
|
84
|
-
i18nAssetsPublicPathPrefix = urlConcat(cdnConfig.jsTemplate);
|
|
85
|
-
} else {
|
|
86
|
-
const defaultCdnDomainPlaceholder = '//{{--js-static-domain}}';
|
|
87
|
-
i18nAssetsPublicPathPrefix = urlConcat(urlJoin(defaultCdnDomainPlaceholder, options.publicPath === undefined ? '' : options.publicPath));
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
i18nAssetsPublicPathPrefix = urlConcat(options.publicPath === undefined ? '' : options.publicPath);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const pluginBaseOptions = {
|
|
94
|
-
locales,
|
|
95
|
-
allI18nObject,
|
|
96
|
-
numericMapPath: i18nOpts.numericMapPath,
|
|
97
|
-
numericJsonpFunc: i18nOpts.numericJsonpFunc || defaultJsonpFunc,
|
|
98
|
-
dynamicJsonpFunc: i18nOpts.dynamicJsonpFunc || defaultJsonpFunc,
|
|
99
|
-
numericFilenameTemplate,
|
|
100
|
-
// This will now include "i18n-chunks/[locale]/"
|
|
101
|
-
dynamicFilenameTemplate,
|
|
102
|
-
// This will now include "i18n-chunks/[locale]/"
|
|
103
|
-
moduleType: 'i18n/mini-extract',
|
|
104
|
-
mainChunkName: options.i18nChunkSplit && options.i18nChunkSplit.mainChunkName || 'main',
|
|
105
|
-
htmlTemplateLabel,
|
|
106
|
-
localeVarName: i18nOpts.localeVarName
|
|
107
|
-
};
|
|
108
|
-
const htmlInjectorOptions = { ...pluginBaseOptions,
|
|
109
|
-
i18nAssetsPublicPathPrefix: i18nAssetsPublicPathPrefix,
|
|
110
|
-
cspNoncePlaceholder: i18nOpts.cspNoncePlaceholder || '{{--CSP-nonce}}'
|
|
111
|
-
};
|
|
112
|
-
return [new I18nNumericIndexPlugin(pluginBaseOptions), new I18nNumericIndexHtmlInjectorPlugin(htmlInjectorOptions)];
|
|
113
|
-
}
|