@zohodesk/react-cli 0.0.1-beta.166 → 0.0.1-beta.169
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/.prettierrc +6 -0
- package/README.md +83 -3
- package/bin/cli.js +10 -15
- package/cert/Tsicsezwild-22-23.crt +37 -0
- package/cert/Tsicsezwild-22-23.key +27 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/lib/configs/jest.config.js +6 -1
- package/lib/configs/webpack.dev.config.js +13 -17
- package/lib/configs/webpack.docs.config.js +35 -36
- package/lib/configs/webpack.impact.config.js +8 -14
- package/lib/configs/webpack.prod.config.js +8 -5
- package/lib/loaderUtils/configsAssetsLoaders.js +88 -0
- package/lib/loaderUtils/getCSSLoaders.js +5 -3
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +63 -54
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
- package/lib/postcss-plugins/__test__/test1Input.css +39 -0
- package/lib/postcss-plugins/__test__/test1Output.css +39 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +365 -0
- package/lib/schemas/index.js +31 -4
- package/lib/servers/{devBulid.js → devBuild.js} +7 -3
- package/lib/servers/getCliPath.js +7 -3
- package/lib/servers/httpsOptions.js +2 -3
- package/lib/servers/nowatchserver.js +2 -2
- package/lib/servers/server.js +11 -3
- package/lib/utils/repoClone.js +5 -2
- package/lib/utils/rtl.js +19 -2
- package/lib/utils/useExitCleanup.js +55 -0
- package/package.json +5 -1
- package/postpublish.js +6 -0
- package/cert/cert.pem +0 -37
- package/cert/key.pem +0 -27
- package/cert/passphrase.pem +0 -1
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.configAudioLoader = configAudioLoader;
|
7
|
+
exports.configFontLoader = configFontLoader;
|
8
|
+
exports.configImageLoader = configImageLoader;
|
9
|
+
exports.configSVGLoader = configSVGLoader;
|
10
|
+
exports.createNameTemplate = createNameTemplate;
|
11
|
+
// function getLoaderOptionQueryString(params) {
|
12
|
+
const ImageExtRegex = /\.jpe?g$|\.gif$|\.png$/;
|
13
|
+
const FontExtRegex = /\.woff2|\.woff$|\.ttf$|\.eot$/;
|
14
|
+
const SVGExtRegex = /\.svg$/;
|
15
|
+
const AudioExtRegex = /\.ogg$/;
|
16
|
+
|
17
|
+
function createLoaderOptionQueryString(loaderName, nameTemplate, limit = 1000) {
|
18
|
+
return `${loaderName}?limit=${limit}&name=${nameTemplate}`;
|
19
|
+
}
|
20
|
+
|
21
|
+
function configImageLoader(nameTemplate) {
|
22
|
+
return {
|
23
|
+
test: ImageExtRegex,
|
24
|
+
use: createLoaderOptionQueryString('url-loader', `./images/${nameTemplate}`)
|
25
|
+
};
|
26
|
+
}
|
27
|
+
|
28
|
+
function configFontLoader(nameTemplate) {
|
29
|
+
return {
|
30
|
+
test: FontExtRegex,
|
31
|
+
use: createLoaderOptionQueryString('url-loader', `./fonts/${nameTemplate}`)
|
32
|
+
};
|
33
|
+
}
|
34
|
+
|
35
|
+
function configSVGLoader(nameTemplate) {
|
36
|
+
return {
|
37
|
+
test: SVGExtRegex,
|
38
|
+
use: createLoaderOptionQueryString('url-loader', `./fonts/${nameTemplate}`, 1)
|
39
|
+
};
|
40
|
+
}
|
41
|
+
|
42
|
+
function configAudioLoader(nameTemplate) {
|
43
|
+
return {
|
44
|
+
test: AudioExtRegex,
|
45
|
+
use: createLoaderOptionQueryString('file-loader', `./fonts/${nameTemplate}`, 1)
|
46
|
+
};
|
47
|
+
}
|
48
|
+
|
49
|
+
function createNameTemplate(enableChunkHash) {
|
50
|
+
const ext = `${enableChunkHash ? '.[hash:20]' : ''}.[ext]`;
|
51
|
+
return `[name]${ext}`;
|
52
|
+
}
|
53
|
+
/*
|
54
|
+
export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
|
55
|
+
const nameTemplate = createNameTemplate(enableChunkHash);
|
56
|
+
return [
|
57
|
+
configImageLoader(nameTemplate),
|
58
|
+
configFontLoader(nameTemplate),
|
59
|
+
configSVGLoader(nameTemplate),
|
60
|
+
configAudioLoader(nameTemplate)
|
61
|
+
];
|
62
|
+
}
|
63
|
+
*/
|
64
|
+
|
65
|
+
/*
|
66
|
+
export function createLoaderOptionObject(
|
67
|
+
loaderName,
|
68
|
+
nameTemplate,
|
69
|
+
fallback,
|
70
|
+
limit = 1000
|
71
|
+
) {
|
72
|
+
return {
|
73
|
+
loader: loaderName,
|
74
|
+
options: {
|
75
|
+
limit,
|
76
|
+
name: nameTemplate,
|
77
|
+
fallback
|
78
|
+
}
|
79
|
+
};
|
80
|
+
}
|
81
|
+
|
82
|
+
function configLoaderObject(filter, loaderAndOptions) {
|
83
|
+
return {
|
84
|
+
test: filter,
|
85
|
+
use: loaderAndOptions
|
86
|
+
};
|
87
|
+
}
|
88
|
+
*/
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
16
16
|
let options = (0, _utils.getOptions)();
|
17
17
|
let isWin = process.platform === 'win32';
|
18
18
|
|
19
|
-
let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorReplace, cssHashSelectors, classNamePrefix) => {
|
19
|
+
let getCSSLoaders = (hasRTL, combinerMq, rtlExclude, hoverActive, classNameBlob, cssUniqueness, selectorReplace, cssHashSelectors, classNamePrefix) => {
|
20
20
|
const {
|
21
21
|
devCssFileBountry
|
22
22
|
} = options.app;
|
@@ -28,7 +28,8 @@ let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorR
|
|
28
28
|
} = options.impactService;
|
29
29
|
let rtlExcludeLocal = isWin ? rtlExclude.map(r => r.replace(/\//g, '\\')) : rtlExclude;
|
30
30
|
let cssLoaderOptions = {
|
31
|
-
importLoaders: hasRTL ? 1 : 0,
|
31
|
+
// importLoaders: hasRTL||hoverActive ? 1 : 0,
|
32
|
+
importLoaders: 1,
|
32
33
|
modules: {},
|
33
34
|
sourceMap: true
|
34
35
|
};
|
@@ -50,7 +51,8 @@ let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorR
|
|
50
51
|
return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
|
51
52
|
}
|
52
53
|
})]
|
53
|
-
})
|
54
|
+
}), // require('postcss-import')(),
|
55
|
+
combinerMq && require('postcss-combine-media-query')(), hoverActive && require('../postcss-plugins/hoverActivePlugin')()].filter(Boolean);
|
54
56
|
return [cssSelectorZipPath && {
|
55
57
|
loader: require.resolve('../loaders/selectorMappingLoader')
|
56
58
|
}, {
|
@@ -3,84 +3,93 @@
|
|
3
3
|
generaly we have manage our all I18n keys and values as language specific i18n files and then we download all i18n in initial page load.
|
4
4
|
|
5
5
|
### what is the problem with this?.
|
6
|
+
|
6
7
|
the problem is i18n file keep get's grown it will affect the the inital page load and critial rendering path.
|
7
8
|
So, We have decide to create a plugin for split i18n per chunk's of js vise.
|
8
9
|
|
9
10
|
### what is i18n split?
|
10
|
-
it is like code split for i18n.
|
11
|
-
we will collect i18n from js chunk and we will create separate i18n chunk per js chunk,
|
12
|
-
with this we already load Js chunks are on demand and now we also download i18n also ondemand with this the initial and forthere actions.
|
13
|
-
when js download's we will download i18n with it.
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
it is like code split for i18n.
|
13
|
+
we will collect i18n from js chunk and we will create separate i18n chunk per js chunk,
|
14
|
+
with this we already load Js chunks are on demand and now we also download i18n also ondemand with this the initial and forthere actions.
|
15
|
+
when js download's we will download i18n with it.
|
16
|
+
|
17
|
+
### How to we going to i18n split?
|
18
|
+
|
19
|
+
we will read the js chunk and collect I18n keys form it,
|
20
|
+
then we will create i18n chunk files with these used keys.
|
18
21
|
|
19
22
|
### how do you collect i18n keys from js files?
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
|
24
|
+
we will traverse the js file's AST (static analysis) and find i18 keys,
|
25
|
+
we will concider all string which is in jsResource file as i18n keys.
|
26
|
+
and you can tell dynamic i18n key by js comments,
|
27
|
+
Like Below:-
|
28
|
+
|
29
|
+
```js
|
30
|
+
fetch('tickets?view=view1').then(data => {
|
31
|
+
// I18n support.ticketsEmpty
|
32
|
+
// I18n support.viewNotFount
|
33
|
+
// I18n support.permissionDenied
|
34
|
+
let text = getI18nValue(data.i18nkey);
|
35
|
+
});
|
36
|
+
```
|
32
37
|
|
33
38
|
### is there any posiblity for unwanted keys in some chunk?
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
|
40
|
+
Yes, there is two posiblity
|
41
|
+
|
42
|
+
1. js comment , if you write js comment but it is not needed then it will be add into i18n chunk
|
43
|
+
`To Resolve` we currently do not have perfect idea for this, But we can check this by chunk size limit.
|
44
|
+
`idea's will be welcome`
|
45
|
+
2. like we said "we will concider all string which is in jsResource file as i18n keys",
|
46
|
+
So if you use string not for i18n but it was in jsResource then it will be add into i18n chunk.
|
47
|
+
`To Resolve` this problem we can use some kinda prefix or something.
|
41
48
|
|
42
49
|
### how do we downlowd and give to app?
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
50
|
+
|
51
|
+
we have over write defualt webpack requireEnsure (every dynamic chunk requests are done by that function) function.
|
52
|
+
and we parlarly dowload i18n files. and we ask jsonFunction, to our plugin.
|
53
|
+
So we send i18nkeys , when it was download,
|
54
|
+
you must store all i18n keys, we give asycrnsly by that function download in that patticular.
|
47
55
|
so you must store and update (like append or assign) everytime that function call.
|
48
56
|
|
49
57
|
### how to use this feature?
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
},
|
65
|
-
|
58
|
+
|
59
|
+
to use this feature use have give the below oprtions
|
60
|
+
`package.json`
|
61
|
+
|
62
|
+
```json
|
63
|
+
{
|
64
|
+
/// ...some things
|
65
|
+
"react-cli": {
|
66
|
+
// ...some things
|
67
|
+
"i18n": {
|
68
|
+
"chunkSplitEnable": true,
|
69
|
+
"jsResource": "./deskapp/properties/JSResources.properties",
|
70
|
+
"localeVarName": "window.userInfo.langCode",
|
71
|
+
"jsonpFunc": "window.loadI18nChunk",
|
72
|
+
"templateLabel": "{{--user-locale}}", // this is for html template i18n file path locate template
|
73
|
+
"propertiesFolder": "./deskapp/properties"
|
66
74
|
}
|
75
|
+
// ...some things
|
67
76
|
}
|
68
|
-
|
69
|
-
|
77
|
+
}
|
78
|
+
```
|
70
79
|
|
71
80
|
<!-- not need below -->
|
72
|
-
<!--
|
81
|
+
<!--we have added new feature for css to write logic to how hover related css work in hoverhover and a
|
73
82
|
|
74
83
|
### is there any problems with static analysis?
|
75
|
-
Yes,
|
84
|
+
Yes,
|
76
85
|
|
77
86
|
### how do we use dynamic i18n key?
|
78
87
|
|
79
|
-
and we will download i18n file with
|
88
|
+
and we will download i18n file with
|
80
89
|
|
81
90
|
and when js chunk download's then we will download i18n as need.
|
82
91
|
we all know in our app we loading i18n as one single big file for each locale(language).
|
83
|
-
we are going to split i18n as per js chunk, and when js chunk download's then we will download i18n as need.
|
84
|
-
|
85
|
-
|
92
|
+
we are going to split i18n as per js chunk, and when js chunk download's then we will download i18n as need.
|
93
|
+
|
94
|
+
|
86
95
|
-->
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const fs = require('fs');
|
4
|
+
|
5
|
+
const postcss = require('postcss');
|
6
|
+
|
7
|
+
function expectRunPostCss(inputFile, outputfile, cb) {
|
8
|
+
const inputStr = fs.readFileSync(inputFile, 'utf-8');
|
9
|
+
postcss(plugins).process(inputStr, {
|
10
|
+
from,
|
11
|
+
to
|
12
|
+
}).then(result => {
|
13
|
+
expect(result.css).toBe(fs.readFileSync(outputfile, 'utf-8'));
|
14
|
+
cb();
|
15
|
+
});
|
16
|
+
}
|
17
|
+
|
18
|
+
describe('To Check Hover active postcss Plugin ', () => {
|
19
|
+
test('should handle normal rule hover', cb => {
|
20
|
+
expectRunPostCss('test1Input.css', 'test1Output.css', cb);
|
21
|
+
});
|
22
|
+
});
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/*Hover_active:ignore*/
|
2
|
+
g,a:hover{
|
3
|
+
color : red
|
4
|
+
}
|
5
|
+
/*Hover:ignore*/
|
6
|
+
h:hover{
|
7
|
+
background : yellow
|
8
|
+
}
|
9
|
+
|
10
|
+
/* Hover_active:ignore */
|
11
|
+
g,d+e:hover{
|
12
|
+
color : black
|
13
|
+
}
|
14
|
+
|
15
|
+
g,d e:hover{
|
16
|
+
color : black
|
17
|
+
}
|
18
|
+
|
19
|
+
@media screen and (max-width:61.25em){
|
20
|
+
/* Hover_active:ignore */
|
21
|
+
a,b,a:hover, b:hover{
|
22
|
+
background-color : blue
|
23
|
+
}
|
24
|
+
a + b,a:hover + b:hover{
|
25
|
+
background-color : blue
|
26
|
+
}
|
27
|
+
a b:hover{
|
28
|
+
background-color : blue
|
29
|
+
}
|
30
|
+
|
31
|
+
.cc:hover {
|
32
|
+
color: red;
|
33
|
+
}
|
34
|
+
|
35
|
+
c:hover{
|
36
|
+
color : red
|
37
|
+
}
|
38
|
+
|
39
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/*Hover_active:ignore*/
|
2
|
+
g,a:hover{
|
3
|
+
color : red
|
4
|
+
}
|
5
|
+
/*Hover:ignore*/
|
6
|
+
h:hover{
|
7
|
+
background : yellow
|
8
|
+
}
|
9
|
+
|
10
|
+
/* Hover_active:ignore */
|
11
|
+
g,d+e:hover{
|
12
|
+
color : black
|
13
|
+
}
|
14
|
+
|
15
|
+
g,d e:hover{
|
16
|
+
color : black
|
17
|
+
}
|
18
|
+
|
19
|
+
@media screen and (max-width:61.25em){
|
20
|
+
/* Hover_active:ignore */
|
21
|
+
a,b,a:hover, b:hover{
|
22
|
+
background-color : blue
|
23
|
+
}
|
24
|
+
a + b,a:hover + b:hover{
|
25
|
+
background-color : blue
|
26
|
+
}
|
27
|
+
a b:hover{
|
28
|
+
background-color : blue
|
29
|
+
}
|
30
|
+
|
31
|
+
.cc:hover {
|
32
|
+
color: red;
|
33
|
+
}
|
34
|
+
|
35
|
+
c:hover{
|
36
|
+
color : red
|
37
|
+
}
|
38
|
+
|
39
|
+
}
|