@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +183 -183
- package/CHANGELOG.md +5 -0
- package/README.md +636 -491
- package/bin/cli.js +372 -367
- package/files/eslintrc.js +57 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +16 -9
- package/lib/babel/es-plugins-presets.js +26 -14
- package/lib/common/getEntries.js +31 -22
- package/lib/common/getPublicPathConfig.js +27 -13
- package/lib/common/index.js +21 -25
- package/lib/common/splitChunks.js +62 -53
- package/lib/common/templateParameters.js +10 -8
- package/lib/configs/jest.config.js +15 -25
- package/lib/configs/webpack.component.umd.config.js +31 -37
- package/lib/configs/webpack.css.umd.config.js +44 -47
- package/lib/configs/webpack.dev.config.js +70 -52
- package/lib/configs/webpack.docs.config.js +106 -106
- package/lib/configs/webpack.prod.config.js +95 -75
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +103 -74
- package/lib/jest/coverageCollector.js +41 -21
- package/lib/jest/jsonMaker.js +15 -16
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +90 -45
- package/lib/jest/run.js +43 -43
- package/lib/jest/setup.js +102 -95
- package/lib/loaderUtils/getCSSLoaders.js +21 -22
- package/lib/loaderUtils/getDevJsLoaders.js +25 -23
- package/lib/loaderUtils/index.js +11 -13
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileLoader.js +33 -35
- package/lib/loaders/scriptInstrumentLoader.js +21 -20
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +54 -45
- package/lib/middlewares/SSTMiddleware.js +8 -5
- package/lib/pluginUtils/getDevPlugins.js +114 -52
- package/lib/pluginUtils/getDocsPlugins.js +25 -29
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +163 -74
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
- package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +63 -0
- package/lib/plugins/CleanupStatsPlugin.js +18 -32
- package/lib/plugins/CustomAttributePlugin.js +79 -0
- package/lib/plugins/CustomAttributePlugin.md +35 -0
- package/lib/plugins/EFCPlugin.js +185 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
- package/lib/plugins/I18nSplitPlugin/README.md +25 -0
- package/lib/plugins/I18nSplitPlugin/index.js +185 -0
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
- package/lib/plugins/ManifestPlugin.js +52 -63
- package/lib/plugins/ModuleStatsPlugin.js +83 -173
- package/lib/plugins/OptimizeJSPlugin.js +24 -41
- package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
- package/lib/plugins/PublicPathChangePlugin.js +175 -284
- package/lib/plugins/ReportGeneratePlugin.js +150 -151
- package/lib/plugins/ResourceHintsPlugin.js +53 -35
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +81 -57
- package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
- package/lib/plugins/SourceMapHookPlugin.js +21 -33
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +23 -30
- package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
- package/lib/plugins/index.js +100 -91
- package/lib/plugins/webpackwatchrunplugin.js +18 -30
- package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
- package/lib/schemas/index.js +336 -81
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +84 -91
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/impactServer.js +99 -92
- package/lib/servers/mockserver.js +24 -24
- package/lib/servers/scrServer.js +78 -98
- package/lib/servers/server.js +101 -122
- package/lib/servers/ssServer.js +63 -61
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -46
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +6 -4
- package/lib/utils/babelPresets.js +12 -5
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +12 -34
- package/lib/utils/copyTimezones.js +9 -16
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +44 -73
- package/lib/utils/cssURLReplacer.js +60 -54
- package/lib/utils/dependencyPostPublish.js +20 -19
- package/lib/utils/fileUtils.js +66 -54
- package/lib/utils/folderIterator.js +20 -21
- package/lib/utils/getComponents.js +70 -27
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +114 -187
- package/lib/utils/getHash.js +9 -13
- package/lib/utils/getIp.js +9 -9
- package/lib/utils/getOptions.js +26 -29
- package/lib/utils/getServerURL.js +19 -10
- package/lib/utils/index.js +147 -126
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +40 -32
- package/lib/utils/jsonHelper.js +37 -21
- package/lib/utils/lint/addScripts.js +27 -0
- package/lib/utils/lint/checkExistingConfig.js +67 -0
- package/lib/utils/lint/copyConfigs.js +24 -0
- package/lib/utils/lint/index.js +54 -0
- package/lib/utils/lint/lintScripts.js +11 -0
- package/lib/utils/lint/lintSetup.js +31 -0
- package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
- package/lib/utils/lint/question.js +30 -0
- package/lib/utils/lintReporter.js +70 -56
- package/lib/utils/mailSender.js +12 -27
- package/lib/utils/pullOrigin.js +21 -18
- package/lib/utils/reinstallDependencies.js +76 -85
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +47 -45
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +22 -29
- package/lib/utils/setEnvVariables.js +5 -6
- package/lib/utils/ssTestHack.js +21 -19
- package/lib/utils/switchBranch.js +21 -20
- package/lib/utils/urlConcat.js +22 -0
- package/package.json +141 -136
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/index.html +1493 -1493
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
@@ -1,182 +1,181 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
8
9
|
|
9
|
-
var
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
10
11
|
|
11
|
-
var
|
12
|
+
var _redis = _interopRequireDefault(require("redis"));
|
12
13
|
|
13
|
-
var
|
14
|
-
|
15
|
-
var _path = require('path');
|
16
|
-
|
17
|
-
var _path2 = _interopRequireDefault(_path);
|
18
|
-
|
19
|
-
var _redis = require('redis');
|
20
|
-
|
21
|
-
var _redis2 = _interopRequireDefault(_redis);
|
22
|
-
|
23
|
-
var _utils = require('../utils');
|
14
|
+
var _utils = require("../utils");
|
24
15
|
|
25
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
26
17
|
|
27
|
-
|
18
|
+
let options = (0, _utils.getOptions)();
|
19
|
+
let {
|
20
|
+
app: {
|
21
|
+
branch,
|
22
|
+
redisHost,
|
23
|
+
redisPort
|
24
|
+
}
|
25
|
+
} = options;
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
class reportGeneratePlugin {
|
28
|
+
apply(compiler) {
|
29
|
+
compiler.hooks.emit.tapAsync('reportGeneratePlugin', (compilation, callback) => {
|
30
|
+
function formatBytes(bytes) {
|
31
|
+
if (bytes) {
|
32
|
+
let isNegative;
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
_classCallCheck(this, reportGeneratePlugin);
|
38
|
-
}
|
34
|
+
if (bytes < 0) {
|
35
|
+
bytes = bytes * -1; //eslint-disable-line
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
var isNegative = void 0;
|
47
|
-
if (bytes < 0) {
|
48
|
-
bytes = bytes * -1; //eslint-disable-line
|
49
|
-
isNegative = true;
|
50
|
-
}
|
51
|
-
if (bytes < 1024) {
|
52
|
-
if (isNegative) {
|
53
|
-
return '- ' + bytes + ' Bytes';
|
54
|
-
}
|
55
|
-
return bytes + ' Bytes';
|
56
|
-
} else if (bytes < 1048576) {
|
57
|
-
if (isNegative) {
|
58
|
-
return '- ' + (bytes / 1024).toFixed(3) + ' KB';
|
59
|
-
}
|
60
|
-
return (bytes / 1024).toFixed(3) + ' KB';
|
61
|
-
} else if (bytes < 1073741824) {
|
62
|
-
if (isNegative) {
|
63
|
-
return '- ' + (bytes / 1048576).toFixed(3) + ' MB';
|
64
|
-
}
|
65
|
-
return (bytes / 1048576).toFixed(3) + ' MB';
|
37
|
+
isNegative = true;
|
38
|
+
}
|
39
|
+
|
40
|
+
if (bytes < 1024) {
|
41
|
+
if (isNegative) {
|
42
|
+
return `- ${bytes} Bytes`;
|
66
43
|
}
|
44
|
+
|
45
|
+
return `${bytes} Bytes`;
|
46
|
+
} else if (bytes < 1048576) {
|
67
47
|
if (isNegative) {
|
68
|
-
return
|
48
|
+
return `- ${(bytes / 1024).toFixed(3)} KB`;
|
69
49
|
}
|
70
|
-
return (bytes / 1073741824).toFixed(3) + ' GB';
|
71
|
-
}
|
72
|
-
}
|
73
50
|
|
74
|
-
|
51
|
+
return `${(bytes / 1024).toFixed(3)} KB`;
|
52
|
+
} else if (bytes < 1073741824) {
|
53
|
+
if (isNegative) {
|
54
|
+
return `- ${(bytes / 1048576).toFixed(3)} MB`;
|
55
|
+
}
|
75
56
|
|
76
|
-
|
77
|
-
|
78
|
-
});
|
57
|
+
return `${(bytes / 1048576).toFixed(3)} MB`;
|
58
|
+
}
|
79
59
|
|
80
|
-
|
81
|
-
|
82
|
-
|
60
|
+
if (isNegative) {
|
61
|
+
return `- ${(bytes / 1073741824).toFixed(3)} GB`;
|
62
|
+
}
|
83
63
|
|
84
|
-
|
85
|
-
|
64
|
+
return `${(bytes / 1073741824).toFixed(3)} GB`;
|
65
|
+
}
|
66
|
+
}
|
86
67
|
|
87
|
-
|
88
|
-
var finalObj = {};
|
68
|
+
let client = _redis.default.createClient(redisPort, redisHost);
|
89
69
|
|
90
|
-
|
70
|
+
client.on('connect', () => {
|
71
|
+
(0, _utils.log)('Redis client connected');
|
72
|
+
});
|
73
|
+
client.on('error', err => {
|
74
|
+
(0, _utils.log)(`Something went wrong ${err}`);
|
75
|
+
});
|
91
76
|
|
92
|
-
|
77
|
+
if (_fs.default.existsSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'))) {
|
78
|
+
let statsJSON = _fs.default.readFileSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'), 'utf8');
|
79
|
+
|
80
|
+
statsJSON = JSON.parse(statsJSON);
|
81
|
+
let finalObj = {};
|
82
|
+
let branchName = branch ? branch : (0, _utils.getCurrentBranch)();
|
83
|
+
(0, _utils.log)(branchName);
|
84
|
+
statsJSON.assets.forEach(assetObj => {
|
85
|
+
let nameSplitList = assetObj.name.split('/')[assetObj.name.split('/').length - 1].split('.'); // eslint-disable-line
|
86
|
+
|
87
|
+
let [, hash] = nameSplitList;
|
88
|
+
let name = `${nameSplitList[0]}.${nameSplitList[2]}`;
|
89
|
+
let {
|
90
|
+
size
|
91
|
+
} = assetObj;
|
92
|
+
let tempObject = {
|
93
|
+
name,
|
94
|
+
hash,
|
95
|
+
size
|
96
|
+
}; // eslint-disable-next-line
|
97
|
+
|
98
|
+
if (!finalObj.hasOwnProperty(name)) {
|
99
|
+
finalObj[name] = tempObject;
|
100
|
+
}
|
101
|
+
});
|
102
|
+
client.exists(branchName, (err, bool) => {
|
103
|
+
if (!bool) {
|
104
|
+
client.set(branchName, JSON.stringify(finalObj), _redis.default.print);
|
105
|
+
client.quit();
|
106
|
+
} else {
|
107
|
+
let reportObj = {
|
108
|
+
increased: [],
|
109
|
+
hashChanged: [],
|
110
|
+
branchName
|
111
|
+
};
|
112
|
+
client.get(branchName, (err, reply) => {
|
113
|
+
if (err) {
|
114
|
+
(0, _utils.log)(err);
|
115
|
+
} else {
|
116
|
+
reply = JSON.parse(reply); // eslint-disable-line
|
117
|
+
|
118
|
+
Object.keys(reply).forEach(fileName => {
|
119
|
+
// eslint-disable-next-line
|
120
|
+
if (finalObj.hasOwnProperty(fileName)) {
|
121
|
+
if (parseInt(reply[fileName].size) < parseInt(finalObj[fileName].size)) {
|
122
|
+
reportObj.increased.push({
|
123
|
+
name: fileName,
|
124
|
+
size: {
|
125
|
+
old: formatBytes(reply[fileName].size),
|
126
|
+
new: formatBytes(finalObj[fileName].size),
|
127
|
+
diff: formatBytes(parseInt(finalObj[fileName].size) - parseInt(reply[fileName].size))
|
128
|
+
}
|
129
|
+
});
|
130
|
+
}
|
93
131
|
|
94
|
-
|
95
|
-
|
132
|
+
if (reply[fileName].hash !== finalObj[fileName].hash) {
|
133
|
+
reportObj.hashChanged.push({
|
134
|
+
name: fileName,
|
135
|
+
hash: {
|
136
|
+
old: reply[fileName].hash,
|
137
|
+
new: finalObj[fileName].hash
|
138
|
+
}
|
139
|
+
});
|
140
|
+
}
|
141
|
+
}
|
142
|
+
});
|
143
|
+
let json = JSON.stringify(reportObj);
|
96
144
|
|
97
|
-
|
98
|
-
|
145
|
+
_fs.default.writeFile(_path.default.resolve(process.cwd(), 'build', 'buildtrack.js'), `let statsJson=${json}`, err => {
|
146
|
+
if (err) {
|
147
|
+
throw err;
|
148
|
+
}
|
99
149
|
|
100
|
-
|
101
|
-
|
150
|
+
(0, _utils.log)('Stats Json generated!');
|
151
|
+
});
|
152
|
+
}
|
153
|
+
});
|
154
|
+
client.set(branchName, JSON.stringify(finalObj), _redis.default.print); // fs.copyFileSync(
|
155
|
+
// path.resolve(
|
156
|
+
// process.cwd(),
|
157
|
+
// 'node_modules',
|
158
|
+
// '@zohodesk',
|
159
|
+
// 'react-cli',
|
160
|
+
// 'lib',
|
161
|
+
// 'utils',
|
162
|
+
// 'buildstats.html'
|
163
|
+
// ),
|
164
|
+
// path.resolve(process.cwd(), 'build', 'buildstats.html')
|
165
|
+
// );
|
166
|
+
|
167
|
+
client.quit();
|
168
|
+
callback && callback();
|
169
|
+
}
|
102
170
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
client.exists(branchName, function (err, bool) {
|
111
|
-
if (!bool) {
|
112
|
-
client.set(branchName, JSON.stringify(finalObj), _redis2.default.print);
|
113
|
-
client.quit();
|
114
|
-
} else {
|
115
|
-
var reportObj = { increased: [], hashChanged: [], branchName: branchName };
|
116
|
-
client.get(branchName, function (err, reply) {
|
117
|
-
if (err) {
|
118
|
-
(0, _utils.log)(err);
|
119
|
-
} else {
|
120
|
-
reply = JSON.parse(reply); // eslint-disable-line
|
121
|
-
Object.keys(reply).forEach(function (fileName) {
|
122
|
-
// eslint-disable-next-line
|
123
|
-
if (finalObj.hasOwnProperty(fileName)) {
|
124
|
-
if (parseInt(reply[fileName].size) < parseInt(finalObj[fileName].size)) {
|
125
|
-
reportObj.increased.push({
|
126
|
-
name: fileName,
|
127
|
-
size: {
|
128
|
-
old: formatBytes(reply[fileName].size),
|
129
|
-
new: formatBytes(finalObj[fileName].size),
|
130
|
-
diff: formatBytes(parseInt(finalObj[fileName].size) - parseInt(reply[fileName].size))
|
131
|
-
}
|
132
|
-
});
|
133
|
-
}
|
134
|
-
if (reply[fileName].hash !== finalObj[fileName].hash) {
|
135
|
-
reportObj.hashChanged.push({
|
136
|
-
name: fileName,
|
137
|
-
hash: {
|
138
|
-
old: reply[fileName].hash,
|
139
|
-
new: finalObj[fileName].hash
|
140
|
-
}
|
141
|
-
});
|
142
|
-
}
|
143
|
-
}
|
144
|
-
});
|
145
|
-
var json = JSON.stringify(reportObj);
|
146
|
-
_fs2.default.writeFile(_path2.default.resolve(process.cwd(), 'build', 'buildtrack.js'), 'let statsJson=' + json, function (err) {
|
147
|
-
if (err) {
|
148
|
-
throw err;
|
149
|
-
}
|
150
|
-
(0, _utils.log)('Stats Json generated!');
|
151
|
-
});
|
152
|
-
}
|
153
|
-
});
|
154
|
-
client.set(branchName, JSON.stringify(finalObj), _redis2.default.print);
|
155
|
-
// fs.copyFileSync(
|
156
|
-
// path.resolve(
|
157
|
-
// process.cwd(),
|
158
|
-
// 'node_modules',
|
159
|
-
// '@zohodesk',
|
160
|
-
// 'react-cli',
|
161
|
-
// 'lib',
|
162
|
-
// 'utils',
|
163
|
-
// 'buildstats.html'
|
164
|
-
// ),
|
165
|
-
// path.resolve(process.cwd(), 'build', 'buildstats.html')
|
166
|
-
// );
|
167
|
-
client.quit();
|
168
|
-
callback && callback();
|
169
|
-
}
|
170
|
-
if (err) {
|
171
|
-
(0, _utils.log)(err);
|
172
|
-
}
|
173
|
-
});
|
174
|
-
}
|
175
|
-
});
|
176
|
-
}
|
177
|
-
}]);
|
171
|
+
if (err) {
|
172
|
+
(0, _utils.log)(err);
|
173
|
+
}
|
174
|
+
});
|
175
|
+
}
|
176
|
+
});
|
177
|
+
}
|
178
178
|
|
179
|
-
|
180
|
-
}();
|
179
|
+
}
|
181
180
|
|
182
181
|
exports.default = reportGeneratePlugin;
|
@@ -1,49 +1,67 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
|
8
|
+
const {
|
9
|
+
Template
|
10
|
+
} = require('webpack');
|
8
11
|
|
9
|
-
|
12
|
+
const pluginName = 'prefetch-preload-chunk-plugin';
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
class ResourceHintsPlugin {
|
15
|
+
apply(compiler) {
|
16
|
+
compiler.hooks.thisCompilation.tap(pluginName, ({
|
17
|
+
mainTemplate
|
18
|
+
}) => {
|
19
|
+
mainTemplate.hooks.requireExtensions.tap(pluginName, (source, chunk, hash) => {
|
20
|
+
const idNameMap = chunk.getChunkMaps().name;
|
21
|
+
const nameIdMap = {};
|
22
|
+
let needsMap = false;
|
13
23
|
|
14
|
-
|
24
|
+
for (const key in idNameMap) {
|
25
|
+
if (Object.prototype.hasOwnProperty.call(idNameMap, key)) {
|
26
|
+
const value = idNameMap[key];
|
27
|
+
nameIdMap[value] = key;
|
15
28
|
|
16
|
-
|
17
|
-
|
18
|
-
_classCallCheck(this, ResourceHintsPlugin);
|
19
|
-
}
|
20
|
-
|
21
|
-
_createClass(ResourceHintsPlugin, [{
|
22
|
-
key: 'apply',
|
23
|
-
value: function apply(compiler) {
|
24
|
-
compiler.hooks.thisCompilation.tap(pluginName, function (_ref) {
|
25
|
-
var mainTemplate = _ref.mainTemplate;
|
26
|
-
|
27
|
-
mainTemplate.hooks.requireExtensions.tap(pluginName, function (source, chunk, hash) {
|
28
|
-
var idNameMap = chunk.getChunkMaps().name;
|
29
|
-
var nameIdMap = {};
|
30
|
-
var needsMap = false;
|
31
|
-
for (var key in idNameMap) {
|
32
|
-
if (Object.prototype.hasOwnProperty.call(idNameMap, key)) {
|
33
|
-
var value = idNameMap[key];
|
34
|
-
nameIdMap[value] = key;
|
35
|
-
if (key !== value) {
|
36
|
-
needsMap = true;
|
37
|
-
}
|
29
|
+
if (key !== value) {
|
30
|
+
needsMap = true;
|
38
31
|
}
|
39
32
|
}
|
40
|
-
|
41
|
-
|
33
|
+
}
|
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);`]), '};',
|
36
|
+
/*
|
37
|
+
(needsMap
|
38
|
+
? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`]
|
39
|
+
: []
|
40
|
+
).concat([
|
41
|
+
'var promises = [];',
|
42
|
+
'if(installedChunks[chunkId] === undefined) {',
|
43
|
+
Template.indent([
|
44
|
+
'installedChunks[chunkId] = null;',
|
45
|
+
/* mainTemplate.hooks.linkPrefetch.call('', chunk, hash),
|
46
|
+
'document.head.appendChild(link);', */
|
47
|
+
|
48
|
+
/*
|
49
|
+
mainTemplate.hooks.requireEnsure.call('', chunk, hash)
|
50
|
+
]),
|
51
|
+
'}'
|
52
|
+
])
|
53
|
+
),
|
54
|
+
'}',
|
55
|
+
*/
|
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];',
|
57
|
+
// mainTemplate.hooks.jsonpScript.call('', chunk, hash),
|
58
|
+
// 'head.appendChild(script);'
|
59
|
+
]), '}']), '};']);
|
42
60
|
});
|
43
|
-
}
|
44
|
-
}
|
61
|
+
});
|
62
|
+
}
|
45
63
|
|
46
|
-
|
47
|
-
}();
|
64
|
+
}
|
48
65
|
|
49
|
-
|
66
|
+
var _default = ResourceHintsPlugin;
|
67
|
+
exports.default = _default;
|
@@ -1,51 +1,36 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
8
9
|
|
9
|
-
var
|
10
|
-
|
11
|
-
var _fs2 = _interopRequireDefault(_fs);
|
12
|
-
|
13
|
-
var _path = require('path');
|
14
|
-
|
15
|
-
var _path2 = _interopRequireDefault(_path);
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
16
11
|
|
17
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
chunk.files.forEach(function (filename) {
|
34
|
-
if (filename === 'vendor.js') {
|
35
|
-
compilation.assets[filename].children.forEach(function (child) {
|
36
|
-
if (child._value) {
|
37
|
-
child._value = coverageScript + child._value;
|
38
|
-
}
|
39
|
-
});
|
40
|
-
}
|
41
|
-
});
|
14
|
+
let coverageScript = _fs.default.readFileSync(_path.default.resolve(__dirname, '..', 'templates', 'CoverageScriptTemplate.js')).toString();
|
15
|
+
|
16
|
+
class ScriptInstrumentPlugin {
|
17
|
+
apply(compiler) {
|
18
|
+
compiler.hooks.emit.tapAsync('ScriptInstrumentPlugin', (compilation, callback) => {
|
19
|
+
compilation.chunks.forEach(chunk => {
|
20
|
+
chunk.files.forEach(filename => {
|
21
|
+
if (filename === 'vendor.js') {
|
22
|
+
compilation.assets[filename].children.forEach(child => {
|
23
|
+
if (child._value) {
|
24
|
+
child._value = coverageScript + child._value;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
}
|
42
28
|
});
|
43
|
-
callback();
|
44
29
|
});
|
45
|
-
|
46
|
-
|
30
|
+
callback();
|
31
|
+
});
|
32
|
+
}
|
47
33
|
|
48
|
-
|
49
|
-
}();
|
34
|
+
}
|
50
35
|
|
51
36
|
exports.default = ScriptInstrumentPlugin;
|