@zohodesk/react-cli 1.1.6-exp.1 → 1.1.6-exp.2

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,23 +44,28 @@ Now to run app
44
44
 
45
45
  # Change Logs
46
46
 
47
+ # 1.1.6-exp.2
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.
50
+
51
+ # 1.1.5-exp.5
52
+ - fixed the issues regarding custom chunks base config schema.
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.
47
60
  # 1.1.6
48
61
 
49
62
  **Issue Fix**
50
-
51
63
  - local install react-cli spawnSync Error fix in npm 8
52
64
  - babel version update issue fix (Cannot read properties of undefined (reading 'file')) and (BABEL_TRANSFORM_ERROR)
53
65
 
54
- # 1.1.6-exp.1
55
-
56
- **New Feature**
57
-
58
- - Typescript support
59
-
60
66
  # 1.1.5-exp.2
61
67
 
62
68
  **Issue Fix**
63
-
64
69
  - local install react-cli spawnSync Error fix in npm 8
65
70
 
66
71
  # 1.1.5
@@ -72,7 +77,6 @@ Now to run app
72
77
  # 1.1.4
73
78
 
74
79
  **Issue Fix**
75
-
76
80
  - global install react-cli spawnSync Error fix
77
81
  - `0px` variable value conversion issue fixed
78
82
  - pattern exclude for postcss plugins case fixed
@@ -80,7 +84,6 @@ Now to run app
80
84
  # 1.1.3
81
85
 
82
86
  **Issue Fix**
83
-
84
87
  - local install react-cli spawnSync Error fix
85
88
 
86
89
  # 1.1.2
@@ -92,63 +95,54 @@ Now to run app
92
95
  # 1.1.1
93
96
 
94
97
  **Issue Fix**
95
-
96
98
  - docs component name incorrect in windows, when using --enableReactLive issue fixed.
97
99
 
98
- **Feature Update**
99
-
100
+ **Feature Update**
100
101
  - Support for desk-library to use Selector Replace plugin using individual script. To use `react-cli selectorReplacer [source] [target]`
101
102
 
102
103
  # 1.1.0
103
104
 
104
105
  **Feature Update**
105
-
106
106
  - Support for desk-library to use variable convertion plugin using individual script. To use `react-cli variableConverter [source] [target]`
107
107
  - pattern filter changes, new filter system instead of exclude to include or exclude files for plugins.
108
- For more info please refer to :
109
- [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/2.0.0/docs/patternFiltering.md)
108
+ For more info please refer to :
109
+ [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/2.0.0/docs/patternFiltering.md)
110
110
  - React Live feature implemented for Docs.
111
- [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/2.0.0/docs/ReactLive.md)
111
+ [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/2.0.0/docs/ReactLive.md)
112
112
 
113
113
  # 1.0.3-beta.1
114
114
 
115
115
  **Issue Fix**
116
-
117
116
  - nock api not working issue fixed. This error throwing in @zohodesk/react-cli@1.0.2 version. but working in older versions ( 0.0.1-beta.178 )
118
117
 
118
+
119
119
  # 1.0.3
120
120
 
121
121
  **Feature Update**
122
-
123
122
  - Support for global httpsCerts usage
124
123
  - Support for global client_packages_group usage
