@zohodesk/react-cli 0.0.1-exp.161.3 → 0.0.1-exp.164.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +3 -7
- package/README.md +120 -9
- package/bin/cli.js +67 -21
- package/eslint/NOTES.md +3 -0
- package/eslint/a23.c +16 -0
- package/eslint/a28.c +25 -0
- package/eslint/a29.c +25 -0
- package/eslint/a30.c +29 -0
- package/eslint/a31.c +23 -0
- package/eslint/a35.c +23 -0
- package/eslint/a36.c +18 -0
- package/eslint/a37.c +25 -0
- package/eslint/a38.c +28 -0
- package/eslint/a39.c +17 -0
- package/eslint/a40.c +32 -0
- package/eslint/mockapi.html +18 -0
- package/eslint/mockapi.md +5 -0
- package/lib/common/criteriaHandler.js +91 -0
- package/lib/common/index.js +6 -6
- package/lib/common/splitChunks.js +54 -18
- package/lib/common/splitChunks1.js +95 -0
- package/lib/common/splitChunksNew.js +129 -0
- package/lib/common/testPattern.js +71 -0
- package/lib/configs/jest.config.js +12 -3
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.dev.config.js +6 -19
- package/lib/configs/webpack.prod.config.js +18 -21
- package/lib/loaderUtils/index.js +4 -4
- package/lib/pluginUtils/getDevPlugins.js +2 -0
- package/lib/pluginUtils/getProdPlugins.js +2 -0
- package/lib/pluginUtils/index.js +12 -12
- package/lib/plugins/EFCPlugin.js +43 -13
- package/lib/plugins/EFCTemplatePlugin.js +151 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +2 -2
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +1 -1
- package/lib/plugins/ManifestPlugin.js +8 -0
- package/lib/plugins/index.js +36 -36
- package/lib/postcss-plugins/RTLSplitPlugin.js +1 -1
- package/lib/schemas/index.js +15 -0
- package/lib/templates/linterConstant.js +1 -1
- package/lib/utils/cssClassNameGenerate.js +9 -2
- package/lib/utils/cssURLReplacer.js +1 -1
- package/lib/utils/getCurrentBranch.js +1 -1
- package/lib/utils/getOptions.js +55 -1
- package/lib/utils/index.js +21 -19
- package/lib/utils/jsonHelper.js +12 -3
- package/lib/utils/reinstallDependencies.js +1 -1
- package/npm8.md +9 -0
- package/package.json +4 -4
@@ -0,0 +1,91 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.criteriaHandler = criteriaHandler;
|
7
|
+
|
8
|
+
/*
|
9
|
+
root = {
|
10
|
+
a: 1
|
11
|
+
b: 0
|
12
|
+
op = "&"
|
13
|
+
}
|
14
|
+
|
15
|
+
rule = (1 & 2) | 0
|
16
|
+
root = {
|
17
|
+
a: {
|
18
|
+
a: 1
|
19
|
+
b: 2
|
20
|
+
op = "&"
|
21
|
+
}
|
22
|
+
b: 0
|
23
|
+
op = "|"
|
24
|
+
}
|
25
|
+
|
26
|
+
rule = (3 | !(1 & 2)) | 0
|
27
|
+
*/
|
28
|
+
function parseNumber(rule, _i) {
|
29
|
+
let i = _i;
|
30
|
+
let ans = 0;
|
31
|
+
|
32
|
+
while (/[0-9]/.test(rule[i])) {
|
33
|
+
ans = ans * 10 + Number(rule[i]);
|
34
|
+
i++;
|
35
|
+
}
|
36
|
+
|
37
|
+
return [i, ans];
|
38
|
+
}
|
39
|
+
|
40
|
+
function criteriaParser(rule, _i = 0) {
|
41
|
+
let openBarceCount = 0; // let root = {};
|
42
|
+
|
43
|
+
let cur = {};
|
44
|
+
let c;
|
45
|
+
|
46
|
+
for (let i = _i; i < rule.length; i++) {
|
47
|
+
c = rule[i];
|
48
|
+
|
49
|
+
if (/[0-9]/.test(c)) {
|
50
|
+
let [_i, num] = parseNumber(rule, i);
|
51
|
+
i = _i - 1;
|
52
|
+
|
53
|
+
if (cur.a === undefined) {
|
54
|
+
cur.a = num; // } else if (cur.b === undefined) {
|
55
|
+
} else {
|
56
|
+
cur.b = num; // if (cur.op && cur.a);
|
57
|
+
// } else {
|
58
|
+
}
|
59
|
+
} else if (/[|&]/.test(c)) {
|
60
|
+
if (cur.op) {
|
61
|
+
// if (cur.b === undefined && cur.op !== '!') {
|
62
|
+
// throw `Error unexpected charector ${c} in index ${i}`;
|
63
|
+
// }
|
64
|
+
cur = {
|
65
|
+
a: cur,
|
66
|
+
op: c
|
67
|
+
};
|
68
|
+
} else {
|
69
|
+
cur.op = c;
|
70
|
+
}
|
71
|
+
} // if (c === '(' || c === ')') {
|
72
|
+
// if (openBarceCount) {
|
73
|
+
// openBarceCount++;
|
74
|
+
// } else if (c === ')') {
|
75
|
+
// openBarceCount--;
|
76
|
+
// cur = { a, b, op };
|
77
|
+
// }
|
78
|
+
// } else if (/[0-9]/.test(c)) {
|
79
|
+
// } else {
|
80
|
+
// }
|
81
|
+
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
function criteriaHandler(criterias, rule) {
|
86
|
+
if (/[(!)0-9&|]/.test(rule) === false) {
|
87
|
+
console.log('rule has unexpexted charectors');
|
88
|
+
}
|
89
|
+
|
90
|
+
let root = criteriaParser(rule);
|
91
|
+
}
|
package/lib/common/index.js
CHANGED
@@ -3,12 +3,6 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
Object.defineProperty(exports, "splitChunks", {
|
7
|
-
enumerable: true,
|
8
|
-
get: function () {
|
9
|
-
return _splitChunks.default;
|
10
|
-
}
|
11
|
-
});
|
12
6
|
Object.defineProperty(exports, "getEntries", {
|
13
7
|
enumerable: true,
|
14
8
|
get: function () {
|
@@ -21,6 +15,12 @@ Object.defineProperty(exports, "getPublicPathConfig", {
|
|
21
15
|
return _getPublicPathConfig.default;
|
22
16
|
}
|
23
17
|
});
|
18
|
+
Object.defineProperty(exports, "splitChunks", {
|
19
|
+
enumerable: true,
|
20
|
+
get: function () {
|
21
|
+
return _splitChunks.default;
|
22
|
+
}
|
23
|
+
});
|
24
24
|
Object.defineProperty(exports, "templateParameters", {
|
25
25
|
enumerable: true,
|
26
26
|
get: function () {
|
@@ -7,9 +7,11 @@ exports.default = void 0;
|
|
7
7
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
9
9
|
|
10
|
+
var _os = _interopRequireDefault(require("os"));
|
11
|
+
|
10
12
|
var _utils = require("../utils");
|
11
13
|
|
12
|
-
var
|
14
|
+
var _testPattern = require("./testPattern");
|
13
15
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
17
|
|
@@ -42,35 +44,69 @@ let isReact = module => {
|
|
42
44
|
};
|
43
45
|
|
44
46
|
let defaultChunks = {
|
45
|
-
|
47
|
+
vendors: {
|
48
|
+
// picks up everything from node_modules as long as the sum of node modules is larger than minSize
|
49
|
+
//test: /[\\/]node_modules[\\/]((?!react).*)[\\/]/,
|
50
|
+
test: isVendor,
|
51
|
+
chunks: 'initial',
|
52
|
+
// chunks: 'all',
|
53
|
+
name: 'vendors',
|
54
|
+
priority: 19,
|
55
|
+
enforce: true // causes maxInitialRequests to be ignored, minSize still respected if specified in cacheGroup
|
56
|
+
// minSize: 30000 // use the default minSize
|
57
|
+
|
58
|
+
},
|
59
|
+
react: {
|
46
60
|
name: 'react.vendor',
|
47
|
-
chunks: 'all',
|
48
|
-
minChunks: 1,
|
49
61
|
test: isReact,
|
50
|
-
priority: -10
|
51
|
-
},
|
52
|
-
vendor: {
|
53
|
-
name: 'vendor',
|
54
62
|
chunks: 'all',
|
55
63
|
minChunks: 1,
|
56
|
-
|
57
|
-
priority: -10
|
64
|
+
priority: 10
|
58
65
|
}
|
59
66
|
};
|
60
67
|
let customChunksConfig = {};
|
61
|
-
customChunks.map(({
|
68
|
+
customChunks.map((obj, index) => ({
|
69
|
+
name: obj.name,
|
70
|
+
pattern: obj.pattern,
|
71
|
+
minChunks: obj.minChunks || obj.size || 2,
|
72
|
+
rules: obj.rules,
|
73
|
+
chunks: obj.chunks || 'all',
|
74
|
+
priority: obj.priority || -10 * (index + 2),
|
75
|
+
enforce: obj.enforce || true,
|
76
|
+
maxSize: obj.maxSize || 0,
|
77
|
+
minSize: obj.minSize || 20000,
|
78
|
+
includeDepenency: obj.includeDepenency || false
|
79
|
+
})).map(({
|
62
80
|
name,
|
63
81
|
pattern,
|
64
|
-
|
65
|
-
|
82
|
+
minChunks,
|
83
|
+
rules,
|
84
|
+
priority,
|
85
|
+
chunks = 'all',
|
86
|
+
enforce,
|
87
|
+
minSize,
|
88
|
+
maxSize,
|
89
|
+
includeDepenency
|
90
|
+
}) => customChunksConfig[name] = {
|
66
91
|
name,
|
67
|
-
test:
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
92
|
+
test: rules ? m => {
|
93
|
+
const {
|
94
|
+
userRequest
|
95
|
+
} = m;
|
96
|
+
return (0, _testPattern.testPattern)(userRequest, rules); // return (
|
97
|
+
// pkgs.some(p => isRelated(userRequest, p)) ||
|
98
|
+
// (includeDepenency && isDependency(m, pkgs))
|
99
|
+
// );
|
100
|
+
} : new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern),
|
101
|
+
chunks,
|
102
|
+
enforce,
|
103
|
+
minSize,
|
104
|
+
maxSize,
|
105
|
+
minChunks,
|
106
|
+
priority
|
72
107
|
});
|
73
108
|
var _default = {
|
109
|
+
minSize: 12000,
|
74
110
|
cacheGroups: Object.assign({
|
75
111
|
default: false,
|
76
112
|
vendors: false
|
@@ -0,0 +1,95 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
10
|
+
var _os = _interopRequireDefault(require("os"));
|
11
|
+
|
12
|
+
var _utils = require("../utils");
|
13
|
+
|
14
|
+
var _testPattern = require("./testPattern");
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
+
|
18
|
+
let isWindows = _os.default.platform().toLowerCase() === 'win32';
|
19
|
+
let ps = _path.default.sep;
|
20
|
+
let options = (0, _utils.getOptions)();
|
21
|
+
let {
|
22
|
+
app: {
|
23
|
+
vendorExclude,
|
24
|
+
customChunks,
|
25
|
+
vendorInclude
|
26
|
+
}
|
27
|
+
} = options;
|
28
|
+
|
29
|
+
let isVendor = function isVendor(module) {
|
30
|
+
let {
|
31
|
+
userRequest
|
32
|
+
} = module;
|
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));
|
36
|
+
};
|
37
|
+
|
38
|
+
let isReact = module => {
|
39
|
+
let {
|
40
|
+
userRequest
|
41
|
+
} = module;
|
42
|
+
let reactBundle = ['react', 'react-dom'];
|
43
|
+
return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
|
44
|
+
};
|
45
|
+
|
46
|
+
let defaultChunks = {
|
47
|
+
'react.vendor': {
|
48
|
+
name: 'react.vendor',
|
49
|
+
chunks: 'all',
|
50
|
+
minChunks: 1,
|
51
|
+
test: isReact,
|
52
|
+
priority: -10
|
53
|
+
},
|
54
|
+
vendor: {
|
55
|
+
name: 'vendor',
|
56
|
+
chunks: 'initial',
|
57
|
+
minChunks: 1,
|
58
|
+
test: isVendor,
|
59
|
+
priority: -10
|
60
|
+
}
|
61
|
+
};
|
62
|
+
let customChunksConfig = {};
|
63
|
+
customChunks.map(({
|
64
|
+
name,
|
65
|
+
pattern,
|
66
|
+
size = 2,
|
67
|
+
rules,
|
68
|
+
chunks = 'all',
|
69
|
+
includeDepenency
|
70
|
+
}, index) => customChunksConfig[name] = {
|
71
|
+
name,
|
72
|
+
test: rules ? m => {
|
73
|
+
let {
|
74
|
+
userRequest
|
75
|
+
} = m;
|
76
|
+
let pkgs = rules;
|
77
|
+
|
78
|
+
if (!Array.isArray(rules)) {
|
79
|
+
pkgs = [rules];
|
80
|
+
}
|
81
|
+
|
82
|
+
return pkgs.some(p => (0, _testPattern.isRelated)(userRequest, p)) || includeDepenency && (0, _testPattern.isDependency)(m, pkgs);
|
83
|
+
} : new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern),
|
84
|
+
chunks,
|
85
|
+
enforce: true,
|
86
|
+
minChunks: size,
|
87
|
+
priority: -10 * (index + 2)
|
88
|
+
});
|
89
|
+
var _default = {
|
90
|
+
cacheGroups: Object.assign({
|
91
|
+
default: false,
|
92
|
+
vendors: false
|
93
|
+
}, defaultChunks, customChunksConfig)
|
94
|
+
};
|
95
|
+
exports.default = _default;
|
@@ -0,0 +1,129 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
10
|
+
var _os = _interopRequireDefault(require("os"));
|
11
|
+
|
12
|
+
var _utils = require("../utils");
|
13
|
+
|
14
|
+
var _testPattern = require("./testPattern");
|
15
|
+
|
16
|
+
var _criteriaHandler = require("./criteriaHandler");
|
17
|
+
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
+
|
20
|
+
const isWindows = _os.default.platform().toLowerCase() === 'win32';
|
21
|
+
const ps = _path.default.sep;
|
22
|
+
const options = (0, _utils.getOptions)();
|
23
|
+
const {
|
24
|
+
app: {
|
25
|
+
vendorExclude,
|
26
|
+
customChunks,
|
27
|
+
vendorInclude
|
28
|
+
}
|
29
|
+
} = options;
|
30
|
+
|
31
|
+
const canExclude = (m, excludeList) => {
|
32
|
+
let {
|
33
|
+
userRequest
|
34
|
+
} = m;
|
35
|
+
(0, _criteriaHandler.criteriaHandler)();
|
36
|
+
return (// if node_modules not in path then it is obviously not vendor
|
37
|
+
userRequest.indexOf('node_modules') === -1 || // for css currnetly we use style so it is not vendor
|
38
|
+
userRequest.endsWith('.css') || //I don't know what it is but not vendor (due to previous code)
|
39
|
+
userRequest.endsWith('publicPathConfig.js') || // this list given by user, So we need to exclude them
|
40
|
+
excludeList.some(item => (0, _testPattern.isRelatedPackage)(userRequest, item)) || // this is for exclude dependency module by excluded user
|
41
|
+
(0, _testPattern.isDependency)(m, excludeList)
|
42
|
+
);
|
43
|
+
};
|
44
|
+
|
45
|
+
let isVendor = function isVendor(module) {
|
46
|
+
let {
|
47
|
+
userRequest
|
48
|
+
} = module;
|
49
|
+
let excludeList = ['script-loader', 'raw-loader', 'react', 'react-dom'];
|
50
|
+
excludeList = [...excludeList, ...vendorExclude];
|
51
|
+
return userRequest && (vendorInclude.some(item => userRequest.indexOf(item) !== -1) || // (userRequest.indexOf('node_modules') >= 0 &&
|
52
|
+
// userRequest.endsWith('.css') === false &&
|
53
|
+
// userRequest.endsWith('publicPathConfig.js') === false &&
|
54
|
+
// excludeList.every(
|
55
|
+
// item => userRequest.indexOf(`node_modules${ps}${item}${ps}`) === -1
|
56
|
+
// )))
|
57
|
+
!canExclude(module, excludeList));
|
58
|
+
};
|
59
|
+
|
60
|
+
let isReact = module => {
|
61
|
+
let {
|
62
|
+
userRequest
|
63
|
+
} = module;
|
64
|
+
let reactBundle = ['react', 'react-dom'];
|
65
|
+
return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
|
66
|
+
};
|
67
|
+
|
68
|
+
let defaultChunks = {
|
69
|
+
'react.vendor': {
|
70
|
+
name: 'react.vendor',
|
71
|
+
chunks: 'all',
|
72
|
+
minChunks: 1,
|
73
|
+
test: isReact,
|
74
|
+
priority: -10
|
75
|
+
},
|
76
|
+
vendor: {
|
77
|
+
name: 'vendor',
|
78
|
+
chunks: 'all',
|
79
|
+
minChunks: 1,
|
80
|
+
test: isVendor,
|
81
|
+
priority: -10
|
82
|
+
}
|
83
|
+
};
|
84
|
+
let customChunksConfig = {};
|
85
|
+
console.log(customChunks, 'hi');
|
86
|
+
customChunks.map(({
|
87
|
+
name,
|
88
|
+
pattern,
|
89
|
+
size = 2,
|
90
|
+
rules,
|
91
|
+
chunks = 'all',
|
92
|
+
includeDepenency
|
93
|
+
}, index) => customChunksConfig[name] = {
|
94
|
+
name,
|
95
|
+
test: rules ? m => {
|
96
|
+
let {
|
97
|
+
userRequest
|
98
|
+
} = m;
|
99
|
+
let pkgs = rules;
|
100
|
+
|
101
|
+
if (!Array.isArray(rules)) {
|
102
|
+
pkgs = [rules];
|
103
|
+
}
|
104
|
+
|
105
|
+
return pkgs.some(p => (0, _testPattern.isRelated)(userRequest, p)) || includeDepenency && (0, _testPattern.isDependency)(m, pkgs);
|
106
|
+
} : new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern),
|
107
|
+
chunks,
|
108
|
+
enforce: true,
|
109
|
+
minChunks: size,
|
110
|
+
priority: -10 * (index + 2)
|
111
|
+
});
|
112
|
+
var _default = {
|
113
|
+
cacheGroups: Object.assign({
|
114
|
+
default: false,
|
115
|
+
vendors: false
|
116
|
+
}, defaultChunks, customChunksConfig)
|
117
|
+
}; // supportapp / src / analytics / utils / dashboards / chartUI.js;
|
118
|
+
// supportapp / src / modules / analytics / utils / chartTheme.js;
|
119
|
+
// a = [
|
120
|
+
// 'supportapp/src/analytics/utils/dashboards/chartUI.js',
|
121
|
+
// 'supportapp/src/components/analytics/dashboarddetail/Chart/Chart.js',
|
122
|
+
// 'supportapp/src/modules/analytics/utils/chartTheme.js',
|
123
|
+
// 'supportapp/src/modules/analytics/utils/ChartUI.js',
|
124
|
+
// 'supportapp/src/components/zia/zianotifications/ZiaNotificationDashBoard/ZiaNotificationChart.js',
|
125
|
+
// 'supportapp/src/components/analytics/dashboarddetail/SegmentAudience/DayoftheWeek/DayoftheWeek.js',
|
126
|
+
// 'supportapp/src/components/analytics/dashboarddetail/SegmentAudience/HouroftheDay/HouroftheDay.js'
|
127
|
+
// ];
|
128
|
+
|
129
|
+
exports.default = _default;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.isDependency = isDependency;
|
7
|
+
exports.isRelatedPackage = exports.isRelated = void 0;
|
8
|
+
exports.testPattern = testPattern;
|
9
|
+
|
10
|
+
var _express = require("express");
|
11
|
+
|
12
|
+
var _path = require("path");
|
13
|
+
|
14
|
+
// in our development we only use windows, mac and linux
|
15
|
+
const isWindows = _path.sep !== '/'; // this function will return true if pattern matched
|
16
|
+
|
17
|
+
function _testPattern(req, pattern) {
|
18
|
+
let modifyedPattern = pattern;
|
19
|
+
|
20
|
+
if (/[*.$^]/.test(modifyedPattern)) {
|
21
|
+
if (isWindows) {
|
22
|
+
// modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
|
23
|
+
modifyedPattern = modifyedPattern.replace(/\//g, '\\\\');
|
24
|
+
}
|
25
|
+
|
26
|
+
modifyedPattern = modifyedPattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
|
27
|
+
const re = new RegExp(modifyedPattern);
|
28
|
+
return re.test(req);
|
29
|
+
}
|
30
|
+
|
31
|
+
if (isWindows) {
|
32
|
+
// modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
|
33
|
+
modifyedPattern = modifyedPattern.replace(/\//g, '\\');
|
34
|
+
}
|
35
|
+
|
36
|
+
return req.indexOf(modifyedPattern) !== -1;
|
37
|
+
}
|
38
|
+
|
39
|
+
function testPattern(req, pattern) {
|
40
|
+
if (!req || !pattern) {
|
41
|
+
return false;
|
42
|
+
}
|
43
|
+
|
44
|
+
if (Array.isArray(pattern)) {
|
45
|
+
// eslint-disable-next-line no-unused-vars
|
46
|
+
return pattern.every(p => testPattern(req, p));
|
47
|
+
}
|
48
|
+
|
49
|
+
if (pattern[0] === '!') {
|
50
|
+
return !_testPattern(req, pattern.slice(1));
|
51
|
+
}
|
52
|
+
|
53
|
+
return _testPattern(req, pattern);
|
54
|
+
}
|
55
|
+
|
56
|
+
const isRelated = (req, item) => req && req.indexOf(item) !== -1; // export const isRelated = (req, item) => testPattern(req, item);
|
57
|
+
|
58
|
+
|
59
|
+
exports.isRelated = isRelated;
|
60
|
+
|
61
|
+
const isRelatedPackage = (req, item) => isRelated(req, `node_modules${_path.sep}${item}${_path.sep}`) !== -1; // export const isRelated = (req, item) => testPattern(req, item);
|
62
|
+
|
63
|
+
|
64
|
+
exports.isRelatedPackage = isRelatedPackage;
|
65
|
+
|
66
|
+
function isDependency(m, excludeList) {
|
67
|
+
// let reasons = m.reasons.map(r => r.module.userRequest);
|
68
|
+
// m.reasons.some(r => !r.module || !r.module.userRequest) && console.log(m.reasons);
|
69
|
+
return m.reasons.some(r => excludeList.some(item => r.module && isRelated(r.module.userRequest, item)));
|
70
|
+
} // export function queryHandler(conditions, pattern) {
|
71
|
+
// }
|
@@ -2,9 +2,17 @@
|
|
2
2
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
4
4
|
|
5
|
+
var _libAlias = require("./libAlias");
|
6
|
+
|
5
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
8
|
|
7
|
-
let appPath = process.cwd();
|
9
|
+
let appPath = process.cwd(); // '^@root(.*)$': '<rootDir>/src$1',
|
10
|
+
// '^@components(.*)$': '<rootDir>/src/components$1',
|
11
|
+
|
12
|
+
let moduleNameMapper = Object.keys(_libAlias.libAlias).reduce((previousValue, key) => {
|
13
|
+
previousValue[`^${key}(.*)$`] = `${_libAlias.libAlias[key]}$1`;
|
14
|
+
return previousValue;
|
15
|
+
}, {});
|
8
16
|
let commonConfig = {
|
9
17
|
coverageReporters: ['json', 'html', 'json-summary', 'text'],
|
10
18
|
collectCoverage: true,
|
@@ -14,10 +22,11 @@ let commonConfig = {
|
|
14
22
|
'^.+\\.css$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'cssPreprocessor.js'),
|
15
23
|
'^(?!.*\\.(js|jsx|css|json)$)': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'otherFilesPreprocessor.js')
|
16
24
|
},
|
17
|
-
moduleNameMapper: {
|
25
|
+
moduleNameMapper: { ...moduleNameMapper,
|
18
26
|
'\\.(css|less)$': 'identity-obj-proxy'
|
19
27
|
},
|
20
|
-
transformIgnorePatterns: ['/node_modules
|
28
|
+
transformIgnorePatterns: ['/node_modules/(?!(@zohodesk)/)'],
|
29
|
+
// transformIgnorePatterns: ['/node_modules.*?.js$'],
|
21
30
|
moduleFileExtensions: ['js'],
|
22
31
|
setupFiles: [_path.default.resolve(appPath, '__testUtils__', 'globals.js'), _path.default.resolve(__dirname, '..', 'jest', 'setup.js')],
|
23
32
|
globals: {
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.libAlias = void 0;
|
7
|
+
// the reason for alias at the time was code tree shaking
|
8
|
+
// tree shaking was most compactable with ES module system
|
9
|
+
// FIXME: But there is a posiblity when these package does not have lib,
|
10
|
+
// app will work because of alias, But may be jest won't work because of not alais
|
11
|
+
// So need to think about use alais in jest
|
12
|
+
const libAlias = {
|
13
|
+
'@zohodesk/components/lib': '@zohodesk/components/es',
|
14
|
+
// '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
|
15
|
+
'@zohodesk/dot/lib': '@zohodesk/dot/es',
|
16
|
+
'@zohodesk/i18n/lib': '@zohodesk/i18n/es',
|
17
|
+
'@zohodesk/icons/lib': '@zohodesk/icons/es',
|
18
|
+
'@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
|
19
|
+
'@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
|
20
|
+
'@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
|
21
|
+
'@zohodesk/permissions/lib': '@zohodesk/permissions/es',
|
22
|
+
'@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
|
23
|
+
'@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
|
24
|
+
'@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
|
25
|
+
'@zohodesk/storage/lib': '@zohodesk/storage/es',
|
26
|
+
'@zohodesk/svg/lib': '@zohodesk/svg/es',
|
27
|
+
'@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
|
28
|
+
'@zohodesk/variables/lib': '@zohodesk/variables/es',
|
29
|
+
'@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
|
30
|
+
};
|
31
|
+
exports.libAlias = libAlias;
|
@@ -10,6 +10,8 @@ var _pluginUtils = require("../pluginUtils");
|
|
10
10
|
|
11
11
|
var _loaderUtils = require("../loaderUtils");
|
12
12
|
|
13
|
+
var _libAlias = require("./libAlias");
|
14
|
+
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
16
|
|
15
17
|
let options = (0, _utils.getOptions)();
|
@@ -55,6 +57,9 @@ module.exports = {
|
|
55
57
|
entry: (0, _common.getEntries)(options, 'dev'),
|
56
58
|
devtool: sourcemap,
|
57
59
|
mode: 'development',
|
60
|
+
// watchOptions: {
|
61
|
+
// ignored: /node_modules.(?!@zohodesk)/
|
62
|
+
// },
|
58
63
|
output,
|
59
64
|
stats: options.app.disableWatch ? 'errors-only' : {
|
60
65
|
children: false
|
@@ -127,25 +132,7 @@ module.exports = {
|
|
127
132
|
},
|
128
133
|
resolve: {
|
129
134
|
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
|
130
|
-
alias: disableES5Transpile ? {
|
131
|
-
'@zohodesk/components/lib': '@zohodesk/components/es',
|
132
|
-
// "@zohodesk/zc-custom/lib": "@zohodesk/zc-custom/es",
|
133
|
-
'@zohodesk/dot/lib': '@zohodesk/dot/es',
|
134
|
-
'@zohodesk/i18n/lib': '@zohodesk/i18n/es',
|
135
|
-
'@zohodesk/icons/lib': '@zohodesk/icons/es',
|
136
|
-
'@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
|
137
|
-
'@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
|
138
|
-
'@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
|
139
|
-
'@zohodesk/permissions/lib': '@zohodesk/permissions/es',
|
140
|
-
'@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
|
141
|
-
'@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
|
142
|
-
'@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
|
143
|
-
'@zohodesk/storage/lib': '@zohodesk/storage/es',
|
144
|
-
'@zohodesk/svg/lib': '@zohodesk/svg/es',
|
145
|
-
'@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
|
146
|
-
'@zohodesk/variables/lib': '@zohodesk/variables/es',
|
147
|
-
'@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
|
148
|
-
} : {}
|
135
|
+
alias: disableES5Transpile ? _libAlias.libAlias : {}
|
149
136
|
},
|
150
137
|
resolveLoader: {
|
151
138
|
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
|