@zohodesk/react-cli 1.1.18-exp.1 → 1.1.18-exp.2
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/cli.js +4 -0
- package/lib/babel/cmjs-plugins-presets.js +11 -12
- package/lib/babel/es-plugins-presets.js +12 -12
- package/lib/configs/webpack.dev.config.js +4 -0
- package/lib/configs/webpack.prod.config.js +6 -9
- package/lib/loaderUtils/getDevJsLoaders.js +1 -5
- package/lib/schemas/index.js +3 -0
- package/npm-shrinkwrap.json +1076 -31
- package/package.json +6 -1
- package/lib/babel/babel-option-utils/babel-preset-react-option.js +0 -22
- package/packages/client_build_tool/lib/allCommandsConfigs.js +0 -23
- package/packages/client_build_tool/lib/buildToolLoggers.js +0 -32
- package/packages/client_build_tool/lib/commands/build/commandExecutor.js +0 -21
- package/packages/client_build_tool/lib/commands/build/config.js +0 -12
- package/packages/client_build_tool/lib/commands/build/errorHander.js +0 -10
- package/packages/client_build_tool/lib/commands/build/index.js +0 -35
- package/packages/client_build_tool/lib/commands/build/optionsProcesser.js +0 -40
- package/packages/client_build_tool/lib/commands/buildEs/commandExecutor.js +0 -17
- package/packages/client_build_tool/lib/commands/buildEs/config.js +0 -12
- package/packages/client_build_tool/lib/commands/buildLib/commandExecutor.js +0 -17
- package/packages/client_build_tool/lib/commands/buildLib/config.js +0 -12
- package/packages/client_build_tool/lib/commands/start/commandExecutor.js +0 -13
- package/packages/client_build_tool/lib/commands/start/config.js +0 -12
- package/packages/client_build_tool/lib/commands/start/deprecationHandler.js +0 -10
- package/packages/client_build_tool/lib/commands/start/errorHander.js +0 -10
- package/packages/client_build_tool/lib/commands/start/optionsProcesser.js +0 -36
- package/packages/client_build_tool/lib/commands/start/postProcesser.js +0 -10
- package/packages/client_build_tool/lib/commands/start/preProcesser.js +0 -10
- package/packages/client_build_tool/lib/commandsRouter.js +0 -71
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/decidePublicPath.js +0 -44
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/libAlias.js +0 -31
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/nameTemplates.js +0 -51
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +0 -21
- package/packages/client_build_tool/lib/shared/bundler/webpack/cssLoaders.js +0 -16
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin.js +0 -111
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/EFCPlugin.js +0 -1
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +0 -11
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +0 -136
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +0 -95
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +0 -25
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +0 -29
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -24
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nDependency.js +0 -99
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +0 -81
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nModule.js +0 -201
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +0 -401
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +0 -67
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -23
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +0 -29
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +0 -49
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +0 -77
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +0 -63
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +0 -19
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -31
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -127
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +0 -1
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +0 -63
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +0 -89
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +0 -34
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +0 -15
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +0 -155
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin.js +0 -49
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/ExcludePlugin.js +0 -58
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/RTLSplitPlugin.js +0 -139
- package/packages/client_build_tool/lib/shared/bundler/webpack/devServerConfig.js +0 -34
- package/packages/client_build_tool/lib/shared/bundler/webpack/getCSSLoaders.js +0 -30
- package/packages/client_build_tool/lib/shared/bundler/webpack/jsLoaders.js +0 -17
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -14
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +0 -24
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -18
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -21
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -138
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +0 -83
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +0 -23
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaders/workerLoader.js +0 -133
- package/packages/client_build_tool/lib/shared/bundler/webpack/optimizationConfig.js +0 -39
- package/packages/client_build_tool/lib/shared/bundler/webpack/outputConfig.js +0 -28
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +0 -18
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCopyThirdpartyFile.js +0 -38
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -24
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +0 -28
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +0 -35
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -16
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +0 -23
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +0 -19
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -27
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +0 -18
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configUglifyCSSPlugin.js +0 -15
- package/packages/client_build_tool/lib/shared/bundler/webpack/plugins.js +0 -39
- package/packages/client_build_tool/lib/shared/bundler/webpack/postcssPlugins.js +0 -36
- package/packages/client_build_tool/lib/shared/bundler/webpack/resolvers.js +0 -42
- package/packages/client_build_tool/lib/shared/bundler/webpack/splitChunksConfig.js +0 -12
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpack.dev.config.js +0 -17
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpackBuild.js +0 -24
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpackConfig.js +0 -50
- package/packages/client_build_tool/lib/shared/commands-utlis/doBasicRequiermentCheck.js +0 -16
- package/packages/client_build_tool/lib/shared/commands-utlis/getCliPath.js +0 -38
- package/packages/client_build_tool/lib/shared/commands-utlis/index.js +0 -29
- package/packages/client_build_tool/lib/shared/commands-utlis/log.js +0 -13
- package/packages/client_build_tool/lib/shared/commands-utlis/readArgsFormCommandLine.js +0 -11
- package/packages/client_build_tool/lib/shared/commands-utlis/readOptionFormCommandLine.js +0 -11
- package/packages/client_build_tool/lib/shared/commands-utlis/spanSync.js +0 -35
- package/packages/client_build_tool/lib/shared/constants.js +0 -33
- package/packages/client_build_tool/lib/shared/schemas/applyValuesToShema.js +0 -37
- package/packages/client_build_tool/lib/shared/schemas/cliArgsToObject.js +0 -37
- package/packages/client_build_tool/lib/shared/schemas/defaultConfigValues.js +0 -119
- package/packages/client_build_tool/lib/shared/schemas/deprecatedOptionsHandler.js +0 -65
- package/packages/client_build_tool/lib/shared/schemas/getCWD.js +0 -23
- package/packages/client_build_tool/lib/shared/schemas/getNpmVersion.js +0 -21
- package/packages/client_build_tool/lib/shared/schemas/npmConfigToObject.js +0 -32
- package/packages/client_build_tool/lib/shared/schemas/oldDefaultConfigValues.js +0 -480
- package/packages/client_build_tool/lib/shared/schemas/readOptions.js +0 -55
- package/packages/client_build_tool/lib/shared/schemas/readOptionsForPackageJson.js +0 -26
- package/packages/client_build_tool/lib/shared/schemas/readOptionsOld.js +0 -152
- package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.crt +0 -37
- package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.key +0 -27
- package/packages/client_build_tool/lib/shared/server/configWebpackDevMiddleware.js +0 -40
- package/packages/client_build_tool/lib/shared/server/corsHandleing.js +0 -28
- package/packages/client_build_tool/lib/shared/server/getIp.js +0 -30
- package/packages/client_build_tool/lib/shared/server/getServerURL.js +0 -29
- package/packages/client_build_tool/lib/shared/server/httpsOptions.js +0 -53
- package/packages/client_build_tool/lib/shared/server/initExpressApp.js +0 -19
- package/packages/client_build_tool/lib/shared/server/initialHTMLHandling.js +0 -66
- package/packages/client_build_tool/lib/shared/server/serveContextFiles.js +0 -24
- package/packages/client_build_tool/lib/shared/server/serverBywebpackDevMiddleware.js +0 -40
- package/packages/client_build_tool/lib/shared/server/startHttpServer.js +0 -26
- package/packages/client_build_tool/lib/shared/server/startHttpsServer.js +0 -34
- package/packages/client_build_tool/lib/shared/server/unwanted/addHttp2Server.js +0 -41
- package/packages/client_build_tool/lib/shared/server/unwanted/configWebpackDevMiddleware.js +0 -44
- package/packages/client_build_tool/lib/shared/server/unwanted/devServerUtlis.js +0 -1
- package/packages/client_build_tool/lib/shared/server/unwanted/mockApiSupport.js +0 -19
- package/packages/client_build_tool/lib/shared/server/unwanted/webpackConfig.js +0 -32
- package/packages/client_build_tool/lib/shared/server/unwanted/websocketMockSetup.js +0 -48
- package/packages/client_build_tool/lib/shared/server/urlConcat.js +0 -25
- package/packages/client_build_tool/lib/shared/utils/utils.js +0 -1
@@ -1,29 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.readI18nValues = readI18nValues;
|
7
|
-
|
8
|
-
var _propertiesUtils = require("./utils/propertiesUtils");
|
9
|
-
|
10
|
-
// gethere i18n keys and values
|
11
|
-
function readI18nValues({
|
12
|
-
jsResource,
|
13
|
-
propertiesFolder,
|
14
|
-
disableDefault
|
15
|
-
}) {
|
16
|
-
const jsResourceI18nKeys = jsResource ? (0, _propertiesUtils.getPropertiesAsJSON)(jsResource) : {};
|
17
|
-
const allI18nObject = (0, _propertiesUtils.getAllI18n)({
|
18
|
-
folderPath: propertiesFolder,
|
19
|
-
disableDefault,
|
20
|
-
jsResourceI18nKeys
|
21
|
-
}); // initialize base data's and plugis
|
22
|
-
|
23
|
-
const locales = Object.keys(allI18nObject);
|
24
|
-
return {
|
25
|
-
jsResourceI18nKeys,
|
26
|
-
allI18nObject,
|
27
|
-
locales
|
28
|
-
};
|
29
|
-
}
|
@@ -1,49 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.templateFileName = templateFileName;
|
7
|
-
|
8
|
-
var _templateHashHelpers = require("./templateHashHelpers");
|
9
|
-
|
10
|
-
function templateFileName({
|
11
|
-
compiler,
|
12
|
-
compilation,
|
13
|
-
dynamicFilename,
|
14
|
-
locale,
|
15
|
-
chunks,
|
16
|
-
contentHashes
|
17
|
-
}) {
|
18
|
-
const {
|
19
|
-
webpack
|
20
|
-
} = compiler;
|
21
|
-
const {
|
22
|
-
Template,
|
23
|
-
RuntimeGlobals
|
24
|
-
} = webpack;
|
25
|
-
const MODULE_TYPE = 'text/mini-i18n';
|
26
|
-
const {
|
27
|
-
mapExpr,
|
28
|
-
mapExprWithLength
|
29
|
-
} = (0, _templateHashHelpers.templateHashHelpers)(chunks); // "i18n-chunk/[locale]/[name].[chunkhash].js"
|
30
|
-
|
31
|
-
const i18nURLPathTemplate = compilation.getPath(JSON.stringify(dynamicFilename).replace(/\[locale\]/gi, '"+ locale +"'), {
|
32
|
-
hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
|
33
|
-
hashWithLength: length => `" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
|
34
|
-
chunk: {
|
35
|
-
id: '" + chunkId + "',
|
36
|
-
hash: mapExpr(c => c.renderedHash),
|
37
|
-
hashWithLength: mapExprWithLength(c => c.renderedHash),
|
38
|
-
name: mapExpr(c => c.name || c.id),
|
39
|
-
contentHash: {
|
40
|
-
[MODULE_TYPE]: mapExpr(c => contentHashes[c.id])
|
41
|
-
},
|
42
|
-
contentHashWithLength: {
|
43
|
-
[MODULE_TYPE]: mapExprWithLength(c => contentHashes[c.id])
|
44
|
-
}
|
45
|
-
},
|
46
|
-
contentHashType: MODULE_TYPE
|
47
|
-
});
|
48
|
-
return Template.asString([`var locale = ${JSON.stringify(locale)};`, `${RuntimeGlobals.require}.miniI18nF = function(chunkId){return (${i18nURLPathTemplate})}`]);
|
49
|
-
}
|
@@ -1,77 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.templateHashHelpers = templateHashHelpers;
|
7
|
-
|
8
|
-
/**
|
9
|
-
* this function will be used for chunk name, chunk hash, contentHash
|
10
|
-
* in these, sometime chunk name and chunk id same for some chunkss so below logic has little towek
|
11
|
-
* @param {Chunk} chunks
|
12
|
-
* @returns { mapExpr, mapExprWithLength }
|
13
|
-
*/
|
14
|
-
function templateHashHelpers(chunks) {
|
15
|
-
/**
|
16
|
-
* @param {function(Chunk): string | number} fn function from chunk to value
|
17
|
-
* @returns {string} code with static mapping of results of fn
|
18
|
-
*/
|
19
|
-
const createMap = fn => {
|
20
|
-
const obj = {};
|
21
|
-
let useId = false;
|
22
|
-
let lastKey;
|
23
|
-
let entries = 0; // eslint-disable-next-line no-restricted-syntax
|
24
|
-
|
25
|
-
for (const c of chunks) {
|
26
|
-
const value = fn(c);
|
27
|
-
|
28
|
-
if (value === c.id) {
|
29
|
-
useId = true;
|
30
|
-
} else {
|
31
|
-
obj[c.id] = value;
|
32
|
-
lastKey = c.id;
|
33
|
-
entries++;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
if (entries === 0) {
|
38
|
-
return 'chunkId';
|
39
|
-
}
|
40
|
-
|
41
|
-
if (entries === 1) {
|
42
|
-
return useId ? `(chunkId === ${JSON.stringify(lastKey)} ? ${JSON.stringify(obj[lastKey])} : chunkId)` : JSON.stringify(obj[lastKey]);
|
43
|
-
}
|
44
|
-
|
45
|
-
return useId ? `(${JSON.stringify(obj)}[chunkId] || chunkId)` : `${JSON.stringify(obj)}[chunkId]`;
|
46
|
-
};
|
47
|
-
/**
|
48
|
-
* @param {function(Chunk): string | number} fn function from chunk to value
|
49
|
-
* @returns {string} code with static mapping of results of fn for including in quoted string
|
50
|
-
*/
|
51
|
-
|
52
|
-
|
53
|
-
const mapExpr = fn => `" + ${createMap(fn)} + "`;
|
54
|
-
/**
|
55
|
-
* @param {function(Chunk): string | number} fn function from chunk to value
|
56
|
-
* @returns {function(number): string} function which generates code with static mapping of results of fn for including in quoted string for specific length
|
57
|
-
*/
|
58
|
-
|
59
|
-
|
60
|
-
const mapExprWithLength = fn => length => // console.log('called with lentch', length),
|
61
|
-
`" + ${createMap(c => `${fn(c)}`.slice(0, length))} + "`;
|
62
|
-
|
63
|
-
return {
|
64
|
-
mapExpr,
|
65
|
-
mapExprWithLength
|
66
|
-
};
|
67
|
-
}
|
68
|
-
/**
|
69
|
-
function mapExpr(fn) {
|
70
|
-
const obj = {};
|
71
|
-
// eslint-disable-next-line no-restricted-syntax
|
72
|
-
for (const c of chunks) {
|
73
|
-
obj[c.id] = fn(c);
|
74
|
-
}
|
75
|
-
return `(${JSON.stringify(obj)})[chunkId]`;
|
76
|
-
}
|
77
|
-
*/
|
@@ -1,63 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.collectI18nKeysfromAST = collectI18nKeysfromAST;
|
7
|
-
exports.collectI18nKeysfromComments = collectI18nKeysfromComments;
|
8
|
-
|
9
|
-
var _estreeWalker = require("estree-walker");
|
10
|
-
|
11
|
-
// const { walk } = require('estree-walker');
|
12
|
-
function collectI18nKeysfromAST(ast, allI18n) {
|
13
|
-
let i18nKeys = {};
|
14
|
-
(0, _estreeWalker.walk)(ast, {
|
15
|
-
enter: function (node) {
|
16
|
-
if (node.type === 'Literal') {
|
17
|
-
if ((node.raw[0] === '\'' || node.raw[0] === '"') && Object.hasOwnProperty.call(allI18n, node.value)) {
|
18
|
-
i18nKeys[node.value] = allI18n[node.value];
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
});
|
23
|
-
return Object.keys(i18nKeys);
|
24
|
-
}
|
25
|
-
|
26
|
-
const prefixI18nComment = 'I18N';
|
27
|
-
const prefixI18nComment1 = 'dynamic-i18n-key';
|
28
|
-
|
29
|
-
function getI18nKeysFromComment(comment) {
|
30
|
-
let commentString = comment.value.trim();
|
31
|
-
let i18nKeyStr;
|
32
|
-
|
33
|
-
if (commentString.startsWith(prefixI18nComment)) {
|
34
|
-
i18nKeyStr = commentString.slice(prefixI18nComment.length).trim();
|
35
|
-
} else if (commentString.startsWith(prefixI18nComment1)) {
|
36
|
-
i18nKeyStr = commentString.slice(prefixI18nComment1.length).trim();
|
37
|
-
}
|
38
|
-
|
39
|
-
if (!i18nKeyStr) {
|
40
|
-
return [];
|
41
|
-
}
|
42
|
-
|
43
|
-
const i18nKeys = i18nKeyStr.split(',');
|
44
|
-
return i18nKeys;
|
45
|
-
} // export function fromComments(comments, allI18n) {
|
46
|
-
|
47
|
-
|
48
|
-
function collectI18nKeysfromComments(comments, allI18n) {
|
49
|
-
// TODO: need to implement
|
50
|
-
let i18nKeys = {};
|
51
|
-
|
52
|
-
for (let comment of comments) {
|
53
|
-
let keys = getI18nKeysFromComment(comment);
|
54
|
-
|
55
|
-
for (let key of keys) {
|
56
|
-
if (key && allI18n[key]) {
|
57
|
-
i18nKeys[key] = allI18n[key];
|
58
|
-
}
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
return Object.keys(i18nKeys);
|
63
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.REGEXP_CONTENTHASH = void 0;
|
7
|
-
exports.hasContentHash = hasContentHash;
|
8
|
-
// export const REGEXP_CHUNKHASH = /\[chunkhash(?::(\d+))?\]/gi;
|
9
|
-
// export const REGEXP_HASH = /\[hash(?::(\d+))?\]/gi;
|
10
|
-
// export const REGEXP_NAME = /\[name\]/gi;
|
11
|
-
// export const REGEXP_PLACEHOLDERS = /\[(name|id|chunkhash)\]/gi;
|
12
|
-
// TODO: want to choose file type for i18n load
|
13
|
-
const REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/gi;
|
14
|
-
exports.REGEXP_CONTENTHASH = REGEXP_CONTENTHASH;
|
15
|
-
|
16
|
-
function hasContentHash(filenameTemplate) {
|
17
|
-
REGEXP_CONTENTHASH.lastIndex = 0;
|
18
|
-
return REGEXP_CONTENTHASH.test(filenameTemplate);
|
19
|
-
}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
|
7
|
-
var _collectI18nKeys = require("./collectI18nKeys");
|
8
|
-
|
9
|
-
Object.keys(_collectI18nKeys).forEach(function (key) {
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
11
|
-
if (key in exports && exports[key] === _collectI18nKeys[key]) return;
|
12
|
-
Object.defineProperty(exports, key, {
|
13
|
-
enumerable: true,
|
14
|
-
get: function () {
|
15
|
-
return _collectI18nKeys[key];
|
16
|
-
}
|
17
|
-
});
|
18
|
-
});
|
19
|
-
|
20
|
-
var _propertiesUtils = require("./propertiesUtils");
|
21
|
-
|
22
|
-
Object.keys(_propertiesUtils).forEach(function (key) {
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
24
|
-
if (key in exports && exports[key] === _propertiesUtils[key]) return;
|
25
|
-
Object.defineProperty(exports, key, {
|
26
|
-
enumerable: true,
|
27
|
-
get: function () {
|
28
|
-
return _propertiesUtils[key];
|
29
|
-
}
|
30
|
-
});
|
31
|
-
});
|
@@ -1,127 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.getAllI18n = getAllI18n;
|
7
|
-
exports.getPropertiesAsJSON = getPropertiesAsJSON;
|
8
|
-
exports.jsonToString = jsonToString;
|
9
|
-
|
10
|
-
var _fs = require("fs");
|
11
|
-
|
12
|
-
var _path = require("path");
|
13
|
-
|
14
|
-
function isComment(line) {
|
15
|
-
return line[0] === '#';
|
16
|
-
}
|
17
|
-
|
18
|
-
function getPropertiesAsJSON(filePath) {
|
19
|
-
try {
|
20
|
-
const data = (0, _fs.readFileSync)(filePath);
|
21
|
-
const source = data.toString();
|
22
|
-
const i18nObj = {};
|
23
|
-
source.split(/\r?\n\r?/).forEach(fline => {
|
24
|
-
const line = fline.trim();
|
25
|
-
|
26
|
-
if (!line || isComment(line)) {
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
|
30
|
-
const ind = line.indexOf('=');
|
31
|
-
const key = line.slice(0, ind).replace(/\\ /g, ' ');
|
32
|
-
const value = line.slice(ind + 1);
|
33
|
-
|
34
|
-
if (key && value) {
|
35
|
-
i18nObj[key] = value;
|
36
|
-
}
|
37
|
-
}, {});
|
38
|
-
return i18nObj;
|
39
|
-
} catch (err) {
|
40
|
-
return {};
|
41
|
-
}
|
42
|
-
} // TODO: need to make it as custom option and dynamic
|
43
|
-
|
44
|
-
|
45
|
-
function getLang(file) {
|
46
|
-
const underScoreIndex = file.indexOf('_');
|
47
|
-
let language = 'en_US';
|
48
|
-
|
49
|
-
if (underScoreIndex !== -1) {
|
50
|
-
language = file.substring(underScoreIndex + 1);
|
51
|
-
language = language.slice(0, language.indexOf('.'));
|
52
|
-
}
|
53
|
-
|
54
|
-
return language;
|
55
|
-
}
|
56
|
-
|
57
|
-
function getAllI18n({
|
58
|
-
folderPath,
|
59
|
-
disableDefault,
|
60
|
-
jsResourceI18nKeys,
|
61
|
-
exclude = /^[^_]+$/,
|
62
|
-
include = /\.properties$/
|
63
|
-
}) {
|
64
|
-
try {
|
65
|
-
const files = (0, _fs.readdirSync)(folderPath, 'utf8');
|
66
|
-
const allLangI18n = {};
|
67
|
-
const context = (0, _path.join)(process.cwd(), folderPath);
|
68
|
-
files.forEach(file => {
|
69
|
-
const filePath = (0, _path.join)(context, file);
|
70
|
-
|
71
|
-
if (exclude.test(filePath) || !include.test(filePath)) {
|
72
|
-
return;
|
73
|
-
}
|
74
|
-
|
75
|
-
const i18n = getPropertiesAsJSON(filePath);
|
76
|
-
allLangI18n[getLang(file)] = disableDefault ? i18n : { ...jsResourceI18nKeys,
|
77
|
-
...i18n
|
78
|
-
};
|
79
|
-
});
|
80
|
-
return allLangI18n;
|
81
|
-
} catch (err) {
|
82
|
-
console.log(err);
|
83
|
-
return {};
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
|
-
function jsonToString(json, keySeperator) {
|
88
|
-
let str = '{';
|
89
|
-
const keys = Object.keys(json);
|
90
|
-
keys.forEach((key, i) => {
|
91
|
-
const value = json[key];
|
92
|
-
|
93
|
-
if (!value) {
|
94
|
-
return;
|
95
|
-
}
|
96
|
-
|
97
|
-
str += `"${keySeperator ? key.replace(/(\.|\\(\s+))/g, keySeperator) : key}":"${value.replace(/.?"/g, match => {
|
98
|
-
if (match[0] === '\\') {
|
99
|
-
return match;
|
100
|
-
}
|
101
|
-
|
102
|
-
if (match.length === 2) {
|
103
|
-
return `${match[0]}\\${match[1]}`;
|
104
|
-
}
|
105
|
-
|
106
|
-
return `\\${match}`;
|
107
|
-
}).replace(/(\r\n|\n|\r)/g, '')}"`;
|
108
|
-
|
109
|
-
if (i !== keys.length - 1) {
|
110
|
-
str += ',';
|
111
|
-
}
|
112
|
-
});
|
113
|
-
str += '}';
|
114
|
-
return str;
|
115
|
-
}
|
116
|
-
/**
|
117
|
-
* not useable due to special charector
|
118
|
-
*
|
119
|
-
return `{${Object.keys(data).map(key => `"${key}": "${data[key]}"`).join(",")}}`
|
120
|
-
// return JSON.stringify(data);
|
121
|
-
let str = "{";
|
122
|
-
for (const key of Object.keys(data)) {
|
123
|
-
str+= `"${key}": "${data[key]}",`
|
124
|
-
}
|
125
|
-
str+="}";
|
126
|
-
return str;
|
127
|
-
*/
|
package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|
@@ -1,63 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
9
|
-
|
10
|
-
var _JavascriptModulesPlugin = _interopRequireDefault(require("webpack/lib/javascript/JavascriptModulesPlugin"));
|
11
|
-
|
12
|
-
var _replaceCssDirTemplate = require("./replaceCssDirTemplate");
|
13
|
-
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
16
|
-
// const HtmlWebpackPlugin = require('html-webpack-plugin');
|
17
|
-
// import { JavascriptModulesPlugin } from 'webpack';
|
18
|
-
const pluginName = 'OverwriteCssPathForRTL';
|
19
|
-
|
20
|
-
class OverwriteCssPathForRTL {
|
21
|
-
constructor(options = {
|
22
|
-
dirVarName: 'document.dir'
|
23
|
-
}) {
|
24
|
-
this.dirVarName = options.dirVarName || 'document.dir';
|
25
|
-
this.templateLabel = options.templateLabel || '{{--dir}}';
|
26
|
-
}
|
27
|
-
|
28
|
-
overwriteCssPathinHTML(compilation) {
|
29
|
-
// NOTE: need to reconsider It is not working as expected
|
30
|
-
_htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tapAsync(pluginName, (data, cb) => {
|
31
|
-
const {
|
32
|
-
assets
|
33
|
-
} = data;
|
34
|
-
cb(null, { ...data,
|
35
|
-
assets: { ...assets,
|
36
|
-
css: assets.css && (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(assets.css, this.templateLabel)
|
37
|
-
}
|
38
|
-
});
|
39
|
-
});
|
40
|
-
}
|
41
|
-
|
42
|
-
overwriteCssPathinRequireEnsure(compilation, compiler) {
|
43
|
-
const {
|
44
|
-
RawSource
|
45
|
-
} = compiler.webpack.sources;
|
46
|
-
|
47
|
-
_JavascriptModulesPlugin.default.getCompilationHooks(compilation).renderMain.tap(pluginName, source => {
|
48
|
-
const templateText = `"+(${this.dirVarName} === "rtl" ? ".rtl": ".ltr")+"`;
|
49
|
-
const replacedStr = source.source().replace(/\[dir\]/g, templateText);
|
50
|
-
return new RawSource(replacedStr);
|
51
|
-
});
|
52
|
-
}
|
53
|
-
|
54
|
-
apply(compiler) {
|
55
|
-
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
56
|
-
this.overwriteCssPathinHTML(compilation);
|
57
|
-
this.overwriteCssPathinRequireEnsure(compilation, compiler);
|
58
|
-
});
|
59
|
-
}
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
exports.default = OverwriteCssPathForRTL;
|
@@ -1,89 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.RtlCssPlugin = void 0;
|
7
|
-
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
9
|
-
|
10
|
-
var _webpack = require("webpack");
|
11
|
-
|
12
|
-
var _OverwriteCssPathForRTL = _interopRequireDefault(require("./OverwriteCssPathForRTL"));
|
13
|
-
|
14
|
-
var _RTLSplitPlugin = require("../../custom_postcss_loaders/RTLSplitPlugin");
|
15
|
-
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
-
|
18
|
-
// import HtmlWebpackPlugin from 'html-webpack-plugin';
|
19
|
-
// import rtlcss from 'rtlcss';
|
20
|
-
const pluginName = 'RtlCssPlugin';
|
21
|
-
|
22
|
-
const isCss = filename => _path.default.extname(filename) === '.css';
|
23
|
-
|
24
|
-
const isDirRelatedCss = filename => filename.includes('[dir]');
|
25
|
-
|
26
|
-
class RtlCssPlugin {
|
27
|
-
constructor(options = {}) {
|
28
|
-
/**
|
29
|
-
* @typedef {Object} Options
|
30
|
-
* @property {String} dirVarName
|
31
|
-
* @property {Boolean} sourcemap
|
32
|
-
* @property {Object} config
|
33
|
-
*/
|
34
|
-
this.options = {
|
35
|
-
// dirVarName: options.dirVarName || 'document.dir',
|
36
|
-
sourcemap: options.sourcemap,
|
37
|
-
config: options.config
|
38
|
-
};
|
39
|
-
this.templateLabel = options.templateLabel || '{{--dir}}';
|
40
|
-
this.dirVarName = options.dirVarName || 'document.dir';
|
41
|
-
this.rtlSplitOptions = {
|
42
|
-
disableMinifySelector: options.disableMinifySelector
|
43
|
-
};
|
44
|
-
}
|
45
|
-
|
46
|
-
apply(compiler) {
|
47
|
-
const {
|
48
|
-
RawSource
|
49
|
-
} = compiler.webpack.sources;
|
50
|
-
new _OverwriteCssPathForRTL.default({
|
51
|
-
templateLabel: this.templateLabel,
|
52
|
-
dirVarName: this.dirVarName
|
53
|
-
}).apply(compiler); // const { filename, sourcemap, config } = this.options;
|
54
|
-
// const { devtool } = compiler.options;
|
55
|
-
// const postcssOptions = {
|
56
|
-
// map: (sourcemap === undefined && !!devtool) || !!sourcemap
|
57
|
-
// };
|
58
|
-
|
59
|
-
compiler.hooks.compilation.tap(pluginName, compilation => {
|
60
|
-
// compilation.hooks.shouldGenerateChunkAssets.tap(pluginName, (...args) => {
|
61
|
-
// console.log('shouldGenerateChunkAssets', args);
|
62
|
-
// });
|
63
|
-
compilation.hooks.processAssets.tap({
|
64
|
-
name: pluginName,
|
65
|
-
stage: _webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
|
66
|
-
additionalAssets: true
|
67
|
-
}, assets => {
|
68
|
-
Object.keys(assets).filter(isCss).filter(isDirRelatedCss).forEach(chunkFilename => {
|
69
|
-
const {
|
70
|
-
source: asset
|
71
|
-
} = compilation.getAsset(chunkFilename);
|
72
|
-
const sourceStr = asset.source();
|
73
|
-
const {
|
74
|
-
ltr,
|
75
|
-
rtl
|
76
|
-
} = (0, _RTLSplitPlugin.separateRtlAndLtr)(sourceStr, this.rtlSplitOptions);
|
77
|
-
const ltrFilename = chunkFilename.replace('[dir]', 'ltr');
|
78
|
-
const rtlFilename = chunkFilename.replace('[dir]', 'rtl');
|
79
|
-
compilation.deleteAsset(chunkFilename);
|
80
|
-
compilation.emitAsset(ltrFilename, new RawSource(ltr));
|
81
|
-
compilation.emitAsset(rtlFilename, new RawSource(rtl));
|
82
|
-
});
|
83
|
-
});
|
84
|
-
});
|
85
|
-
}
|
86
|
-
|
87
|
-
}
|
88
|
-
|
89
|
-
exports.RtlCssPlugin = RtlCssPlugin;
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# RTL Split
|
2
|
-
|
3
|
-
we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
|
4
|
-
It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
|
5
|
-
Here is problem mostly no one need rtl and ltr related css at the same time in browser,
|
6
|
-
we are try to split them by [dir] and load which type of css is needed.
|
7
|
-
For this purpose we created RTL Split Plugin
|
8
|
-
|
9
|
-
# To Try it out rtl-ltr split
|
10
|
-
|
11
|
-
### how to use this feature?
|
12
|
-
|
13
|
-
to use this feature use have give the below oprtions
|
14
|
-
`package.json`
|
15
|
-
|
16
|
-
```json
|
17
|
-
{
|
18
|
-
/// ...some things
|
19
|
-
"react-cli": {
|
20
|
-
// ...some things
|
21
|
-
"css": {
|
22
|
-
"plugins": {
|
23
|
-
"rtlSplit": {
|
24
|
-
"enableRTLSplit": true,
|
25
|
-
"templateLabel": "{{--dir}}", // this is for html template css file path dir template
|
26
|
-
"disableMinifySelector": false,
|
27
|
-
"dirVarName": "document.dir" // this will be used for download css based on dir
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
// ...some things
|
32
|
-
}
|
33
|
-
}
|
34
|
-
```
|
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.replaceCssDirTemplate = replaceCssDirTemplate;
|
7
|
-
exports.replaceCssDirTemplateMapper = replaceCssDirTemplateMapper;
|
8
|
-
|
9
|
-
function replaceCssDirTemplate(filePath, cssDirTemplate) {
|
10
|
-
return filePath.replace('[dir]', cssDirTemplate);
|
11
|
-
}
|
12
|
-
|
13
|
-
function replaceCssDirTemplateMapper(assets, cssDirTemplate) {
|
14
|
-
return assets.map(filePath => replaceCssDirTemplate(filePath, cssDirTemplate));
|
15
|
-
}
|