@zohodesk/react-cli 1.1.19-exp.16 → 1.1.19-exp.18
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 +12 -0
- package/lib/configs/webpack.prod.config.js +4 -1
- package/lib/loaders/workerLoader.js +39 -24
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -2
- package/lib/pluginUtils/getDevPlugins.js +4 -2
- package/lib/pluginUtils/getProdPlugins.js +3 -1
- package/lib/schemas/index.js +2 -1
- package/npm-shrinkwrap.json +2 -2
- 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
|
+
# 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:-**
|
@@ -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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
type: 'object',
|
23
|
+
properties: {
|
24
|
+
publicPath: {
|
25
|
+
anyOf: [{
|
26
|
+
type: 'string'
|
27
27
|
}, {
|
28
|
-
|
28
|
+
instanceof: 'Function'
|
29
29
|
}]
|
30
30
|
},
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
filename: {
|
32
|
+
anyOf: [{
|
33
|
+
type: 'string',
|
34
|
+
minLength: 1
|
35
35
|
}, {
|
36
|
-
|
36
|
+
instanceof: 'Function'
|
37
37
|
}]
|
38
38
|
},
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
chunkFilename: {
|
40
|
+
type: 'string',
|
41
|
+
minLength: 1
|
42
42
|
},
|
43
|
-
|
44
|
-
|
43
|
+
esModule: {
|
44
|
+
type: 'boolean'
|
45
45
|
}
|
46
46
|
},
|
47
|
-
|
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
|
-
|
123
|
+
type: 'application/javascript'
|
120
124
|
});
|
121
125
|
} catch (e1) {
|
122
126
|
throw new Error(e1);
|
123
127
|
}
|
124
128
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
return
|
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,
|
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:
|
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
|
});
|
package/lib/schemas/index.js
CHANGED
package/npm-shrinkwrap.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zohodesk/react-cli",
|
3
|
-
"version": "1.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.
|
9
|
+
"version": "1.1.19-exp.18",
|
10
10
|
"license": "ISC",
|
11
11
|
"dependencies": {
|
12
12
|
"@babel/cli": "7.10.5",
|