@zohodesk/react-cli 1.1.5-exp.5 → 1.1.6

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 CHANGED
@@ -44,15 +44,18 @@ 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.
47
+ # 1.1.6
49
48
 
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.
49
+ **Issue Fix**
50
+ - local install react-cli spawnSync Error fix in npm 8
51
+ - babel version update issue fix (Cannot read properties of undefined (reading 'file')) and (BABEL_TRANSFORM_ERROR)
52
+
53
+ # 1.1.5-exp.2
54
+
55
+ **Issue Fix**
56
+ - local install react-cli spawnSync Error fix in npm 8
52
57
 
53
- # 1.1.5-exp.3
54
- - added options to split chunks base config
55
- - added support for passing custom chunks split logic as function.
58
+ # 1.1.5
56
59
 
57
60
  **Issue Fix**
58
61
 
@@ -65,6 +68,11 @@ Now to run app
65
68
  - `0px` variable value conversion issue fixed
66
69
  - pattern exclude for postcss plugins case fixed
67
70
 
71
+ # 1.1.3
72
+
73
+ **Issue Fix**
74
+ - local install react-cli spawnSync Error fix
75
+
68
76
  # 1.1.2
69
77
 
70
78
  **Issue Fix**
@@ -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` **{ String | Function }** regex pattern as string and custom logic to split chunks can be defined using function
8
- - `name` **{ String }** chunk name
9
- - `size` **{ Number }** is count which is minimum chunk duplicated or need in chunks
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 alias of `size` default value is `2`,
17
- - `rules`: `rules` is same as `pattern` with some easy hooks **(removed after v1.1.5)**
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
- includeDependency: includeDependency default value is false
26
+ includeDepenency: includeDepenency default value is false
@@ -15,53 +15,35 @@ var _testPattern = require("./testPattern");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- const isWindows = _os.default.platform().toLowerCase() === 'win32';
19
- const ps = _path.default.sep;
20
- const options = (0, _utils.getOptions)();
21
- const {
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 reactBundle = ['react', 'react-dom', 'react-redux', 'react-transition-group', 'scheduler', 'prop-types'];
30
28
 
31
- const isVendor = function isVendor(module) {
32
- const {
29
+ let isVendor = function isVendor(module) {
30
+ let {
33
31
  userRequest
34
32
  } = module;
35
- let excludeList = ['script-loader', 'raw-loader', ...reactBundle];
33
+ let excludeList = ['script-loader', 'raw-loader', 'react', 'react-dom'];
36
34
  excludeList = [...excludeList, ...vendorExclude];
37
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));
38
36
  };
39
37
 
40
- const isReact = module => {
41
- const {
38
+ let isReact = module => {
39
+ let {
42
40
  userRequest
43
41
  } = module;
42
+ let reactBundle = ['react', 'react-dom'];
44
43
  return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
45
44
  };
46
45
 
47
- function rulesMatcher(pattern) {
48
- if (typeof pattern === 'function') {
49
- return pattern;
50
- }
51
-
52
- if (Array.isArray(pattern)) {
53
- return ({
54
- userRequest
55
- }) => (0, _testPattern.testPattern)(userRequest, pattern);
56
- }
57
-
58
- return new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern);
59
- }
60
-
61
- const baseSplitChunkConfig = Object.assign({
62
- minSize: 15000
63
- }, customChunksBaseConfig);
64
- const specificCacheGroupConfig = {
46
+ let defaultChunks = {
65
47
  'react.vendor': {
66
48
  name: 'react.vendor',
67
49
  chunks: 'all',
@@ -81,36 +63,43 @@ const specificCacheGroupConfig = {
81
63
  priority: -10
82
64
  }
83
65
  };
84
- const customChunksConfig = {};
66
+ let customChunksConfig = {};
85
67
  customChunks.map((obj, index) => ({
86
68
  name: obj.name,
87
- chunks: obj.chunks || 'all',
88
- minChunks: obj.minChunks || obj.size || 2,
89
69
  pattern: obj.pattern,
70
+ minChunks: obj.minChunks || obj.size || 2,
71
+ rules: obj.rules,
72
+ // includeDepenency: obj.includeDepenency || false,
90
73
  priority: obj.priority || -10 * (index + 2),
91
74
  enforce: obj.enforce || true,
92
- minSize: obj.minSize,
93
- // || 20000,
94
75
  maxSize: obj.maxSize,
95
76
  // || 0,
96
- reuseExistingChunk: obj.reuseExistingChunk || false,
97
- automaticNamePrefix: obj.automaticNamePrefix || null,
98
- cacheGroupName: obj.cacheGroupName || obj.name
99
- })).forEach(({
77
+ minSize: obj.minSize,
78
+ // || 20000,
79
+ chunks: obj.chunks || 'all'
80
+ })).map(({
100
81
  name,
101
- chunks = 'all',
102
- minChunks,
103
82
  pattern,
83
+ minChunks,
84
+ rules,
104
85
  priority,
86
+ // includeDepenency,
105
87
  enforce,
106
88
  minSize,
107
89
  maxSize,
108
- reuseExistingChunk,
109
- automaticNamePrefix,
110
- cacheGroupName
90
+ chunks = 'all'
111
91
  }) => {
112
- const obj = {
113
- test: rulesMatcher(pattern),
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),
114
103
  chunks,
115
104
  enforce,
116
105
  minChunks,
@@ -125,25 +114,13 @@ customChunks.map((obj, index) => ({
125
114
  obj.maxSize = maxSize;
126
115
  }
127
116
 
128
- if (name !== undefined) {
129
- obj.name = name;
130
- }
131
-
132
- if (reuseExistingChunk !== undefined) {
133
- obj.reuseExistingChunk = reuseExistingChunk;
134
- }
135
-
136
- if (automaticNamePrefix) {
137
- obj.automaticNamePrefix = automaticNamePrefix;
138
- }
139
-
140
- customChunksConfig[cacheGroupName] = obj;
117
+ return customChunksConfig[name] = obj;
141
118
  });
142
- const splitChunkConfig = Object.assign({}, baseSplitChunkConfig, {
119
+ var _default = {
120
+ minSize: 12000,
143
121
  cacheGroups: Object.assign({
144
122
  default: false,
145
123
  vendors: false
146
- }, specificCacheGroupConfig, customChunksConfig)
147
- });
148
- var _default = splitChunkConfig;
124
+ }, defaultChunks, customChunksConfig)
125
+ };
149
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 modifiedPattern = pattern;
16
+ let modifyedPattern = pattern;
17
17
 
18
- if (/[*.$^]/.test(modifiedPattern)) {
18
+ if (/[*.$^]/.test(modifyedPattern)) {
19
19
  if (isWindows) {
20
- // modifiedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
21
- modifiedPattern = modifiedPattern.replace(/\//g, '\\\\');
20
+ // modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
21
+ modifyedPattern = modifyedPattern.replace(/\//g, '\\\\');
22
22
  }
23
23
 
24
- modifiedPattern = modifiedPattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
25
- const re = new RegExp(modifiedPattern);
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
- // modifiedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
31
- modifiedPattern = modifiedPattern.replace(/\//g, '\\');
30
+ // modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
31
+ modifyedPattern = modifyedPattern.replace(/\//g, '\\');
32
32
  }
33
33
 
34
- return req.indexOf(modifiedPattern) !== -1;
34
+ return req.indexOf(modifyedPattern) !== -1;
35
35
  }
36
36
 
37
37
  function testPattern(req, pattern) {
@@ -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 = true;
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}.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
- })`]), '};',
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}.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];',
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
  ]), '}']), '};']);
@@ -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$'
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _child_process = require("child_process");
9
9
 
10
- var _fs = _interopRequireWildcard(require("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(_x => {
191
- const x = _x.replace(/\//gi, _path.default.sep);
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(_x => {
202
- const x = _x.replace(/\//gi, _path.default.sep);
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 = getOptionsFromConfigFile(appPath, processEnv.config_file);
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 = userSchemas || require(packagePath)['react-cli'] || {};
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
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "1.1.5-exp.5",
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.5-exp.5",
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.5-exp.5",
3
+ "version": "1.1.6",
4
4
  "description": "A CLI tool for build modern web application and libraries",
5
5
  "scripts": {
6
6
  "init": "node ./lib/utils/init.js",