@zohodesk/react-cli 1.1.19-exp.9 → 1.1.20-exp.1
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 +28 -0
- package/bin/cli.js +0 -4
- package/docs/ReactLive.md +5 -1
- package/lib/babel/cmjs-plugins-presets.js +6 -11
- package/lib/babel/es-plugins-presets.js +6 -12
- package/lib/configs/jest.config.js +2 -2
- package/lib/configs/webpack.dev.config.js +0 -4
- package/lib/configs/webpack.prod.config.js +5 -6
- package/lib/loaderUtils/getDevJsLoaders.js +1 -1
- package/lib/loaders/docsLoader.js +2 -2
- package/lib/loaders/enhancedReactLiveConverter.js +151 -0
- package/lib/loaders/workerLoader.js +39 -24
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +59 -1
- package/lib/pluginUtils/getDevPlugins.js +9 -4
- package/lib/pluginUtils/getProdPlugins.js +7 -2
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +111 -0
- package/lib/plugins/EventsHandlingPlugin.js +36 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +5 -1
- package/lib/schemas/index.js +2 -4
- package/lib/utils/index.js +14 -0
- package/lib/utils/typeCheck.js +10 -0
- package/npm-shrinkwrap.json +19073 -432
- package/package.json +1 -6
@@ -0,0 +1,111 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
const pluginName = 'CustomScriptLoadingStrategyPlugin';
|
13
|
+
|
14
|
+
class CustomScriptLoadingStrategyPlugin {
|
15
|
+
constructor({
|
16
|
+
scriptLoadingStategey
|
17
|
+
} = {}) {
|
18
|
+
this.scriptLoadingStrategy = scriptLoadingStategey;
|
19
|
+
}
|
20
|
+
|
21
|
+
getFileNameFromTagSrc(src) {
|
22
|
+
const fileNameArr = src.split('/');
|
23
|
+
return fileNameArr[fileNameArr.length - 1];
|
24
|
+
}
|
25
|
+
|
26
|
+
addAttributestToTag(tag, attributes) {
|
27
|
+
tag.attributes = Object.assign({}, tag.attributes, attributes);
|
28
|
+
}
|
29
|
+
|
30
|
+
matchFileName(tag, fileName) {
|
31
|
+
return fileName.test(this.getFileNameFromTagSrc(tag.attributes.src));
|
32
|
+
}
|
33
|
+
|
34
|
+
blockingStrategy(tag) {
|
35
|
+
delete tag.attributes.defer;
|
36
|
+
delete tag.attributes.async;
|
37
|
+
}
|
38
|
+
|
39
|
+
deferStrategy(tag) {
|
40
|
+
delete tag.attributes.async;
|
41
|
+
}
|
42
|
+
|
43
|
+
asyncStrategy(tag) {
|
44
|
+
delete tag.attributes.defer;
|
45
|
+
}
|
46
|
+
|
47
|
+
moduleStrategy(tag) {
|
48
|
+
this.deferStrategy(tag);
|
49
|
+
}
|
50
|
+
|
51
|
+
matchStrategy(scriptLoadingStrategy, tag) {
|
52
|
+
if (scriptLoadingStrategy === 'blocking') {
|
53
|
+
this.blockingStrategy(tag);
|
54
|
+
}
|
55
|
+
|
56
|
+
if (scriptLoadingStrategy === 'defer') {
|
57
|
+
this.deferStrategy(tag);
|
58
|
+
}
|
59
|
+
|
60
|
+
if (scriptLoadingStrategy === 'async') {
|
61
|
+
this.asyncStrategy(tag);
|
62
|
+
}
|
63
|
+
|
64
|
+
if (scriptLoadingStrategy === 'module') {
|
65
|
+
this.moduleStrategy(tag);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
matchAndApplyCustomLoadingStrategyToScripts(tags) {
|
70
|
+
Object.keys(this.scriptLoadingStrategy).forEach(scriptLoadingStrategy => {
|
71
|
+
console.log('sc', scriptLoadingStrategy);
|
72
|
+
const filesToMatch = this.scriptLoadingStrategy[scriptLoadingStrategy];
|
73
|
+
tags.forEach(tag => {
|
74
|
+
if (tag.attributes.src) {
|
75
|
+
const isFileMatch = filesToMatch.some(fileName => this.matchFileName(tag, fileName));
|
76
|
+
|
77
|
+
if (isFileMatch) {
|
78
|
+
this.matchStrategy(scriptLoadingStrategy, tag);
|
79
|
+
this.addAttributestToTag(tag, {
|
80
|
+
[scriptLoadingStrategy]: true
|
81
|
+
});
|
82
|
+
}
|
83
|
+
} // filesToMatch.forEach(fileName => {
|
84
|
+
// if (!this.matchFileName(tag, fileName)) {
|
85
|
+
// return;
|
86
|
+
// }
|
87
|
+
// this.matchStrategy(scriptLoadingStrategy, tag);
|
88
|
+
// this.addAttributestToTag(tag, fileName, {
|
89
|
+
// [scriptLoadingStrategy]: true
|
90
|
+
// });
|
91
|
+
// });
|
92
|
+
|
93
|
+
});
|
94
|
+
});
|
95
|
+
}
|
96
|
+
|
97
|
+
apply(compiler) {
|
98
|
+
compiler.hooks.compilation.tap(pluginName, compilation => {
|
99
|
+
_htmlWebpackPlugin.default.getHooks(compilation).alterAssetTagGroups.tapAsync(pluginName, (data, callback) => {
|
100
|
+
const tags = [...data.bodyTags, ...data.headTags];
|
101
|
+
console.log('tags', tags);
|
102
|
+
this.matchAndApplyCustomLoadingStrategyToScripts(tags);
|
103
|
+
console.log('tags after', tags);
|
104
|
+
callback(null, data);
|
105
|
+
});
|
106
|
+
});
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
exports.default = CustomScriptLoadingStrategyPlugin;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.EventsHandlingPlugin = void 0;
|
7
|
+
|
8
|
+
/* eslint-disable no-use-before-define */
|
9
|
+
class EventsHandlingPlugin {
|
10
|
+
constructor(options) {}
|
11
|
+
|
12
|
+
apply(compiler) {
|
13
|
+
console.log("hi"); // NOTE: we not using this, Reason currently this option is only need for EFC,
|
14
|
+
// So it do not needed.
|
15
|
+
|
16
|
+
compiler.hooks.thisCompilation.tap({
|
17
|
+
name: 'CustomAttributePlugin',
|
18
|
+
stage: 1,
|
19
|
+
fn: compilation => {
|
20
|
+
compilation.mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
|
21
|
+
// const str = attributeSetTemplate(cssAttributes, 'linkTag');
|
22
|
+
const replacesourcedStr = source.replace('linkTag.onerror = function(event) {', 'linkTag.onerror = function(event) { linkTag.onerror = linkTag.onload = null');
|
23
|
+
const re = replacesourcedStr.replace('linkTag.onload = resolve', `linkTag.onload = () => {
|
24
|
+
linkTag.onerror = linkTag.onload = null;
|
25
|
+
resolve();
|
26
|
+
};`); // console.log({ s: source, r: replacedStr });
|
27
|
+
|
28
|
+
return re;
|
29
|
+
});
|
30
|
+
}
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
}
|
35
|
+
|
36
|
+
exports.EventsHandlingPlugin = EventsHandlingPlugin;
|
@@ -228,8 +228,12 @@ class I18nDownlodLogic {
|
|
228
228
|
if(dataSrc === srcPath || dataSrc === fullsrcPath){ return resolve();}
|
229
229
|
}
|
230
230
|
var scriptTag = document.createElement("script");
|
231
|
-
scriptTag.onload =
|
231
|
+
scriptTag.onload = () => {
|
232
|
+
scriptTag.onerror = scriptTag.onload = null;
|
233
|
+
resolve();
|
234
|
+
};
|
232
235
|
scriptTag.onerror = function(event) {
|
236
|
+
scriptTag.onerror = scriptTag.onload = null;
|
233
237
|
var request = event && event.target && event.target.src || fullsrcPath;
|
234
238
|
var err = new Error("Loading I18N chunk " + chunkId + " failed.\\n(" + request + ")");
|
235
239
|
err.code = "I18N_CHUNK_LOAD_FAILED";
|
package/lib/schemas/index.js
CHANGED
@@ -322,7 +322,8 @@ var _default = {
|
|
322
322
|
},
|
323
323
|
htmlTemplate: {
|
324
324
|
minify: null,
|
325
|
-
inject: true
|
325
|
+
inject: true,
|
326
|
+
customScriptLoadingStrategey: null
|
326
327
|
},
|
327
328
|
removePropTypes: false,
|
328
329
|
customChunksBaseConfig: null,
|
@@ -738,9 +739,6 @@ var _default = {
|
|
738
739
|
fileName: null,
|
739
740
|
options: null,
|
740
741
|
excludeKeys: null
|
741
|
-
},
|
742
|
-
babelCustomizationForLibrary: {
|
743
|
-
babelPlugins: []
|
744
742
|
}
|
745
743
|
};
|
746
744
|
exports.default = _default;
|
package/lib/utils/index.js
CHANGED
@@ -167,6 +167,20 @@ var _getComponents = _interopRequireDefault(require("./getComponents"));
|
|
167
167
|
|
168
168
|
var _ssTestHack = _interopRequireDefault(require("./ssTestHack"));
|
169
169
|
|
170
|
+
var _typeCheck = require("./typeCheck");
|
171
|
+
|
172
|
+
Object.keys(_typeCheck).forEach(function (key) {
|
173
|
+
if (key === "default" || key === "__esModule") return;
|
174
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
175
|
+
if (key in exports && exports[key] === _typeCheck[key]) return;
|
176
|
+
Object.defineProperty(exports, key, {
|
177
|
+
enumerable: true,
|
178
|
+
get: function () {
|
179
|
+
return _typeCheck[key];
|
180
|
+
}
|
181
|
+
});
|
182
|
+
});
|
183
|
+
|
170
184
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
171
185
|
|
172
186
|
// eslint-disable-next-line no-duplicate-imports
|