@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.1
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
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.REGEXP_CONTENTHASH = void 0;
|
7
|
+
exports.getShortI18nAssets = getShortI18nAssets;
|
8
|
+
exports.hasContentHash = hasContentHash;
|
9
|
+
|
10
|
+
var _urlConcat = require("../../../utils/urlConcat");
|
11
|
+
|
12
|
+
// export const REGEXP_CHUNKHASH = /\[chunkhash(?::(\d+))?\]/gi;
|
13
|
+
// export const REGEXP_HASH = /\[hash(?::(\d+))?\]/gi;
|
14
|
+
// export const REGEXP_NAME = /\[name\]/gi;
|
15
|
+
// export const REGEXP_PLACEHOLDERS = /\[(name|id|chunkhash)\]/gi;
|
16
|
+
// TODO: want to choose file type for i18n load
|
17
|
+
const REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/gi;
|
18
|
+
exports.REGEXP_CONTENTHASH = REGEXP_CONTENTHASH;
|
19
|
+
|
20
|
+
function hasContentHash(filenameTemplate) {
|
21
|
+
return REGEXP_CONTENTHASH.test(filenameTemplate);
|
22
|
+
}
|
23
|
+
|
24
|
+
function getShortI18nAssets(chunks, i18nManifest, publicPathPrefix) {
|
25
|
+
const i18nAssets = {};
|
26
|
+
chunks.forEach(chunk => {
|
27
|
+
const i18nFiles = i18nManifest[chunk.id];
|
28
|
+
|
29
|
+
if (i18nFiles) {
|
30
|
+
Object.keys(i18nFiles).forEach(locale => {
|
31
|
+
if (!i18nAssets[locale]) {
|
32
|
+
i18nAssets[locale] = [];
|
33
|
+
}
|
34
|
+
|
35
|
+
i18nAssets[locale].push((0, _urlConcat.urlConcat)(publicPathPrefix, i18nFiles[locale]));
|
36
|
+
});
|
37
|
+
}
|
38
|
+
});
|
39
|
+
return i18nAssets;
|
40
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
|
7
|
+
var _collectI18nKeys = require("./collectI18nKeys");
|
8
|
+
|
9
|
+
Object.keys(_collectI18nKeys).forEach(function (key) {
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
11
|
+
if (key in exports && exports[key] === _collectI18nKeys[key]) return;
|
12
|
+
Object.defineProperty(exports, key, {
|
13
|
+
enumerable: true,
|
14
|
+
get: function () {
|
15
|
+
return _collectI18nKeys[key];
|
16
|
+
}
|
17
|
+
});
|
18
|
+
});
|
19
|
+
|
20
|
+
var _propertiesUtils = require("./propertiesUtils");
|
21
|
+
|
22
|
+
Object.keys(_propertiesUtils).forEach(function (key) {
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
24
|
+
if (key in exports && exports[key] === _propertiesUtils[key]) return;
|
25
|
+
Object.defineProperty(exports, key, {
|
26
|
+
enumerable: true,
|
27
|
+
get: function () {
|
28
|
+
return _propertiesUtils[key];
|
29
|
+
}
|
30
|
+
});
|
31
|
+
});
|
@@ -0,0 +1,112 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getAllI18n = getAllI18n;
|
7
|
+
exports.getPropertiesAsJSON = getPropertiesAsJSON;
|
8
|
+
exports.jsonToString = jsonToString;
|
9
|
+
|
10
|
+
var _fs = require("fs");
|
11
|
+
|
12
|
+
var _path = require("path");
|
13
|
+
|
14
|
+
function isComment(line) {
|
15
|
+
return line[0] === '#';
|
16
|
+
}
|
17
|
+
|
18
|
+
function getPropertiesAsJSON(filePath) {
|
19
|
+
try {
|
20
|
+
const data = (0, _fs.readFileSync)(filePath);
|
21
|
+
let source = data.toString();
|
22
|
+
const i18nObj = {};
|
23
|
+
source.split(/\r?\n\r?/).forEach(fline => {
|
24
|
+
const line = fline.trim();
|
25
|
+
|
26
|
+
if (!line || isComment(line)) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
|
30
|
+
const ind = line.indexOf('=');
|
31
|
+
const key = line.slice(0, ind).replace(/\\ /g, ' ');
|
32
|
+
const value = line.slice(ind + 1);
|
33
|
+
|
34
|
+
if (key && value) {
|
35
|
+
i18nObj[key] = value;
|
36
|
+
}
|
37
|
+
}, {});
|
38
|
+
return i18nObj;
|
39
|
+
} catch (err) {
|
40
|
+
return {};
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
function getLang(file) {
|
45
|
+
let underScoreIndex = file.indexOf('_');
|
46
|
+
let language = 'en_US';
|
47
|
+
|
48
|
+
if (underScoreIndex !== -1) {
|
49
|
+
language = file.substring(underScoreIndex + 1);
|
50
|
+
language = language.slice(0, language.indexOf('.'));
|
51
|
+
}
|
52
|
+
|
53
|
+
return language;
|
54
|
+
}
|
55
|
+
|
56
|
+
function getAllI18n({
|
57
|
+
folderPath,
|
58
|
+
disableDefault,
|
59
|
+
jsResourceI18nKeys,
|
60
|
+
exclude = /^[^_]+$/,
|
61
|
+
include = /\.properties$/
|
62
|
+
}) {
|
63
|
+
try {
|
64
|
+
const files = (0, _fs.readdirSync)(folderPath, 'utf8');
|
65
|
+
const allLangI18n = {};
|
66
|
+
const context = (0, _path.join)(process.cwd(), folderPath);
|
67
|
+
files.forEach(file => {
|
68
|
+
const filePath = (0, _path.join)(context, file);
|
69
|
+
|
70
|
+
if (exclude.test(filePath) || !include.test(filePath)) {
|
71
|
+
// console.log('exclude', filePath);
|
72
|
+
return;
|
73
|
+
} // console.log('include', filePath);
|
74
|
+
|
75
|
+
|
76
|
+
const i18n = getPropertiesAsJSON(filePath);
|
77
|
+
allLangI18n[getLang(file)] = disableDefault ? i18n : Object.assign({}, jsResourceI18nKeys, i18n);
|
78
|
+
});
|
79
|
+
return allLangI18n;
|
80
|
+
} catch (err) {
|
81
|
+
// console.log(err);
|
82
|
+
return {};
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
function jsonToString(json, keySeperator) {
|
87
|
+
let str = '{';
|
88
|
+
let keys = Object.keys(json);
|
89
|
+
keys.forEach((key, i) => {
|
90
|
+
let value = json[key];
|
91
|
+
|
92
|
+
if (!value) {
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
|
96
|
+
str += `"${keySeperator ? key.replace(/(\.|\\(\s+))/g, keySeperator) : key}":"${value.replace(/.?"/g, match => {
|
97
|
+
if (match[0] === '\\') {
|
98
|
+
return match;
|
99
|
+
} else if (match.length === 2) {
|
100
|
+
return `${match[0]}\\${match[1]}`;
|
101
|
+
}
|
102
|
+
|
103
|
+
return `\\${match}`;
|
104
|
+
}).replace(/(\r\n|\n|\r)/g, '')}"`;
|
105
|
+
|
106
|
+
if (i !== keys.length - 1) {
|
107
|
+
str += ',';
|
108
|
+
}
|
109
|
+
});
|
110
|
+
str += '}';
|
111
|
+
return str;
|
112
|
+
}
|
@@ -1,89 +1,78 @@
|
|
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 _path = _interopRequireDefault(require("path"));
|
8
9
|
|
9
|
-
var
|
10
|
-
|
11
|
-
var _path2 = _interopRequireDefault(_path);
|
12
|
-
|
13
|
-
var _webpackSources = require('webpack-sources');
|
10
|
+
var _webpackSources = require("webpack-sources");
|
14
11
|
|
15
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
13
|
|
17
|
-
|
14
|
+
let filenameParser = filename => {
|
15
|
+
let filepaths = filename.split('/');
|
16
|
+
let hashedName = filepaths[filepaths.length - 1];
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
let {
|
19
|
+
name,
|
20
|
+
ext
|
21
|
+
} = _path.default.parse(hashedName);
|
22
22
|
|
23
|
-
|
24
|
-
name = _path$parse.name,
|
25
|
-
ext = _path$parse.ext;
|
26
|
-
|
27
|
-
var nameparts = name.split('.');
|
23
|
+
let nameparts = name.split('.');
|
28
24
|
return {
|
29
25
|
name: nameparts.slice(0, nameparts.length - 1).join('.') + ext,
|
30
|
-
hashedName
|
26
|
+
hashedName
|
31
27
|
};
|
32
28
|
};
|
33
29
|
|
34
|
-
|
35
|
-
|
36
|
-
_classCallCheck(this, ManifestPlugin);
|
37
|
-
|
30
|
+
class ManifestPlugin {
|
31
|
+
constructor(options) {
|
38
32
|
this.options = options;
|
39
33
|
}
|
40
34
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
hashedName = _filenameParser.hashedName;
|
54
|
-
|
55
|
-
if (chunk.canBeInitial()) {
|
56
|
-
if (!files.entryFiles) {
|
57
|
-
files.entryFiles = {};
|
58
|
-
}
|
59
|
-
files.entryFiles[filename] = hashedName;
|
60
|
-
}
|
61
|
-
files[filename] = hashedName;
|
62
|
-
return files;
|
63
|
-
}, files);
|
64
|
-
}, {});
|
65
|
-
|
66
|
-
manifest = stats.assets.reduce(function (files, asset) {
|
67
|
-
var isEntryAsset = asset.chunks.length > 0;
|
68
|
-
if (isEntryAsset) {
|
69
|
-
return files;
|
35
|
+
apply(compiler) {
|
36
|
+
compiler.hooks.emit.tap('PublicPathChangePlugin', compilation => {
|
37
|
+
let stats = compilation.getStats().toJson();
|
38
|
+
let manifest = compilation.chunks.reduce((files, chunk) => chunk.files.reduce((files, name) => {
|
39
|
+
let {
|
40
|
+
name: filename,
|
41
|
+
hashedName
|
42
|
+
} = filenameParser(name);
|
43
|
+
|
44
|
+
if (chunk.canBeInitial()) {
|
45
|
+
if (!files.entryFiles) {
|
46
|
+
files.entryFiles = {};
|
70
47
|
}
|
71
|
-
var filename = asset.name;
|
72
48
|
|
73
|
-
|
74
|
-
|
75
|
-
hashedName = _filenameParser2.hashedName;
|
49
|
+
files.entryFiles[filename] = hashedName;
|
50
|
+
}
|
76
51
|
|
77
|
-
|
78
|
-
|
79
|
-
|
52
|
+
files[filename] = hashedName;
|
53
|
+
return files;
|
54
|
+
}, files), {});
|
55
|
+
manifest = stats.assets.reduce((files, asset) => {
|
56
|
+
let isEntryAsset = asset.chunks.length > 0;
|
80
57
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
58
|
+
if (isEntryAsset) {
|
59
|
+
return files;
|
60
|
+
}
|
61
|
+
|
62
|
+
let {
|
63
|
+
name: filename
|
64
|
+
} = asset;
|
65
|
+
let {
|
66
|
+
name,
|
67
|
+
hashedName
|
68
|
+
} = filenameParser(filename);
|
69
|
+
files[name] = hashedName;
|
70
|
+
return files;
|
71
|
+
}, manifest);
|
72
|
+
compilation.assets[this.options.fileName] = new _webpackSources.RawSource(JSON.stringify(manifest));
|
73
|
+
});
|
74
|
+
}
|
85
75
|
|
86
|
-
|
87
|
-
}();
|
76
|
+
}
|
88
77
|
|
89
78
|
exports.default = ManifestPlugin;
|
@@ -1,214 +1,124 @@
|
|
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 _path = _interopRequireDefault(require("path"));
|
8
9
|
|
9
|
-
var
|
10
|
-
|
11
|
-
var _path = require('path');
|
12
|
-
|
13
|
-
var _path2 = _interopRequireDefault(_path);
|
14
|
-
|
15
|
-
var _webpackSources = require('webpack-sources');
|
10
|
+
var _webpackSources = require("webpack-sources");
|
16
11
|
|
17
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
var isValidModule = function isValidModule(name) {
|
22
|
-
if (name.includes('node_modules') && (name.includes('@zohodesk' + _path2.default.sep + 'components') || name.includes('@zohodesk' + _path2.default.sep + 'dot')) && !name.endsWith('index.js') && !name.endsWith('docs.js')) {
|
14
|
+
let isValidModule = name => {
|
15
|
+
if (name.includes('node_modules') && (name.includes(`@zohodesk${_path.default.sep}components`) || name.includes(`@zohodesk${_path.default.sep}dot`)) && !name.endsWith('index.js') && !name.endsWith('docs.js')) {
|
23
16
|
return true;
|
24
17
|
}
|
25
18
|
|
26
19
|
return !name.includes('index.js') && !name.endsWith('.css') && !name.endsWith('.png') && !name.includes('node_modules') && name.includes('src');
|
27
20
|
};
|
28
21
|
|
29
|
-
|
30
|
-
|
31
|
-
_path$parse$name$spli2 = _slicedToArray(_path$parse$name$spli, 1),
|
32
|
-
name = _path$parse$name$spli2[0];
|
22
|
+
let getModuleName = modulePath => {
|
23
|
+
let [name] = _path.default.parse(modulePath).name.split('.');
|
33
24
|
|
34
|
-
if (modulePath.includes(
|
35
|
-
name =
|
36
|
-
} else if (modulePath.includes(
|
37
|
-
name =
|
25
|
+
if (modulePath.includes(`@zohodesk${_path.default.sep}components`)) {
|
26
|
+
name = `@zohodesk/components/${name}`;
|
27
|
+
} else if (modulePath.includes(`@zohodesk${_path.default.sep}dot`)) {
|
28
|
+
name = `@zohodesk/dot/${name}`;
|
38
29
|
}
|
30
|
+
|
39
31
|
return name;
|
40
32
|
};
|
41
33
|
|
42
|
-
|
43
|
-
|
44
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
45
|
-
|
46
|
-
_classCallCheck(this, ModuleStatsPlugin);
|
47
|
-
|
34
|
+
class ModuleStatsPlugin {
|
35
|
+
constructor(options = {}) {
|
48
36
|
this.options = options;
|
49
37
|
this.options.filename = options.filename || 'js/moduleStats.js';
|
50
38
|
}
|
51
39
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
40
|
+
apply(compiler) {
|
41
|
+
compiler.hooks.emit.tap('ModuleStatsPlugin', compilation => {
|
42
|
+
let stats = compilation.getStats().toJson();
|
43
|
+
let results = {};
|
44
|
+
let {
|
45
|
+
modules
|
46
|
+
} = stats;
|
47
|
+
|
48
|
+
for (let module of modules) {
|
49
|
+
let {
|
50
|
+
name,
|
51
|
+
reasons
|
52
|
+
} = module;
|
53
|
+
|
54
|
+
if (isValidModule(name)) {
|
55
|
+
let references = new Set();
|
56
|
+
let referencedby = new Set();
|
57
|
+
let docsName;
|
58
|
+
let fileName;
|
59
|
+
compilation.modules.forEach(module => {
|
60
|
+
module.reasons.forEach(reason => {
|
61
|
+
let exportedValue = reason.dependency;
|
62
|
+
|
63
|
+
if (exportedValue.type === 'harmony export imported specifier') {
|
64
|
+
if (exportedValue.module.userRequest.includes(name.replace('.', ''))) {
|
65
|
+
docsName = exportedValue.name;
|
77
66
|
}
|
78
|
-
}
|
67
|
+
}
|
79
68
|
});
|
69
|
+
});
|
70
|
+
let currentModuleName = getModuleName(name);
|
71
|
+
|
72
|
+
if (Array.isArray(reasons)) {
|
73
|
+
for (let reason of reasons) {
|
74
|
+
let {
|
75
|
+
moduleName
|
76
|
+
} = reason;
|
77
|
+
|
78
|
+
if (isValidModule(moduleName)) {
|
79
|
+
let reasonedModuleName = getModuleName(moduleName);
|
80
|
+
referencedby.add(reasonedModuleName);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
80
84
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
85
|
+
for (let subModule of modules) {
|
86
|
+
let {
|
87
|
+
name: subModuleName,
|
88
|
+
reasons
|
89
|
+
} = subModule;
|
86
90
|
|
87
|
-
|
88
|
-
|
89
|
-
var reason = _step2.value;
|
90
|
-
var moduleName = reason.moduleName;
|
91
|
+
if (isValidModule(subModuleName)) {
|
92
|
+
let currentModuleName = getModuleName(subModuleName);
|
91
93
|
|
94
|
+
if (Array.isArray(reasons)) {
|
95
|
+
for (let reason of reasons) {
|
96
|
+
let {
|
97
|
+
moduleName: reasonedModuleName
|
98
|
+
} = reason;
|
92
99
|
|
93
|
-
if (
|
94
|
-
|
95
|
-
referencedby.add(reasonedModuleName);
|
96
|
-
}
|
97
|
-
}
|
98
|
-
} catch (err) {
|
99
|
-
_didIteratorError2 = true;
|
100
|
-
_iteratorError2 = err;
|
101
|
-
} finally {
|
102
|
-
try {
|
103
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
104
|
-
_iterator2.return();
|
105
|
-
}
|
106
|
-
} finally {
|
107
|
-
if (_didIteratorError2) {
|
108
|
-
throw _iteratorError2;
|
100
|
+
if (name === reasonedModuleName) {
|
101
|
+
references.add(currentModuleName);
|
109
102
|
}
|
110
103
|
}
|
111
104
|
}
|
112
105
|
}
|
113
|
-
var _iteratorNormalCompletion3 = true;
|
114
|
-
var _didIteratorError3 = false;
|
115
|
-
var _iteratorError3 = undefined;
|
116
|
-
|
117
|
-
try {
|
118
|
-
for (var _iterator3 = modules[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
119
|
-
var subModule = _step3.value;
|
120
|
-
var subModuleName = subModule.name,
|
121
|
-
_reasons = subModule.reasons;
|
122
|
-
|
123
|
-
if (isValidModule(subModuleName)) {
|
124
|
-
var _currentModuleName = getModuleName(subModuleName);
|
125
|
-
if (Array.isArray(_reasons)) {
|
126
|
-
var _iteratorNormalCompletion4 = true;
|
127
|
-
var _didIteratorError4 = false;
|
128
|
-
var _iteratorError4 = undefined;
|
129
|
-
|
130
|
-
try {
|
131
|
-
for (var _iterator4 = _reasons[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
132
|
-
var _reason = _step4.value;
|
133
|
-
var _reasonedModuleName = _reason.moduleName;
|
134
|
-
|
135
|
-
if (name === _reasonedModuleName) {
|
136
|
-
references.add(_currentModuleName);
|
137
|
-
}
|
138
|
-
}
|
139
|
-
} catch (err) {
|
140
|
-
_didIteratorError4 = true;
|
141
|
-
_iteratorError4 = err;
|
142
|
-
} finally {
|
143
|
-
try {
|
144
|
-
if (!_iteratorNormalCompletion4 && _iterator4.return) {
|
145
|
-
_iterator4.return();
|
146
|
-
}
|
147
|
-
} finally {
|
148
|
-
if (_didIteratorError4) {
|
149
|
-
throw _iteratorError4;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
}
|
153
|
-
}
|
154
|
-
}
|
155
|
-
}
|
156
|
-
} catch (err) {
|
157
|
-
_didIteratorError3 = true;
|
158
|
-
_iteratorError3 = err;
|
159
|
-
} finally {
|
160
|
-
try {
|
161
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
162
|
-
_iterator3.return();
|
163
|
-
}
|
164
|
-
} finally {
|
165
|
-
if (_didIteratorError3) {
|
166
|
-
throw _iteratorError3;
|
167
|
-
}
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
results[currentModuleName] = {
|
172
|
-
name: currentModuleName,
|
173
|
-
references: Array.from(references),
|
174
|
-
referencedby: Array.from(referencedby),
|
175
|
-
docsName: docsName ? docsName : ''
|
176
|
-
};
|
177
106
|
}
|
178
|
-
};
|
179
|
-
|
180
|
-
var _iteratorNormalCompletion = true;
|
181
|
-
var _didIteratorError = false;
|
182
|
-
var _iteratorError = undefined;
|
183
107
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
}
|
191
|
-
} catch (err) {
|
192
|
-
_didIteratorError = true;
|
193
|
-
_iteratorError = err;
|
194
|
-
} finally {
|
195
|
-
try {
|
196
|
-
if (!_iteratorNormalCompletion && _iterator.return) {
|
197
|
-
_iterator.return();
|
198
|
-
}
|
199
|
-
} finally {
|
200
|
-
if (_didIteratorError) {
|
201
|
-
throw _iteratorError;
|
202
|
-
}
|
203
|
-
}
|
108
|
+
results[currentModuleName] = {
|
109
|
+
name: currentModuleName,
|
110
|
+
references: Array.from(references),
|
111
|
+
referencedby: Array.from(referencedby),
|
112
|
+
docsName: docsName ? docsName : '',
|
113
|
+
fileName: name ? name : currentModuleName
|
114
|
+
};
|
204
115
|
}
|
116
|
+
}
|
205
117
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
}]);
|
118
|
+
compilation.assets[this.options.filename] = new _webpackSources.RawSource(JSON.stringify(results));
|
119
|
+
});
|
120
|
+
}
|
210
121
|
|
211
|
-
|
212
|
-
}();
|
122
|
+
}
|
213
123
|
|
214
124
|
exports.default = ModuleStatsPlugin;
|