@zohodesk/react-cli 1.1.19-exp.16 → 1.1.19-exp.18

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -44,6 +44,18 @@ Now to run app
44
44
 
45
45
  # Change Logs
46
46
 
47
+ # 1.1.19-exp.18
48
+
49
+ **Changes**
50
+
51
+ - To do further build size optimization by utilizing webpack provided config.
52
+
53
+ ```
54
+ innerGraph: true,
55
+ usedExports: true,
56
+ sideEffects: true
57
+ ```
58
+
47
59
  # 1.1.19 (5-2-2024)
48
60
 
49
61
  **Feature:-**
@@ -102,7 +102,10 @@ module.exports = {
102
102
  // exclude: /\/smap/
103
103
  // })
104
104
  // ],
105
- moduleIds: 'named'
105
+ moduleIds: 'named',
106
+ usedExports: true,
107
+ innerGraph: true,
108
+ sideEffects: true
106
109
  },
107
110
  stats: {
108
111
  children: false,
@@ -19,32 +19,32 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
19
19
  /* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
20
20
  import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
21
21
  const schema = {
22
- 'type': 'object',
23
- 'properties': {
24
- 'publicPath': {
25
- 'anyOf': [{
26
- 'type': 'string'
22
+ type: 'object',
23
+ properties: {
24
+ publicPath: {
25
+ anyOf: [{
26
+ type: 'string'
27
27
  }, {
28
- 'instanceof': 'Function'
28
+ instanceof: 'Function'
29
29
  }]
30
30
  },
31
- 'filename': {
32
- 'anyOf': [{
33
- 'type': 'string',
34
- 'minLength': 1
31
+ filename: {
32
+ anyOf: [{
33
+ type: 'string',
34
+ minLength: 1
35
35
  }, {
36
- 'instanceof': 'Function'
36
+ instanceof: 'Function'
37
37
  }]
38
38
  },
39
- 'chunkFilename': {
40
- 'type': 'string',
41
- 'minLength': 1
39
+ chunkFilename: {
40
+ type: 'string',
41
+ minLength: 1
42
42
  },
43
- 'esModule': {
44
- 'type': 'boolean'
43
+ esModule: {
44
+ type: 'boolean'
45
45
  }
46
46
  },
47
- 'additionalProperties': false
47
+ additionalProperties: false
48
48
  }; // eslint-disable-next-line
49
49
 
50
50
  function loader() {}
@@ -112,25 +112,40 @@ function pitch(request) {
112
112
  }
113
113
 
114
114
  function workerCode() {
115
+ if (this.workerInstance) {
116
+ return this.workerInstance;
117
+ }
118
+
115
119
  let blob;
116
120
 
117
121
  try {
118
122
  blob = new Blob([`importScripts('${this.workerUrl}');`], {
119
- 'type': 'application/javascript'
123
+ type: 'application/javascript'
120
124
  });
121
125
  } catch (e1) {
122
126
  throw new Error(e1);
123
127
  }
124
128
 
125
- let url = window.URL || window.webkitURL;
126
- let blobUrl = url.createObjectURL(blob);
127
- let worker = new Worker(blobUrl);
128
- return worker;
129
+ const url = window.URL || window.webkitURL;
130
+ const blobUrl = url.createObjectURL(blob);
131
+ this.workerInstance = new Worker(blobUrl);
132
+ return this.workerInstance;
129
133
  }
130
134
 
131
- return cb(null, `${options.esModule ? 'export default' : 'module.exports ='} {\n
135
+ return cb(null, `const workerObj ={\n
136
+ workerInstance: null, \n
132
137
  workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
133
138
  getInstance: ${workerCode} \n
134
- }`);
139
+ };\n
140
+ workerObj.getInstance();
141
+ ${options.esModule ? 'export default' : 'module.exports ='} workerObj;
142
+ `); // return cb(
143
+ // null,
144
+ // `${options.esModule ? 'export default' : 'module.exports ='} {\n
145
+ // workerInstance: null, \n
146
+ // workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
147
+ // getInstance: ${workerCode} \n
148
+ // }`
149
+ // );
135
150
  });
136
151
  }
@@ -26,6 +26,12 @@ const defaultHTMLMiniFyOption = {
26
26
  removeStyleLinkTypeAttributes: true,
27
27
  useShortDoctype: true
28
28
  };
29
+ const defaultScriptLoadingStrategy = 'defer';
30
+
31
+ function getScriptLoadingStrategy(scriptLoadingStategey) {
32
+ const allowedScriptLoadingStrategies = ['blocking', 'defer'];
33
+ return allowedScriptLoadingStrategies.includes(scriptLoadingStategey) ? scriptLoadingStategey : defaultScriptLoadingStrategy;
34
+ }
29
35
 
30
36
  function configHtmlWebpackPlugins(plugins, {
31
37
  enableChunkHash = false,
@@ -33,7 +39,8 @@ function configHtmlWebpackPlugins(plugins, {
33
39
  inject,
34
40
  crossorigin,
35
41
  hasEFC,
36
- minify: minifyHtmlOptions = false
42
+ minify: minifyHtmlOptions = false,
43
+ scriptLoadingStrategey
37
44
  }) {
38
45
  const optionsHtmlWebpack = {
39
46
  chunksSortMode: 'none',
@@ -44,7 +51,7 @@ function configHtmlWebpackPlugins(plugins, {
44
51
  // ? minifyHtmlOptions
45
52
  // : minifyHtmlOptions,,
46
53
  templateParameters: _common.templateParameters,
47
- scriptLoading: 'defer',
54
+ scriptLoading: getScriptLoadingStrategy(scriptLoadingStrategey),
48
55
  inject: inject
49
56
  };
50
57
 
@@ -60,7 +60,8 @@ const getDevPlugins = (options, publicPath) => {
60
60
  mode
61
61
  },
62
62
  htmlTemplate: {
63
- inject
63
+ inject,
64
+ scriptLoadingStrategey
64
65
  },
65
66
  crossorigin
66
67
  },
@@ -166,7 +167,8 @@ const getDevPlugins = (options, publicPath) => {
166
167
  minify: false,
167
168
  inject,
168
169
  crossorigin,
169
- hasEFC
170
+ hasEFC,
171
+ scriptLoadingStrategey
170
172
  });
171
173
 
172
174
  if (hasEFC) {
@@ -78,7 +78,8 @@ const getProdPlugins = (options, publicPath = '') => {
78
78
  } = options.app;
79
79
  const {
80
80
  inject,
81
- minify: minifyHtmlOptions
81
+ minify: minifyHtmlOptions,
82
+ scriptLoadingStrategey
82
83
  } = htmlTemplate;
83
84
  const {
84
85
  i18n
@@ -176,6 +177,7 @@ const getProdPlugins = (options, publicPath = '') => {
176
177
  folder,
177
178
  inject,
178
179
  minify: minifyHtmlOptions,
180
+ scriptLoadingStrategey,
179
181
  crossorigin,
180
182
  hasEFC
181
183
  });
@@ -322,7 +322,8 @@ var _default = {
322
322
  },
323
323
  htmlTemplate: {
324
324
  minify: null,
325
- inject: true
325
+ inject: true,
326
+ scriptLoadingStrategey: ''
326
327
  },
327
328
  removePropTypes: false,
328
329
  customChunksBaseConfig: null,
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "1.1.18-exp.1",
3
+ "version": "1.1.19-exp.18",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@zohodesk/react-cli",
9
- "version": "1.1.18-exp.1",
9
+ "version": "1.1.19-exp.18",
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.19-exp.16",
3
+ "version": "1.1.19-exp.18",
4
4
  "description": "A CLI tool for build modern web application and libraries",
5
5
  "scripts": {
6
6
  "init": "node ./lib/utils/init.js",