@zohodesk/react-cli 1.1.11-exp.6 → 1.1.11-exp.8
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +12 -0
- package/lib/pluginUtils/getDevPlugins.js +3 -1
- package/lib/pluginUtils/getProdPlugins.js +3 -1
- package/lib/plugins/EfcResourceCleanupPlugin.js +11 -7
- package/lib/plugins/StatsPlugin.js +8 -44
- package/lib/schemas/index.js +3 -3
- package/lib/utils/object-manipulation.js +41 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -44,6 +44,18 @@ Now to run app
|
|
44
44
|
|
45
45
|
# Change Logs
|
46
46
|
|
47
|
+
|
48
|
+
# 1.1.11-exp.8 (4-9-2023)
|
49
|
+
|
50
|
+
**Changes**
|
51
|
+
- Re-factoring related changes
|
52
|
+
|
53
|
+
|
54
|
+
# 1.1.11-exp.7 (1-9-2023)
|
55
|
+
|
56
|
+
**Changes**
|
57
|
+
- Fixed the unInsall variable not available via window varaible issue with resource cleanup plugin
|
58
|
+
|
47
59
|
# 1.1.11-exp.6 (31-8-2023)
|
48
60
|
|
49
61
|
**Features**
|
@@ -193,7 +193,9 @@ const getDevPlugins = (options, publicPath) => {
|
|
193
193
|
}));
|
194
194
|
instrumentScript && pluginsArr.push(new _plugins.ScriptInstrumentPlugin());
|
195
195
|
customAttributes.enable && pluginsArr.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
|
196
|
-
customAttributes.enable && pluginsArr.push(new _EfcResourceCleanupPlugin.default(customAttributes
|
196
|
+
customAttributes.enable && pluginsArr.push(new _EfcResourceCleanupPlugin.default(Object.assign({}, customAttributes, {
|
197
|
+
globalCacheObj: context
|
198
|
+
})));
|
197
199
|
hasShadowDOM && pluginsArr.push(new _plugins.ShadowDOMSupportPlugin());
|
198
200
|
|
199
201
|
if (devCssFileBountry) {
|
@@ -298,7 +298,9 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
298
298
|
|
299
299
|
|
300
300
|
customAttributes.enable && pluginsArr.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
|
301
|
-
customAttributes.enable && pluginsArr.push(new _EfcResourceCleanupPlugin.default(customAttributes
|
301
|
+
customAttributes.enable && pluginsArr.push(new _EfcResourceCleanupPlugin.default(Object.assign({}, customAttributes, {
|
302
|
+
globalCacheObj: context
|
303
|
+
})));
|
302
304
|
enableStats && pluginsArr.push(new _StatsPlugin.default({
|
303
305
|
statsOptions,
|
304
306
|
statsOutputExcludeKeys,
|
@@ -15,10 +15,14 @@ module.exports = class EfcResouceCleanupPlugin {
|
|
15
15
|
mainTemplate
|
16
16
|
}) => {
|
17
17
|
mainTemplate.hooks.afterStartup.tap(plugInName, source => {
|
18
|
-
const
|
18
|
+
const {
|
19
|
+
attributes,
|
20
|
+
globalCacheObj
|
21
|
+
} = this.options;
|
22
|
+
const attributesArr = Object.entries(attributes);
|
19
23
|
const [[attributekey, attributeValue]] = attributesArr;
|
20
24
|
const resourceSelector = `[${attributekey}="${attributeValue}"]`;
|
21
|
-
return Template.asString([source, Template.indent([`
|
25
|
+
return Template.asString([source, Template.indent([` window['${globalCacheObj}Jsonp'].unInstall = function() {
|
22
26
|
Object.keys(installedModules).forEach(installedModulesKey => installedModules[installedModulesKey] = null);
|
23
27
|
Object.keys(modules).forEach(moduleKey => modules[moduleKey] = null);
|
24
28
|
`, `
|
@@ -27,11 +31,11 @@ module.exports = class EfcResouceCleanupPlugin {
|
|
27
31
|
__webpack_require__.m = null;
|
28
32
|
__webpack_require__.c = null;
|
29
33
|
|
30
|
-
`, `
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
`, attributekey && attributeValue ? `
|
35
|
+
const addedResources = document.querySelectorAll('${resourceSelector}');
|
36
|
+
addedResources.forEach(addedResource => addedResource.remove());
|
37
|
+
}
|
38
|
+
` : ''])]);
|
35
39
|
});
|
36
40
|
});
|
37
41
|
}
|
@@ -9,7 +9,8 @@ const {
|
|
9
9
|
} = require('stream');
|
10
10
|
|
11
11
|
const {
|
12
|
-
removeKeysFromObject
|
12
|
+
removeKeysFromObject,
|
13
|
+
convertObjectToStringGen
|
13
14
|
} = require('../utils/object-manipulation');
|
14
15
|
|
15
16
|
const pluginName = 'stats-plugin';
|
@@ -17,52 +18,15 @@ const statsSchema = {
|
|
17
18
|
all: true
|
18
19
|
};
|
19
20
|
|
20
|
-
function* convertObjectToStringGen(obj) {
|
21
|
-
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || obj === null) {
|
22
|
-
yield JSON.stringify(obj);
|
23
|
-
} else if (Array.isArray(obj)) {
|
24
|
-
yield '[';
|
25
|
-
let isFirst = true;
|
26
|
-
|
27
|
-
for (let item of obj) {
|
28
|
-
if (item === undefined) {
|
29
|
-
item = null;
|
30
|
-
}
|
31
|
-
|
32
|
-
yield `${isFirst ? '' : ','}`;
|
33
|
-
yield* convertObjectToStringGen(item);
|
34
|
-
isFirst = false;
|
35
|
-
}
|
36
|
-
|
37
|
-
yield ']';
|
38
|
-
} else {
|
39
|
-
yield '{';
|
40
|
-
let isFirst = true;
|
41
|
-
const entries = Object.entries(obj);
|
42
|
-
|
43
|
-
for (const [itemKey, itemValue] of entries) {
|
44
|
-
if (itemValue === undefined) {
|
45
|
-
continue;
|
46
|
-
}
|
47
|
-
|
48
|
-
yield `${isFirst ? '' : ','}${JSON.stringify(itemKey)}: `;
|
49
|
-
yield* convertObjectToStringGen(itemValue);
|
50
|
-
isFirst = false;
|
51
|
-
}
|
52
|
-
|
53
|
-
yield '}';
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
21
|
class StatsPlugin {
|
58
22
|
constructor({
|
59
|
-
statsOptions
|
60
|
-
statsOutputExcludeKeys
|
61
|
-
statsFileName
|
23
|
+
statsOptions,
|
24
|
+
statsOutputExcludeKeys,
|
25
|
+
statsFileName
|
62
26
|
}) {
|
63
|
-
this.excludeKeysInStat = statsOutputExcludeKeys;
|
64
|
-
this.
|
65
|
-
this.
|
27
|
+
this.excludeKeysInStat = statsOutputExcludeKeys || [];
|
28
|
+
this.statsFileName = statsFileName || 'bundle-report-integrity.json';
|
29
|
+
this.statsOptions = Object.assign({}, statsSchema, statsOptions || {});
|
66
30
|
}
|
67
31
|
|
68
32
|
apply(compiler) {
|
package/lib/schemas/index.js
CHANGED
@@ -729,9 +729,9 @@ var _default = {
|
|
729
729
|
value: false,
|
730
730
|
cli: 'enable_stats'
|
731
731
|
},
|
732
|
-
fileName:
|
733
|
-
options:
|
734
|
-
excludeKeys:
|
732
|
+
fileName: null,
|
733
|
+
options: null,
|
734
|
+
excludeKeys: null
|
735
735
|
}
|
736
736
|
};
|
737
737
|
exports.default = _default;
|
@@ -3,6 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.convertObjectToStringGen = convertObjectToStringGen;
|
6
7
|
exports.removeKeysFromObject = removeKeysFromObject;
|
7
8
|
|
8
9
|
function objectPathMatcher(currentKey, objHierarchy = [], keysToBeRemoved = []) {
|
@@ -20,7 +21,9 @@ function objectPathMatcher(currentKey, objHierarchy = [], keysToBeRemoved = [])
|
|
20
21
|
}
|
21
22
|
/*
|
22
23
|
1) *.keyTobeRemoved -> means match every object path, this key will be removed
|
23
|
-
2)
|
24
|
+
2) keyToBeremoved -> means root object key
|
25
|
+
3) nestedPath.keyToBeRemoved -> means only that nested path key
|
26
|
+
4) don't need to account for array iteration, just object key path is enough in the key to be removed.
|
24
27
|
*/
|
25
28
|
|
26
29
|
|
@@ -45,4 +48,41 @@ function removeKeysFromObject(obj, keysToBeRemoved, prevKeys = []) {
|
|
45
48
|
}
|
46
49
|
|
47
50
|
return obj;
|
51
|
+
}
|
52
|
+
|
53
|
+
function* convertObjectToStringGen(obj) {
|
54
|
+
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || obj === null) {
|
55
|
+
yield JSON.stringify(obj);
|
56
|
+
} else if (Array.isArray(obj)) {
|
57
|
+
yield '[';
|
58
|
+
let isFirst = true;
|
59
|
+
|
60
|
+
for (let item of obj) {
|
61
|
+
if (item === undefined) {
|
62
|
+
item = null;
|
63
|
+
}
|
64
|
+
|
65
|
+
yield `${isFirst ? '' : ','}`;
|
66
|
+
yield* convertObjectToStringGen(item);
|
67
|
+
isFirst = false;
|
68
|
+
}
|
69
|
+
|
70
|
+
yield ']';
|
71
|
+
} else {
|
72
|
+
yield '{';
|
73
|
+
let isFirst = true;
|
74
|
+
const entries = Object.entries(obj);
|
75
|
+
|
76
|
+
for (const [itemKey, itemValue] of entries) {
|
77
|
+
if (itemValue === undefined) {
|
78
|
+
continue;
|
79
|
+
}
|
80
|
+
|
81
|
+
yield `${isFirst ? '' : ','}${JSON.stringify(itemKey)}: `;
|
82
|
+
yield* convertObjectToStringGen(itemValue);
|
83
|
+
isFirst = false;
|
84
|
+
}
|
85
|
+
|
86
|
+
yield '}';
|
87
|
+
}
|
48
88
|
}
|