@zohodesk/react-cli 1.1.5-exp.3 → 1.1.5-exp.5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +8 -1
- package/docs/CustomChunks.md +1 -1
- package/lib/common/splitChunks.js +3 -3
- package/lib/plugins/ResourceHintsPlugin.js +5 -3
- package/lib/schemas/index.js +1 -1
- package/npm-shrinkwrap.json +18996 -15
- package/package.json +1 -1
package/README.md
CHANGED
@@ -44,8 +44,15 @@ Now to run app
|
|
44
44
|
|
45
45
|
# Change Logs
|
46
46
|
|
47
|
+
# 1.1.5-exp.5
|
48
|
+
- fixed the issues regarding custom chunks base config schema.
|
49
|
+
|
50
|
+
# 1.1.5-exp.4
|
51
|
+
- added support for using regex expression to get group of chunks chunkId via Resource Hint plugin prefetch/preload hook.
|
52
|
+
|
47
53
|
# 1.1.5-exp.3
|
48
|
-
-
|
54
|
+
- added options to split chunks base config
|
55
|
+
- added support for passing custom chunks split logic as function.
|
49
56
|
|
50
57
|
**Issue Fix**
|
51
58
|
|
package/docs/CustomChunks.md
CHANGED
@@ -4,7 +4,7 @@ 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` **{ String | Function }** regex pattern as string and
|
7
|
+
- `pattern` **{ String | Function }** regex pattern as string and custom logic to split chunks can be defined using function
|
8
8
|
- `name` **{ String }** chunk name
|
9
9
|
- `size` **{ Number }** is count which is minimum chunk duplicated or need in chunks
|
10
10
|
|
@@ -59,7 +59,7 @@ function rulesMatcher(pattern) {
|
|
59
59
|
}
|
60
60
|
|
61
61
|
const baseSplitChunkConfig = Object.assign({
|
62
|
-
minSize:
|
62
|
+
minSize: 15000
|
63
63
|
}, customChunksBaseConfig);
|
64
64
|
const specificCacheGroupConfig = {
|
65
65
|
'react.vendor': {
|
@@ -125,11 +125,11 @@ customChunks.map((obj, index) => ({
|
|
125
125
|
obj.maxSize = maxSize;
|
126
126
|
}
|
127
127
|
|
128
|
-
if (name) {
|
128
|
+
if (name !== undefined) {
|
129
129
|
obj.name = name;
|
130
130
|
}
|
131
131
|
|
132
|
-
if (reuseExistingChunk) {
|
132
|
+
if (reuseExistingChunk !== undefined) {
|
133
133
|
obj.reuseExistingChunk = reuseExistingChunk;
|
134
134
|
}
|
135
135
|
|
@@ -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 = true;
|
23
23
|
|
24
24
|
for (const key in idNameMap) {
|
25
25
|
if (Object.prototype.hasOwnProperty.call(idNameMap, key)) {
|
@@ -32,7 +32,9 @@ class ResourceHintsPlugin {
|
|
32
32
|
}
|
33
33
|
}
|
34
34
|
|
35
|
-
return Template.asString([source, '', `${mainTemplate.requireFn}.
|
35
|
+
return Template.asString([source, '', `${mainTemplate.requireFn}.getChunkIds = function getChunkIds(chunkId) {`, Template.indent((needsMap ? [`const nameToChunkIdMap = ${JSON.stringify(nameIdMap)}`, 'const chunkNames = Object.keys(nameToChunkIdMap)'] : []).concat(['return chunkNames.filter(chunkName => chunkId.test(chunkName)).map(chunkName => nameToChunkIdMap[chunkName]);'])), '}', `// Prefetch a chunk (${pluginName})`, `${mainTemplate.requireFn}.pfc = function prefetchChunk(chunkId) {`, Template.indent([`let chunkIds = ${mainTemplate.requireFn}.getChunkIds(new RegExp(chunkId, 'i'))`, `chunkIds.forEach(idOfAChunk => {
|
36
|
+
${mainTemplate.requireFn}.e(idOfAChunk);
|
37
|
+
})`]), '};',
|
36
38
|
/*
|
37
39
|
(needsMap
|
38
40
|
? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`]
|
@@ -53,7 +55,7 @@ class ResourceHintsPlugin {
|
|
53
55
|
),
|
54
56
|
'}',
|
55
57
|
*/
|
56
|
-
`// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.
|
58
|
+
`// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkIds(new RegExp('^' + chunkId + '$'))[0]`, '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];',
|
57
59
|
// mainTemplate.hooks.jsonpScript.call('', chunk, hash),
|
58
60
|
// 'head.appendChild(script);'
|
59
61
|
]), '}']), '};']);
|