125
- - custom attribute for dynamically loading chunks, In this version we merged changes from [0.0.1-beta.167.1](#0.0.1-beta.167.1).
126
- **Package Update**
127
- - @zohodesk/client_packages_group@**1.0.1** ==> @zohodesk/client_packages_group@**1.0.2**
124
+ - custom attribute for dynamically loading chunks, In this version we merged changes from [0.0.1-beta.167.1](#0.0.1-beta.167.1).
125
+ **Package Update**
126
+ - @zohodesk/client_packages_group@**1.0.1** ==> @zohodesk/client_packages_group@**1.0.2**
127
+
128
+
128
129
 
129
130
  # 1.0.2
130
131
 
131
132
  **Feature Update**
132
-
133
133
  - Selector replace plugin made as a custom postcss-plugin with update to code that was unpublished in package.
134
134
 
135
135
  # 1.0.1
136
136
 
137
137
  **Issue Fix**
138
-
139
138
  - variable conversion for px and var(--) values in same declaration was not supported, now it is supported.
140
139
  - package-lock.json removed from `.npmignore`
141
140
 
142
141
  **Feature Update**
143
-
144
142
  - exclude added to Selector Plugin
145
-
146
143
  # 1.0.0
147
-
148
144
  ## Major Release
149
-
150
145
  **Changes:**
151
-
152
146
  - File support added for `.webp` for `docs`, `dev` and `prod` mode
153
147
  - File support added for `.webm` for `docs`, `dev` and `prod` mode
154
148
 
@@ -156,11 +150,12 @@ Now to run app
156
150
 
157
151
  - We have remove ssl certificate for security reasons.
158
152
  So default https server won't run.
159
- In order to make it work as before you need to specify two things
153
+ In order to make it work as before you need to specify two things
160
154
  1. install `@zohodesk-private/client_dev_cert`
161
- 2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
162
- unless configaration are proper this may break `start` , `docs` , `nowatchstart`. and mock wms `/wmsmockapi` won't work.
163
- So Please be carefull when you update this version or above without proper configaration.
155
+ 2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
156
+ unless configaration are proper this may break `start` , `docs` , `nowatchstart`. and mock wms `/wmsmockapi` won't work.
157
+ So Please be carefull when you update this version or above without proper configaration.
158
+
164
159
 
165
160
  # 0.0.1-beta.178
166
161
 
@@ -173,11 +168,11 @@ Now to run app
173
168
 
174
169
  - We have remove ssl certificate for security reasons.
175
170
  So default https server won't run.
176
- In order to make it work as before you need to specify two things
171
+ In order to make it work as before you need to specify two things
177
172
  1. install `@zohodesk-private/client_dev_cert`
178
- 2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
179
- unless configaration are proper this may break `start` , `docs` , `nowatchstart`.
180
- So Please be carefull when you update this version or above without proper configaration.
173
+ 2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
174
+ unless configaration are proper this may break `start` , `docs` , `nowatchstart`.
175
+ So Please be carefull when you update this version or above without proper configaration.
181
176
 
182
177
  # 0.0.1-exp.178.2
183
178
 
@@ -191,11 +186,11 @@ Now to run app
191
186
 
192
187
  - We have remove ssl certificate for security reasons.
193
188
  So default https server won't run.
194
- In order to make it work as before you need to specify two things
189
+ In order to make it work as before you need to specify two things
195
190
  1. install `@zohodesk-private/client_dev_cert`
196
- 2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
197
- unless configaration are proper this may break `start` , `docs` , `nowatchstart`.
198
- So Please be carefull when you update this version or above without proper configaration.
191
+ 2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
192
+ unless configaration are proper this may break `start` , `docs` , `nowatchstart`.
193
+ So Please be carefull when you update this version or above without proper configaration.
199
194
 
200
195
  # 0.0.1-beta.177
201
196
 
@@ -353,9 +348,8 @@ Features:-
353
348
  - In docs we have added `Description` for Component Props- check out it in `PropTypes` tab
354
349
 
355
350
  # 0.0.1-beta.167.1
356
-
357
351
  In this version we merged changes from [0.0.1-betaa.138.1](#0.0.1-betaa.138.1).
358
- and with [0.0.1-beta.167](#0.0.1-beta.167) version changes.
352
+ and with [0.0.1-beta.167](#0.0.1-beta.167) version changes.
359
353
 
360
354
  # 0.0.1-beta.167
361
355
 
@@ -619,7 +613,6 @@ impact servise related changes:-
619
613
  - few enhancements
620
614
 
621
615
  # 0.0.1-betaa.138.1
622
-
623
616
  - new feature added for custom extra attribute for dynamically added tags by webpack.
624
617
  - To enable this feature you need to enable "react-cli" => "app" => "customAttributes" => "enable"
625
618
  - For more [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/9eea8df14e55584b2114b5e484ca8b751a4ba191/src/plugins/CustomAttributePlugin.md)
@@ -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` regex pattern as string
8
- - `name` chunk name
9
- - `size` is count which is minmum chunk dublicated or need in chunks
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
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 alies of `size` default value is `2`,
17
- - `rules`: `rules` is same as `pattern` with some easy hooks
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)**
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
- includeDepenency: includeDepenency default value is false
26
+ includeDependency: includeDependency default value is false
@@ -15,35 +15,52 @@ var _testPattern = require("./testPattern");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- let isWindows = _os.default.platform().toLowerCase() === 'win32';
19
- let ps = _path.default.sep;
20
- let options = (0, _utils.getOptions)();
21
- let {
18
+ const isWindows = _os.default.platform().toLowerCase() === 'win32';
19
+ const ps = _path.default.sep;
20
+ const options = (0, _utils.getOptions)();
21
+ const {
22
22
  app: {
23
23
  vendorExclude,
24
24
  customChunks,
25
- vendorInclude
25
+ vendorInclude,
26
+ customChunksBaseConfig
26
27
  }
27
28
  } = 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))];
28
31
 
29
- let isVendor = function isVendor(module) {
30
- let {
32
+ const isVendor = function isVendor(module) {
33
+ const {
31
34
  userRequest
32
35
  } = 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
+ return userRequest && (vendorInclude.some(item => userRequest.indexOf(item) !== -1) || userRequest.indexOf('node_modules') >= 0 && userRequest.endsWith('.css') === false && userRequest.endsWith('publicPathConfig.js') === false && vendorExcludelist.every(item => userRequest.indexOf(`node_modules${ps}${item}${ps}`) === -1));
36
37
  };
37
38
 
38
- let isReact = module => {
39
- let {
39
+ const isReact = module => {
40
+ const {
40
41
  userRequest
41
42
  } = module;
42
- let reactBundle = ['react', 'react-dom'];
43
- return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
43
+ return userRequest && reactBundleIncludeList.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
44
44
  };
45
45
 
46
- let defaultChunks = {
46
+ function rulesMatcher(pattern) {
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 = {
47
64
  'react.vendor': {
48
65
  name: 'react.vendor',
49
66
  chunks: 'all',
@@ -63,45 +80,37 @@ let defaultChunks = {
63
80
  priority: -10
64
81
  }
65
82
  };
66
- let customChunksConfig = {};
83
+ const customChunksConfig = {};
67
84
  customChunks.map((obj, index) => ({
68
85
  name: obj.name,
69
- pattern: obj.pattern,
86
+ chunks: obj.chunks || 'all',
70
87
  minChunks: obj.minChunks || obj.size || 2,
71
- rules: obj.rules,
72
- // includeDepenency: obj.includeDepenency || false,
88
+ pattern: obj.pattern,
73
89
  priority: obj.priority || -10 * (index + 2),
74
- enforce: obj.enforce || true,
75
- maxSize: obj.maxSize,
76
- // || 0,
90
+ enforce: obj.enforce,
77
91
  minSize: obj.minSize,
78
92
  // || 20000,
79
- chunks: obj.chunks || 'all'
80
- })).map(({
93
+ maxSize: obj.maxSize,
94
+ // || 0,
95
+ reuseExistingChunk: obj.reuseExistingChunk,
96
+ automaticNamePrefix: obj.automaticNamePrefix || '',
97
+ cacheGroupName: obj.cacheGroupName || obj.name
98
+ })).forEach(({
81
99
  name,
82
- pattern,
100
+ chunks = 'all',
83
101
  minChunks,
84
- rules,
102
+ pattern,
85
103
  priority,
86
- // includeDepenency,
87
104
  enforce,
88
105
  minSize,
89
106
  maxSize,
90
- chunks = 'all'
107
+ reuseExistingChunk,
108
+ automaticNamePrefix,
109
+ cacheGroupName
91
110
  }) => {
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),
111
+ const obj = {
112
+ test: rulesMatcher(pattern),
103
113
  chunks,
104
- enforce,
105
114
  minChunks,
106
115
  priority
107
116
  };
@@ -114,13 +123,30 @@ customChunks.map((obj, index) => ({
114
123
  obj.maxSize = maxSize;
115
124
  }
116
125
 
117
- return customChunksConfig[name] = obj;
126
+ if (enforce !== false) {
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;
118
143
  });
119
- var _default = {
120
- minSize: 12000,
144
+ const splitChunkConfig = Object.assign({}, baseSplitChunkConfig, {
121
145
  cacheGroups: Object.assign({
122
146
  default: false,
123
147
  vendors: false
124
- }, defaultChunks, customChunksConfig)
125
- };
148
+ }, specificCacheGroupConfig, customChunksConfig)
149
+ });
150
+ console.log('split chunks', splitChunkConfig);
151
+ var _default = splitChunkConfig;
126
152
  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 modifyedPattern = pattern;
16
+ let modifiedPattern = pattern;
17
17
 
18
- if (/[*.$^]/.test(modifyedPattern)) {
18
+ if (/[*.$^]/.test(modifiedPattern)) {
19
19
  if (isWindows) {
20
- // modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
21
- modifyedPattern = modifyedPattern.replace(/\//g, '\\\\');
20
+ // modifiedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
21
+ modifiedPattern = modifiedPattern.replace(/\//g, '\\\\');
22
22
  }
23
23
 
24
- modifyedPattern = modifyedPattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
25
- const re = new RegExp(modifyedPattern);
24
+ modifiedPattern = modifiedPattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
25
+ const re = new RegExp(modifiedPattern);
26
26
  return re.test(req);
27
27
  }
28
28
 
29
29
  if (isWindows) {
30
- // modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
31
- modifyedPattern = modifyedPattern.replace(/\//g, '\\');
30
+ // modifiedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
31
+ modifiedPattern = modifiedPattern.replace(/\//g, '\\');
32
32
  }
33
33
 
34
- return req.indexOf(modifyedPattern) !== -1;
34
+ return req.indexOf(modifiedPattern) !== -1;
35
35
  }
36
36
 
37
37
  function testPattern(req, pattern) {
@@ -34,8 +34,7 @@ function moduleResolver(options) {
34
34
  const nodeModulesPath = required ? required.nodeModulesPath : _client_packages_group.nodeModulesPath;
35
35
  return {
36
36
  modules: [nodeModulesPath, _constants.cliNodeModulesPath, 'node_modules'].filter(Boolean),
37
- alias: disableES5Transpile ? _libAlias.libAlias : {},
38
- extensions: ['.tsx', '.ts', '.js'] // alias: { ...libAlias, ...clientDependenies }
37
+ alias: disableES5Transpile ? _libAlias.libAlias : {} // alias: { ...libAlias, ...clientDependenies }
39
38
 
40
39
  };
41
40
  }
@@ -97,10 +97,6 @@ module.exports = {
97
97
 
98
98
  return false;
99
99
  }
100
- }, {
101
- test: /\.tsx?$/,
102
- use: 'ts-loader',
103
- exclude: /node_modules/
104
100
  }, seperateCssModules ? {
105
101
  test: /\.css$/,
106
102
  exclude: /\.module\.css$/,
@@ -148,10 +148,6 @@ module.exports = {
148
148
 
149
149
  return false;
150
150
  }
151
- }, {
152
- test: /\.tsx?$/,
153
- use: 'ts-loader',
154
- exclude: /node_modules/
155
151
  }, seperateCssModules ? {
156
152
  test: /\.css$/,
157
153
  exclude: /\.module\.css$/,
@@ -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 = false;
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}.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);`]), '};',
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}.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];',
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
  ]), '}']), '};']);
