@zohodesk/react-cli 1.1.6-exp.2 → 1.1.7
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 +5 -11
- package/docs/CustomChunks.md +6 -6
- package/docs/MarkdownParser.md +18 -0
- package/lib/common/splitChunks.js +45 -71
- package/lib/common/testPattern.js +9 -9
- package/lib/loaders/__test__/markdownLoader.spec.js +145 -0
- package/lib/loaders/docsLoader.js +3 -0
- package/lib/loaders/markdownLoader.js +71 -0
- package/lib/plugins/ResourceHintsPlugin.js +3 -5
- package/lib/schemas/index.js +4 -1
- package/lib/utils/getOptions.js +7 -25
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- package/templates/docs/all.html +1 -0
- package/templates/docs/component.html +1 -0
- package/templates/docs/components.html +1 -0
- package/templates/docs/css/markdown.css +202 -0
- package/templates/docs/index.html +1 -0
package/README.md
CHANGED
@@ -44,19 +44,13 @@ Now to run app
|
|
44
44
|
|
45
45
|
# Change Logs
|
46
46
|
|
47
|
-
# 1.1.
|
48
|
-
- fixed file path separator issue with split chunks config for vendor exclude list.
|
49
|
-
- added support for not doing enforce true for chunks on splitchunks config.
|
47
|
+
# 1.1.7
|
50
48
|
|
51
|
-
|
52
|
-
-
|
49
|
+
**Feature**
|
50
|
+
- Markdown parser feature added in docs
|
51
|
+
For more info please refer to :
|
52
|
+
[details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/2.0.0/docs/MarkdownParser.md)
|
53
53
|
|
54
|
-
# 1.1.5-exp.4
|
55
|
-
- added support for using regex expression to get group of chunks chunkId via Resource Hint plugin prefetch/preload hook.
|
56
|
-
|
57
|
-
# 1.1.5-exp.3
|
58
|
-
- added options to split chunks base config
|
59
|
-
- added support for passing custom chunks split logic as function.
|
60
54
|
# 1.1.6
|
61
55
|
|
62
56
|
**Issue Fix**
|
package/docs/CustomChunks.md
CHANGED
@@ -4,17 +4,17 @@ In react-cli we provide options to create custom chunks.
|
|
4
4
|
This Custom Chunk Option is array of Object
|
5
5
|
that Object keys are
|
6
6
|
|
7
|
-
- `pattern`
|
8
|
-
- `name`
|
9
|
-
- `size`
|
7
|
+
- `pattern` regex pattern as string
|
8
|
+
- `name` chunk name
|
9
|
+
- `size` is count which is minmum chunk dublicated or need in chunks
|
10
10
|
|
11
11
|
> Since 0.0.1-exp.164.1
|
12
12
|
|
13
13
|
extra features in custom chunks :-
|
14
14
|
for more details [SplitChunkPlugin](https://webpack.js.org/plugins/split-chunks-plugin/) webpack
|
15
15
|
|
16
|
-
- `minChunks`: `minChunks` is
|
17
|
-
- `rules`: `rules` is same as `pattern` with some easy hooks
|
16
|
+
- `minChunks`: `minChunks` is alies of `size` default value is `2`,
|
17
|
+
- `rules`: `rules` is same as `pattern` with some easy hooks
|
18
18
|
- use `/` for both windows and linux we will replace internally
|
19
19
|
- for `.*` we need to use `*`
|
20
20
|
- we can consider rules as regex when the `rules-string` has any of these `*`, `^`, `$`. So if you want regex then kindly use `*` in your `rules-string` for force regex
|
@@ -23,4 +23,4 @@ for more details [SplitChunkPlugin](https://webpack.js.org/plugins/split-chunks-
|
|
23
23
|
- `enforce`: enforce default value is true,
|
24
24
|
- `maxSize`: maxSize, default value is 0,
|
25
25
|
- `minSize`: minSize, default value is 20000,
|
26
|
-
|
26
|
+
includeDepenency: includeDepenency default value is false
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
----> markdownParser <----
|
3
|
+
|
4
|
+
1. Markdown parser allows us to write Documentation using Markdown language inside the Javascript file
|
5
|
+
2. This will converts the snippets to HTML tag.
|
6
|
+
3. We can implement this only inside the particular syntax which is metioned below.
|
7
|
+
4. We can enable/disable this feature by `npm run docs --markdown_parser=true/false` default value will be `true`.
|
8
|
+
5. Also we can enable/disable this feature by adding `enableMDParser` key inside the package.json under the `docs`.
|
9
|
+
|
10
|
+
### syntax
|
11
|
+
```
|
12
|
+
/* MD:START
|
13
|
+
# Hello World
|
14
|
+
MD:END */
|
15
|
+
```
|
16
|
+
|
17
|
+
# v1.1.7 update:
|
18
|
+
* Markdown Parser feature implemented.
|
@@ -15,52 +15,35 @@ var _testPattern = require("./testPattern");
|
|
15
15
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
let isWindows = _os.default.platform().toLowerCase() === 'win32';
|
19
|
+
let ps = _path.default.sep;
|
20
|
+
let options = (0, _utils.getOptions)();
|
21
|
+
let {
|
22
22
|
app: {
|
23
23
|
vendorExclude,
|
24
24
|
customChunks,
|
25
|
-
vendorInclude
|
26
|
-
customChunksBaseConfig
|
25
|
+
vendorInclude
|
27
26
|
}
|
28
27
|
} = options;
|
29
|
-
const reactBundleIncludeList = ['react', 'react-dom', 'react-redux', 'react-transition-group', 'scheduler', 'prop-types'];
|
30
|
-
const vendorExcludelist = ['script-loader', 'raw-loader', ...reactBundleIncludeList, ...vendorExclude.map(vendorPath => vendorPath.replace(/[/\\]/g, _path.default.sep))];
|
31
28
|
|
32
|
-
|
33
|
-
|
29
|
+
let isVendor = function isVendor(module) {
|
30
|
+
let {
|
34
31
|
userRequest
|
35
32
|
} = module;
|
36
|
-
|
33
|
+
let excludeList = ['script-loader', 'raw-loader', 'react', 'react-dom'];
|
34
|
+
excludeList = [...excludeList, ...vendorExclude];
|
35
|
+
return userRequest && (vendorInclude.some(item => userRequest.indexOf(item) !== -1) || userRequest.indexOf('node_modules') >= 0 && userRequest.endsWith('.css') === false && userRequest.endsWith('publicPathConfig.js') === false && excludeList.every(item => userRequest.indexOf(`node_modules${ps}${item}${ps}`) === -1));
|
37
36
|
};
|
38
37
|
|
39
|
-
|
40
|
-
|
38
|
+
let isReact = module => {
|
39
|
+
let {
|
41
40
|
userRequest
|
42
41
|
} = module;
|
43
|
-
|
42
|
+
let reactBundle = ['react', 'react-dom'];
|
43
|
+
return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
|
44
44
|
};
|
45
45
|
|
46
|
-
|
47
|
-
if (typeof pattern === 'function') {
|
48
|
-
return pattern;
|
49
|
-
}
|
50
|
-
|
51
|
-
if (Array.isArray(pattern)) {
|
52
|
-
return ({
|
53
|
-
userRequest
|
54
|
-
}) => (0, _testPattern.testPattern)(userRequest, pattern);
|
55
|
-
}
|
56
|
-
|
57
|
-
return new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern);
|
58
|
-
}
|
59
|
-
|
60
|
-
const baseSplitChunkConfig = Object.assign({
|
61
|
-
minSize: 15000
|
62
|
-
}, customChunksBaseConfig);
|
63
|
-
const specificCacheGroupConfig = {
|
46
|
+
let defaultChunks = {
|
64
47
|
'react.vendor': {
|
65
48
|
name: 'react.vendor',
|
66
49
|
chunks: 'all',
|
@@ -80,37 +63,45 @@ const specificCacheGroupConfig = {
|
|
80
63
|
priority: -10
|
81
64
|
}
|
82
65
|
};
|
83
|
-
|
66
|
+
let customChunksConfig = {};
|
84
67
|
customChunks.map((obj, index) => ({
|
85
68
|
name: obj.name,
|
86
|
-
chunks: obj.chunks || 'all',
|
87
|
-
minChunks: obj.minChunks || obj.size || 2,
|
88
69
|
pattern: obj.pattern,
|
70
|
+
minChunks: obj.minChunks || obj.size || 2,
|
71
|
+
rules: obj.rules,
|
72
|
+
// includeDepenency: obj.includeDepenency || false,
|
89
73
|
priority: obj.priority || -10 * (index + 2),
|
90
|
-
enforce: obj.enforce,
|
91
|
-
minSize: obj.minSize,
|
92
|
-
// || 20000,
|
74
|
+
enforce: obj.enforce || true,
|
93
75
|
maxSize: obj.maxSize,
|
94
76
|
// || 0,
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
})).
|
77
|
+
minSize: obj.minSize,
|
78
|
+
// || 20000,
|
79
|
+
chunks: obj.chunks || 'all'
|
80
|
+
})).map(({
|
99
81
|
name,
|
100
|
-
chunks = 'all',
|
101
|
-
minChunks,
|
102
82
|
pattern,
|
83
|
+
minChunks,
|
84
|
+
rules,
|
103
85
|
priority,
|
86
|
+
// includeDepenency,
|
104
87
|
enforce,
|
105
88
|
minSize,
|
106
89
|
maxSize,
|
107
|
-
|
108
|
-
automaticNamePrefix,
|
109
|
-
cacheGroupName
|
90
|
+
chunks = 'all'
|
110
91
|
}) => {
|
111
|
-
|
112
|
-
|
92
|
+
let obj = {
|
93
|
+
name,
|
94
|
+
test: rules ? m => {
|
95
|
+
const {
|
96
|
+
userRequest
|
97
|
+
} = m;
|
98
|
+
return (0, _testPattern.testPattern)(userRequest, rules); // return (
|
99
|
+
// pkgs.some(p => isRelated(userRequest, p)) ||
|
100
|
+
// (includeDepenency && isDependency(m, pkgs))
|
101
|
+
// );
|
102
|
+
} : new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern),
|
113
103
|
chunks,
|
104
|
+
enforce,
|
114
105
|
minChunks,
|
115
106
|
priority
|
116
107
|
};
|
@@ -123,30 +114,13 @@ customChunks.map((obj, index) => ({
|
|
123
114
|
obj.maxSize = maxSize;
|
124
115
|
}
|
125
116
|
|
126
|
-
|
127
|
-
obj.enforce = true;
|
128
|
-
}
|
129
|
-
|
130
|
-
if (name !== undefined) {
|
131
|
-
obj.name = name;
|
132
|
-
}
|
133
|
-
|
134
|
-
if (reuseExistingChunk !== undefined) {
|
135
|
-
obj.reuseExistingChunk = reuseExistingChunk;
|
136
|
-
}
|
137
|
-
|
138
|
-
if (automaticNamePrefix) {
|
139
|
-
obj.automaticNamePrefix = automaticNamePrefix;
|
140
|
-
}
|
141
|
-
|
142
|
-
customChunksConfig[cacheGroupName] = obj;
|
117
|
+
return customChunksConfig[name] = obj;
|
143
118
|
});
|
144
|
-
|
119
|
+
var _default = {
|
120
|
+
minSize: 12000,
|
145
121
|
cacheGroups: Object.assign({
|
146
122
|
default: false,
|
147
123
|
vendors: false
|
148
|
-
},
|
149
|
-
}
|
150
|
-
console.log('split chunks', splitChunkConfig);
|
151
|
-
var _default = splitChunkConfig;
|
124
|
+
}, defaultChunks, customChunksConfig)
|
125
|
+
};
|
152
126
|
exports.default = _default;
|
@@ -13,25 +13,25 @@ var _path = require("path");
|
|
13
13
|
const isWindows = _path.sep !== '/'; // this function will return true if pattern matched
|
14
14
|
|
15
15
|
function _testPattern(req, pattern) {
|
16
|
-
let
|
16
|
+
let modifyedPattern = pattern;
|
17
17
|
|
18
|
-
if (/[*.$^]/.test(
|
18
|
+
if (/[*.$^]/.test(modifyedPattern)) {
|
19
19
|
if (isWindows) {
|
20
|
-
//
|
21
|
-
|
20
|
+
// modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
|
21
|
+
modifyedPattern = modifyedPattern.replace(/\//g, '\\\\');
|
22
22
|
}
|
23
23
|
|
24
|
-
|
25
|
-
const re = new RegExp(
|
24
|
+
modifyedPattern = modifyedPattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
|
25
|
+
const re = new RegExp(modifyedPattern);
|
26
26
|
return re.test(req);
|
27
27
|
}
|
28
28
|
|
29
29
|
if (isWindows) {
|
30
|
-
//
|
31
|
-
|
30
|
+
// modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
|
31
|
+
modifyedPattern = modifyedPattern.replace(/\//g, '\\');
|
32
32
|
}
|
33
33
|
|
34
|
-
return req.indexOf(
|
34
|
+
return req.indexOf(modifyedPattern) !== -1;
|
35
35
|
}
|
36
36
|
|
37
37
|
function testPattern(req, pattern) {
|
@@ -0,0 +1,145 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const {
|
4
|
+
markdownParser
|
5
|
+
} = require('../markdownLoader'); // Replace './your-file' with the correct file path
|
6
|
+
|
7
|
+
|
8
|
+
describe('markdownParser', () => {
|
9
|
+
test('For {}(braces) case', () => {
|
10
|
+
const source = `
|
11
|
+
/* MD:START
|
12
|
+
# {Hi, This is Test Case :)}
|
13
|
+
MD:END */
|
14
|
+
`;
|
15
|
+
const expectedOutput = `
|
16
|
+
<><div class="markDown"><h1>{Hi, This is Test Case :)}</h1>
|
17
|
+
</div></>
|
18
|
+
`;
|
19
|
+
expect(markdownParser(source)).toEqual(expectedOutput);
|
20
|
+
});
|
21
|
+
test('For $ (dollor) case', () => {
|
22
|
+
const source = `
|
23
|
+
/* MD:START
|
24
|
+
# $Hi, This is Test Case :)
|
25
|
+
MD:END */
|
26
|
+
`;
|
27
|
+
const expectedOutput = `
|
28
|
+
<><div class="markDown"><h1>$Hi, This is Test Case :)</h1>
|
29
|
+
</div></>
|
30
|
+
`;
|
31
|
+
expect(markdownParser(source)).toEqual(expectedOutput);
|
32
|
+
});
|
33
|
+
test('For All kind of Tag Cases', () => {
|
34
|
+
const source = `
|
35
|
+
/* MD:START
|
36
|
+
# Markdown File with Variety of Data
|
37
|
+
|
38
|
+
## Text
|
39
|
+
|
40
|
+
This is a paragraph of text.
|
41
|
+
|
42
|
+
## Headings
|
43
|
+
|
44
|
+
### Heading 1
|
45
|
+
|
46
|
+
### Heading 2
|
47
|
+
|
48
|
+
#### Heading 2.1
|
49
|
+
|
50
|
+
#### Heading 2.2
|
51
|
+
|
52
|
+
## Lists
|
53
|
+
|
54
|
+
### Unordered List
|
55
|
+
|
56
|
+
- Item 1
|
57
|
+
- Item 2
|
58
|
+
- Item 3
|
59
|
+
|
60
|
+
### Ordered List
|
61
|
+
|
62
|
+
1. First item
|
63
|
+
2. Second item
|
64
|
+
3. Third item
|
65
|
+
|
66
|
+
## Links
|
67
|
+
|
68
|
+
Here's a link to [OpenAI's website](https://openai.com).
|
69
|
+
|
70
|
+
## Images
|
71
|
+
|
72
|
+

|
73
|
+
|
74
|
+
## Tables
|
75
|
+
|
76
|
+
| Name | Age | Gender |
|
77
|
+
|-------|-----|--------|
|
78
|
+
| John | 25 | Male |
|
79
|
+
| Sarah | 30 | Female |
|
80
|
+
| Mark | 35 | Male |
|
81
|
+
|
82
|
+
MD:END */
|
83
|
+
`;
|
84
|
+
const expectedOutput = `
|
85
|
+
<><div class="markDown"><h1>Markdown File with Variety of Data</h1>
|
86
|
+
<h2>Text</h2>
|
87
|
+
<p>This is a paragraph of text.</p>
|
88
|
+
<h2>Headings</h2>
|
89
|
+
<h3>Heading 1</h3>
|
90
|
+
<h3>Heading 2</h3>
|
91
|
+
<h4>Heading 2.1</h4>
|
92
|
+
<h4>Heading 2.2</h4>
|
93
|
+
<h2>Lists</h2>
|
94
|
+
<h3>Unordered List</h3>
|
95
|
+
<ul>
|
96
|
+
<li>Item 1</li>
|
97
|
+
<li>Item 2</li>
|
98
|
+
<li>Item 3</li>
|
99
|
+
</ul>
|
100
|
+
<h3>Ordered List</h3>
|
101
|
+
<ol>
|
102
|
+
<li>First item</li>
|
103
|
+
<li>Second item</li>
|
104
|
+
<li>Third item</li>
|
105
|
+
</ol>
|
106
|
+
<h2>Links</h2>
|
107
|
+
<p>Here's a link to <a href="https://openai.com">OpenAI's website</a>.</p>
|
108
|
+
<h2>Images</h2>
|
109
|
+
<p><img src="https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg" alt="Markdown Logo"/></p>
|
110
|
+
<h2>Tables</h2>
|
111
|
+
<table>
|
112
|
+
<thead>
|
113
|
+
<tr>
|
114
|
+
<th>Name</th>
|
115
|
+
<th>Age</th>
|
116
|
+
<th>Gender</th>
|
117
|
+
</tr>
|
118
|
+
</thead>
|
119
|
+
<tbody>
|
120
|
+
<tr>
|
121
|
+
<td>John</td>
|
122
|
+
<td>25</td>
|
123
|
+
<td>Male</td>
|
124
|
+
</tr>
|
125
|
+
<tr>
|
126
|
+
<td>Sarah</td>
|
127
|
+
<td>30</td>
|
128
|
+
<td>Female</td>
|
129
|
+
</tr>
|
130
|
+
<tr>
|
131
|
+
<td>Mark</td>
|
132
|
+
<td>35</td>
|
133
|
+
<td>Male</td>
|
134
|
+
</tr>
|
135
|
+
</tbody>
|
136
|
+
</table>
|
137
|
+
</div></>
|
138
|
+
`;
|
139
|
+
expect(markdownParser(source)).toEqual(expectedOutput);
|
140
|
+
});
|
141
|
+
test('For Source null case', () => {
|
142
|
+
expect(markdownParser(null)).toEqual('');
|
143
|
+
expect(markdownParser('')).toEqual('');
|
144
|
+
});
|
145
|
+
});
|
@@ -8,6 +8,8 @@ var _path = _interopRequireDefault(require("path"));
|
|
8
8
|
|
9
9
|
var _reactLiveConvertor = require("./reactLiveConvertor");
|
10
10
|
|
11
|
+
var _markdownLoader = require("./markdownLoader.js");
|
12
|
+
|
11
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
14
|
|
13
15
|
module.exports = function (source) {
|
@@ -24,6 +26,7 @@ module.exports = function (source) {
|
|
24
26
|
|
25
27
|
const src = _fs.default.readFileSync(originalFilePath).toString();
|
26
28
|
|
29
|
+
options.docs.enableMDParser && (source = (0, _markdownLoader.markdownParser)(source));
|
27
30
|
options.docs.enableReactLive && (source = (0, _reactLiveConvertor.reactLiveConvertor)(source, originalFilePath)); //to Enable the ReactLive Converter
|
28
31
|
|
29
32
|
return `${source};${name}.source=${JSON.stringify(src)};${name}.filePath=${JSON.stringify(filePath)}`;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.markdownParser = markdownParser;
|
7
|
+
|
8
|
+
const markdownIt = require('markdown-it'); // const md = new markdownIt({ linkify: true,breaks:true });
|
9
|
+
|
10
|
+
|
11
|
+
const md = new markdownIt({
|
12
|
+
html: false,
|
13
|
+
linkify: true,
|
14
|
+
typographer: true,
|
15
|
+
breaks: true,
|
16
|
+
xhtmlOut: true
|
17
|
+
}); //const md = new markdownIt();
|
18
|
+
|
19
|
+
function markdownParser(source) {
|
20
|
+
if (!source) {
|
21
|
+
return '';
|
22
|
+
}
|
23
|
+
|
24
|
+
const startTag = '/* MD:START';
|
25
|
+
const endTag = 'MD:END */'; // Iterate through all occurrences of the tags
|
26
|
+
|
27
|
+
let startIndex = source.indexOf(startTag);
|
28
|
+
|
29
|
+
while (startIndex !== -1) {
|
30
|
+
const endIndex = source.indexOf(endTag, startIndex);
|
31
|
+
|
32
|
+
if (endIndex !== -1) {
|
33
|
+
const extractedMarkdown = source.slice(startIndex + startTag.length, endIndex);
|
34
|
+
let lines = extractedMarkdown.split('\n');
|
35
|
+
lines = lines.filter(line => line.trim() !== '');
|
36
|
+
const firstLineIndentMatch = lines[0].match(/^\s+/);
|
37
|
+
const firstLineIndent = firstLineIndentMatch ? firstLineIndentMatch[0] : '';
|
38
|
+
const modifiedStr = lines.map(line => line.replace(new RegExp(`^${firstLineIndent}`), '')).join('\n').replace(/(:--)|(--:)/g, '---');
|
39
|
+
let html = md.render(modifiedStr); //html = html.replace(/"|<hr>|<img src=(".*?")>|<br>|:--|--:|{|}|\$/g, match => {
|
40
|
+
|
41
|
+
html = html.replace(/"|{|}|\$/g, match => {
|
42
|
+
// if (match === '<hr>') {
|
43
|
+
// return '<hr/>';
|
44
|
+
// } else if (match.startsWith('<img src=')) {
|
45
|
+
// return match.replace('>', '/>');
|
46
|
+
// } else if (match === '<br>') {
|
47
|
+
// return '<br/>';
|
48
|
+
if (match === '$') {
|
49
|
+
return '$';
|
50
|
+
} else if (match === '{') {
|
51
|
+
return '{';
|
52
|
+
} else if (match === '}') {
|
53
|
+
return '}';
|
54
|
+
} // else if (match === ':--' || match === '--:' ) {
|
55
|
+
// return '---';
|
56
|
+
// }
|
57
|
+
else if (match === '}') {
|
58
|
+
return '}';
|
59
|
+
}
|
60
|
+
|
61
|
+
return match;
|
62
|
+
}); // console.log(html,"html");
|
63
|
+
|
64
|
+
source = source.replace(source.slice(startIndex, endIndex + endTag.length), '<><div class="markDown">' + html + '</div></>');
|
65
|
+
}
|
66
|
+
|
67
|
+
startIndex = source.indexOf(startTag, startIndex + 1); // console.log(source)
|
68
|
+
}
|
69
|
+
|
70
|
+
return source;
|
71
|
+
}
|
@@ -19,7 +19,7 @@ class ResourceHintsPlugin {
|
|
19
19
|
mainTemplate.hooks.requireExtensions.tap(pluginName, (source, chunk, hash) => {
|
20
20
|
const idNameMap = chunk.getChunkMaps().name;
|
21
21
|
const nameIdMap = {};
|
22
|
-
let needsMap =
|
22
|
+
let needsMap = false;
|
23
23
|
|
24
24
|
for (const key in idNameMap) {
|
25
25
|
if (Object.prototype.hasOwnProperty.call(idNameMap, key)) {
|
@@ -32,9 +32,7 @@ class ResourceHintsPlugin {
|
|
32
32
|
}
|
33
33
|
}
|
34
34
|
|
35
|
-
return Template.asString([source, '', `${mainTemplate.requireFn}.
|
36
|
-
${mainTemplate.requireFn}.e(idOfAChunk);
|
37
|
-
})`]), '};',
|
35
|
+
return Template.asString([source, '', `${mainTemplate.requireFn}.getChunkId = function getChunkId(chunkId) {`, Template.indent((needsMap ? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`] : []).concat(['return chunkId;'])), '}', `// Prefetch a chunk (${pluginName})`, `${mainTemplate.requireFn}.pfc = function prefetchChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, `${mainTemplate.requireFn}.e(chunkId);`]), '};',
|
38
36
|
/*
|
39
37
|
(needsMap
|
40
38
|
? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`]
|
@@ -55,7 +53,7 @@ class ResourceHintsPlugin {
|
|
55
53
|
),
|
56
54
|
'}',
|
57
55
|
*/
|
58
|
-
`// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.
|
56
|
+
`// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, 'if(installedChunks[chunkId] === undefined) {', Template.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'document.head.appendChild(link);', `${mainTemplate.requireFn}.e(chunkId);` // 'var head = document.getElementsByTagName(\'head\')[0];',
|
59
57
|
// mainTemplate.hooks.jsonpScript.call('', chunk, hash),
|
60
58
|
// 'head.appendChild(script);'
|
61
59
|
]), '}']), '};']);
|
package/lib/schemas/index.js
CHANGED
@@ -333,7 +333,6 @@ var _default = {
|
|
333
333
|
inject: true
|
334
334
|
},
|
335
335
|
removePropTypes: false,
|
336
|
-
customChunksBaseConfig: null,
|
337
336
|
customChunks: [{
|
338
337
|
name: 'styles',
|
339
338
|
pattern: '\\.css$'
|
@@ -383,6 +382,10 @@ var _default = {
|
|
383
382
|
value: true,
|
384
383
|
cli: 'react_live'
|
385
384
|
},
|
385
|
+
enableMDParser: {
|
386
|
+
value: true,
|
387
|
+
cli: 'markdown_parser'
|
388
|
+
},
|
386
389
|
rtlExclude: [],
|
387
390
|
selectorReplace: null,
|
388
391
|
plugins: {
|
package/lib/utils/getOptions.js
CHANGED
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
7
7
|
|
8
8
|
var _child_process = require("child_process");
|
9
9
|
|
10
|
-
var _fs =
|
10
|
+
var _fs = _interopRequireDefault(require("fs"));
|
11
11
|
|
12
12
|
var _path = _interopRequireDefault(require("path"));
|
13
13
|
|
@@ -15,10 +15,6 @@ var _schemas = _interopRequireDefault(require("../schemas"));
|
|
15
15
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
17
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
19
|
-
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
21
|
-
|
22
18
|
// import { argv } from 'process';
|
23
19
|
const args = process.argv.slice(2); // console.log('argv', argv);
|
24
20
|
|
@@ -187,9 +183,8 @@ function deprecationSupport(options) {
|
|
187
183
|
Object.keys(options.app.patterns).forEach(key => {
|
188
184
|
if (options.app.exclude[key] && options.app.patterns[key].length === 0) {
|
189
185
|
let tempArr = options.app.exclude[key];
|
190
|
-
tempArr = tempArr.map(
|
191
|
-
|
192
|
-
|
186
|
+
tempArr = tempArr.map(x => {
|
187
|
+
x = x.replace(/\//gi, _path.default.sep);
|
193
188
|
return `!**${x[0] === _path.default.sep || x[0] === '@' ? '' : _path.default.sep}${x}${x[x.length - 1] === _path.default.sep ? '' : _path.default.sep}**`;
|
194
189
|
});
|
195
190
|
options.app.patterns[key] = tempArr;
|
@@ -198,9 +193,8 @@ function deprecationSupport(options) {
|
|
198
193
|
Object.keys(options.docs.patterns).forEach(key => {
|
199
194
|
if (options.docs.exclude[key] && options.docs.patterns[key].length === 0) {
|
200
195
|
let tempArr = options.docs.exclude[key];
|
201
|
-
tempArr = tempArr.map(
|
202
|
-
|
203
|
-
|
196
|
+
tempArr = tempArr.map(x => {
|
197
|
+
x = x.replace(/\//gi, _path.default.sep);
|
204
198
|
return `!**${x[0] === _path.default.sep || x[0] === '@' ? '' : _path.default.sep}${x}${x[x.length - 1] === _path.default.sep ? '' : _path.default.sep}**`;
|
205
199
|
});
|
206
200
|
options.docs.patterns[key] = tempArr;
|
@@ -208,30 +202,18 @@ function deprecationSupport(options) {
|
|
208
202
|
});
|
209
203
|
}
|
210
204
|
|
211
|
-
const getOptionsFromConfigFile = (appPath, configFileName) => {
|
212
|
-
const fileName = configFileName || 'build.config.js';
|
213
|
-
|
214
|
-
const packagePath = _path.default.join(appPath, fileName);
|
215
|
-
|
216
|
-
if ((0, _fs.existsSync)(packagePath)) {
|
217
|
-
return require(packagePath).config;
|
218
|
-
}
|
219
|
-
|
220
|
-
return null;
|
221
|
-
};
|
222
|
-
|
223
205
|
const getOptions = () => {
|
224
206
|
if (global.reactCLIOptions) {
|
225
207
|
return global.reactCLIOptions;
|
226
208
|
}
|
227
209
|
|
228
210
|
const appPath = process.cwd();
|
229
|
-
let userSchemas
|
211
|
+
let userSchemas;
|
230
212
|
|
231
213
|
const packagePath = _path.default.join(appPath, 'package.json');
|
232
214
|
|
233
215
|
if (_fs.default.existsSync(packagePath)) {
|
234
|
-
userSchemas =
|
216
|
+
userSchemas = require(packagePath)['react-cli'] || {};
|
235
217
|
}
|
236
218
|
|
237
219
|
const options = defaulter(_schemas.default, userSchemas || {}); // for future may be for npm 8 edge cases
|
package/npm-shrinkwrap.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zohodesk/react-cli",
|
3
|
-
"version": "1.1.6
|
3
|
+
"version": "1.1.6",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "@zohodesk/react-cli",
|
9
|
-
"version": "1.1.6
|
9
|
+
"version": "1.1.6",
|
10
10
|
"license": "ISC",
|
11
11
|
"dependencies": {
|
12
12
|
"@babel/cli": "7.10.5",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zohodesk/react-cli",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.7",
|
4
4
|
"description": "A CLI tool for build modern web application and libraries",
|
5
5
|
"scripts": {
|
6
6
|
"init": "node ./lib/utils/init.js",
|
@@ -80,6 +80,7 @@
|
|
80
80
|
"jsdom": "16.4.0",
|
81
81
|
"loader-utils": "2.0.0",
|
82
82
|
"lodash-webpack-plugin": "0.11.5",
|
83
|
+
"markdown-it": "^13.0.1",
|
83
84
|
"mini-css-extract-plugin": "0.10.0",
|
84
85
|
"nock": "13.2.9",
|
85
86
|
"nodemailer": "6.4.11",
|
package/templates/docs/all.html
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
6
|
<link rel="stylesheet" href="./css/component.css" />
|
7
7
|
<link rel="stylesheet" href="/docs/css/main.css" />
|
8
|
+
<link rel="stylesheet" href="./css/markdown.css">
|
8
9
|
</head>
|
9
10
|
<body>
|
10
11
|
<div id="react" class="appContainer"></div>
|
@@ -6,6 +6,7 @@
|
|
6
6
|
<link rel="stylesheet" href="./css/component.css" />
|
7
7
|
<link rel="stylesheet" href="./css/componentTest.css" />
|
8
8
|
<link rel="stylesheet" href="/docs/css/main.css" />
|
9
|
+
<link rel="stylesheet" href="./css/markdown.css">
|
9
10
|
</head>
|
10
11
|
<body>
|
11
12
|
<div id="react" class="ssTest appContainer"></div>
|
@@ -0,0 +1,202 @@
|
|
1
|
+
:root{
|
2
|
+
--cli-md-cli-md-base-font-family: -apple-system,system-ui,"Segoe UI",Regular,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
|
3
|
+
--cli-md-cli-md-base-colour: #d9dcde;
|
4
|
+
}
|
5
|
+
|
6
|
+
.markDown {
|
7
|
+
line-height: 1.6;
|
8
|
+
margin: 20px;
|
9
|
+
color: #333;
|
10
|
+
font-size: 16px;
|
11
|
+
}
|
12
|
+
.markDown p {
|
13
|
+
margin-bottom: 16px;
|
14
|
+
line-height:2
|
15
|
+
}
|
16
|
+
|
17
|
+
.markDown h1 {
|
18
|
+
box-sizing: border-box;
|
19
|
+
color: var(--cli-md-base-colour);
|
20
|
+
font-family: var(--cli-md-base-font-family);
|
21
|
+
font-size: 2em;
|
22
|
+
font-weight: 600;
|
23
|
+
line-height: 1.25;
|
24
|
+
margin: 24px 0 16px;
|
25
|
+
padding-bottom: .3em;
|
26
|
+
word-wrap: break-word;
|
27
|
+
border-bottom: 1px solid #eaecef
|
28
|
+
}
|
29
|
+
|
30
|
+
.markDown h2 {
|
31
|
+
font-size: 1.5em
|
32
|
+
}
|
33
|
+
|
34
|
+
.markDown h2,.markDown h3 {
|
35
|
+
box-sizing: border-box;
|
36
|
+
color: var(--cli-md-base-colour);
|
37
|
+
font-family: var(--cli-md-base-font-family);
|
38
|
+
font-weight: 600;
|
39
|
+
line-height: 1.25;
|
40
|
+
margin-bottom: 16px;
|
41
|
+
margin-top: 24px;
|
42
|
+
padding-bottom: .3em;
|
43
|
+
word-wrap: break-word;
|
44
|
+
border-bottom: 1px solid #eaecef
|
45
|
+
}
|
46
|
+
|
47
|
+
.markDown h3 {
|
48
|
+
font-size: 1.2em
|
49
|
+
}
|
50
|
+
|
51
|
+
.markDown h4 {
|
52
|
+
box-sizing: border-box;
|
53
|
+
color: var(--cli-md-base-colour);
|
54
|
+
font-family: var(--cli-md-base-font-family);
|
55
|
+
font-size: 1em;
|
56
|
+
font-weight: 600;
|
57
|
+
line-height: 1.25;
|
58
|
+
margin-bottom: 16px;
|
59
|
+
margin-top: 24px;
|
60
|
+
word-wrap: break-word
|
61
|
+
}
|
62
|
+
|
63
|
+
.markDown td,.markDown th {
|
64
|
+
border-collapse: collapse;
|
65
|
+
box-sizing: border-box;
|
66
|
+
color: var(--cli-md-base-colour);
|
67
|
+
font-family: var(--cli-md-base-font-family);
|
68
|
+
line-height: 24px;
|
69
|
+
padding: 6px 13px;
|
70
|
+
text-align: -webkit-left;
|
71
|
+
word-wrap: break-word;
|
72
|
+
border: 1px solid #dfe2e5
|
73
|
+
}
|
74
|
+
|
75
|
+
.markDown th {
|
76
|
+
font-weight: 600
|
77
|
+
}
|
78
|
+
|
79
|
+
.markDown tr {
|
80
|
+
background-color: #fff;
|
81
|
+
border-collapse: collapse;
|
82
|
+
box-sizing: border-box;
|
83
|
+
color: var(--cli-md-base-colour);
|
84
|
+
font-family: var(--cli-md-base-font-family);
|
85
|
+
line-height: 24px;
|
86
|
+
overflow-wrap: break-word;
|
87
|
+
word-wrap: break-word
|
88
|
+
}
|
89
|
+
|
90
|
+
.markDown tr :nth-child(2n) {
|
91
|
+
background-color: #f6f8fa
|
92
|
+
}
|
93
|
+
|
94
|
+
.markDown thead {
|
95
|
+
font-size: 16px;
|
96
|
+
line-height: 1.5;
|
97
|
+
word-wrap: break-word;
|
98
|
+
border-spacing: 0;
|
99
|
+
border-collapse: collapse;
|
100
|
+
box-sizing: border-box
|
101
|
+
}
|
102
|
+
|
103
|
+
.markDown table {
|
104
|
+
-webkit-border-horizontal-spacing: 0;
|
105
|
+
-webkit-border-vertical-spacing: 0;
|
106
|
+
border-collapse: collapse;
|
107
|
+
box-sizing: border-box;
|
108
|
+
color: var(--cli-md-base-colour);
|
109
|
+
display: block;
|
110
|
+
margin-top: 0;
|
111
|
+
overflow: auto;
|
112
|
+
width: -webkit-max-content;
|
113
|
+
width: -moz-max-content;
|
114
|
+
width: max-content
|
115
|
+
}
|
116
|
+
|
117
|
+
.markDown image,.markDown table {
|
118
|
+
font-family: var(--cli-md-base-font-family);
|
119
|
+
line-height: 24px;
|
120
|
+
margin-bottom: 16px;
|
121
|
+
max-width: 100%;
|
122
|
+
word-wrap: break-word
|
123
|
+
}
|
124
|
+
|
125
|
+
.markDown image {
|
126
|
+
background-color: #fff;
|
127
|
+
border-style: none;
|
128
|
+
color: #0366d6;
|
129
|
+
cursor: pointer
|
130
|
+
}
|
131
|
+
|
132
|
+
.markDown ul {
|
133
|
+
box-sizing: border-box;
|
134
|
+
color: var(--cli-md-base-colour);
|
135
|
+
font-family: var(--cli-md-base-font-family);
|
136
|
+
line-height: 24px;
|
137
|
+
margin-bottom: 16px;
|
138
|
+
margin-top: 0;
|
139
|
+
padding-left: 2em;
|
140
|
+
word-wrap: break-word
|
141
|
+
}
|
142
|
+
|
143
|
+
.markDown ul li {
|
144
|
+
list-style: initial
|
145
|
+
}
|
146
|
+
|
147
|
+
.markDown ol li,.markDown ul li {
|
148
|
+
box-sizing: border-box;
|
149
|
+
color: var(--cli-md-base-colour);
|
150
|
+
font-family: var(--cli-md-base-font-family);
|
151
|
+
line-height: 24px;
|
152
|
+
margin-top: .25em;
|
153
|
+
text-align: left;
|
154
|
+
word-wrap: break-word
|
155
|
+
}
|
156
|
+
|
157
|
+
.markDown ol li {
|
158
|
+
list-style: decimal
|
159
|
+
}
|
160
|
+
|
161
|
+
.markDown pre {
|
162
|
+
background-color: #f6f8fa;
|
163
|
+
line-height: 1.45;
|
164
|
+
margin-bottom: 16px;
|
165
|
+
margin-top: 0;
|
166
|
+
overflow: auto;
|
167
|
+
overflow-wrap: normal;
|
168
|
+
padding: 16px;
|
169
|
+
white-space: pre;
|
170
|
+
word-break: normal
|
171
|
+
}
|
172
|
+
|
173
|
+
.markDown pre,.markDown code:not(.markDown pre code) {
|
174
|
+
border-radius: 6px;
|
175
|
+
box-sizing: border-box;
|
176
|
+
color: var(--cli-md-base-colour);
|
177
|
+
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
|
178
|
+
font-size: 85%
|
179
|
+
}
|
180
|
+
|
181
|
+
.markDown code:not(.markDown pre code) {
|
182
|
+
background-color: rgba(27,31,35,.05);
|
183
|
+
line-height: 20.4px;
|
184
|
+
margin: 0;
|
185
|
+
padding: .2em .4em;
|
186
|
+
word-wrap: break-word
|
187
|
+
}
|
188
|
+
|
189
|
+
.markDown a {
|
190
|
+
box-sizing: border-box;
|
191
|
+
color: #0366d6;
|
192
|
+
cursor: pointer;
|
193
|
+
font-family: var(--cli-md-base-font-family);
|
194
|
+
line-height: 24px;
|
195
|
+
text-decoration: none;
|
196
|
+
word-wrap: break-word
|
197
|
+
}
|
198
|
+
|
199
|
+
.markDown a :hover {
|
200
|
+
outline: 0;
|
201
|
+
text-decoration: underline
|
202
|
+
}
|
@@ -14,6 +14,7 @@
|
|
14
14
|
<script src="./js/active-line.js"></script>
|
15
15
|
<script src="./js/matchbrackets.js"></script>
|
16
16
|
<link rel="stylesheet" type="text/css" href="./css/hopscotch.css">
|
17
|
+
<link rel="stylesheet" href="./css/markdown.css">
|
17
18
|
<title>Zoho Desk - React Components</title>
|
18
19
|
<script>
|
19
20
|
|