@@ -333,6 +333,7 @@ var _default = {
333
333
  inject: true
334
334
  },
335
335
  removePropTypes: false,
336
+ customChunksBaseConfig: null,
336
337
  customChunks: [{
337
338
  name: 'styles',
338
339
  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 = _interopRequireDefault(require("fs"));
10
+ var _fs = _interopRequireWildcard(require("fs"));
11
11
 
12
12
  var _path = _interopRequireDefault(require("path"));
13
13
 
@@ -15,6 +15,10 @@ 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
+
18
22
  // import { argv } from 'process';
19
23
  const args = process.argv.slice(2); // console.log('argv', argv);
20
24
 
@@ -183,8 +187,9 @@ function deprecationSupport(options) {
183
187
  Object.keys(options.app.patterns).forEach(key => {
184
188
  if (options.app.exclude[key] && options.app.patterns[key].length === 0) {
185
189
  let tempArr = options.app.exclude[key];
186
- tempArr = tempArr.map(x => {
187
- x = x.replace(/\//gi, _path.default.sep);
190
+ tempArr = tempArr.map(_x => {
191
+ const x = _x.replace(/\//gi, _path.default.sep);
192
+
188
193
  return `!**${x[0] === _path.default.sep || x[0] === '@' ? '' : _path.default.sep}${x}${x[x.length - 1] === _path.default.sep ? '' : _path.default.sep}**`;
189
194
  });
190
195
  options.app.patterns[key] = tempArr;
@@ -193,8 +198,9 @@ function deprecationSupport(options) {
193
198
  Object.keys(options.docs.patterns).forEach(key => {
194
199
  if (options.docs.exclude[key] && options.docs.patterns[key].length === 0) {
195
200
  let tempArr = options.docs.exclude[key];
196
- tempArr = tempArr.map(x => {
197
- x = x.replace(/\//gi, _path.default.sep);
201
+ tempArr = tempArr.map(_x => {
202
+ const x = _x.replace(/\//gi, _path.default.sep);
203
+
198
204
  return `!**${x[0] === _path.default.sep || x[0] === '@' ? '' : _path.default.sep}${x}${x[x.length - 1] === _path.default.sep ? '' : _path.default.sep}**`;
199
205
  });
200
206
  options.docs.patterns[key] = tempArr;
@@ -202,18 +208,30 @@ function deprecationSupport(options) {
202
208
  });
203
209
  }
204
210
 
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
+
205
223
  const getOptions = () => {
206
224
  if (global.reactCLIOptions) {
207
225
  return global.reactCLIOptions;
208
226
  }
209
227
 
210
228
  const appPath = process.cwd();
211
- let userSchemas;
229
+ let userSchemas = getOptionsFromConfigFile(appPath, processEnv.config_file);
212
230
 
213
231
  const packagePath = _path.default.join(appPath, 'package.json');
214
232
 
215
233
  if (_fs.default.existsSync(packagePath)) {
216
- userSchemas = require(packagePath)['react-cli'] || {};
234
+ userSchemas = userSchemas || require(packagePath)['react-cli'] || {};
217
235
  }
218
236
 
219
237
  const options = defaulter(_schemas.default, userSchemas || {}); // for future may be for npm 8 edge cases