@zohodesk/react-cli 0.0.1-beta.17 → 0.0.1-beta.171
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/.eslintignore +1 -0
- package/.eslintrc.js +49 -10
- package/.prettierrc +6 -0
- package/CHANGELOG.md +5 -0
- package/README.md +859 -0
- package/bin/cli.js +215 -46
- package/cert/Tsicsezwild-22-23.crt +37 -0
- package/cert/Tsicsezwild-22-23.key +27 -0
- package/docs/CustomChunks.md +26 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +24 -0
- package/lib/babel/es-plugins-presets.js +34 -0
- package/lib/common/getEntries.js +33 -46
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +24 -19
- package/lib/common/splitChunks.js +110 -25
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +31 -27
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.component.umd.config.js +46 -53
- package/lib/configs/webpack.css.umd.config.js +47 -46
- package/lib/configs/webpack.dev.config.js +99 -84
- package/lib/configs/webpack.docs.config.js +65 -57
- package/lib/configs/webpack.impact.config.js +109 -0
- package/lib/configs/webpack.prod.config.js +147 -104
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +68 -35
- package/lib/jest/jsonMaker.js +54 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +92 -42
- package/lib/jest/run.js +75 -28
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +113 -0
- package/lib/loaderUtils/getDevJsLoaders.js +35 -23
- package/lib/loaderUtils/index.js +14 -7
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/fileLoader.js +47 -38
- package/lib/loaders/scriptInstrumentLoader.js +23 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +90 -72
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +177 -30
- package/lib/pluginUtils/getDocsPlugins.js +36 -15
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +244 -37
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +14 -18
- package/lib/pluginUtils/getUMDComponentPlugins.js +14 -9
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +77 -0
- package/lib/plugins/CleanupStatsPlugin.js +28 -0
- package/lib/plugins/EFCPlugin.js +241 -0
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
- 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 +95 -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 +86 -0
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +41 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +226 -0
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +67 -0
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +107 -0
- package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
- package/lib/plugins/SourceMapHookPlugin.js +25 -59
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +39 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +127 -37
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludePlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
- package/lib/postcss-plugins/__test__/test1Input.css +39 -0
- package/lib/postcss-plugins/__test__/test1Output.css +39 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +368 -0
- package/lib/postcss-plugins/variableModifier.js +243 -0
- package/lib/schemas/index.js +541 -65
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +94 -79
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +18 -0
- package/lib/servers/impactServer.js +123 -115
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +200 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +134 -132
- package/lib/servers/ssServer.js +106 -70
- package/lib/sh/reportPublish.sh +16 -10
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +10 -0
- package/lib/utils/babelPresets.js +12 -4
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +16 -109
- package/lib/utils/copyTimezones.js +21 -0
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +77 -0
- package/lib/utils/cssURLReplacer.js +136 -0
- package/lib/utils/dependencyPostPublish.js +42 -0
- package/lib/utils/fileUtils.js +125 -0
- package/lib/utils/folderIterator.js +47 -0
- package/lib/utils/getComponents.js +126 -0
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +151 -0
- package/lib/utils/getHash.js +26 -0
- package/lib/utils/getIp.js +20 -0
- package/lib/utils/getOptions.js +113 -28
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +283 -68
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +47 -27
- package/lib/utils/jsonHelper.js +106 -0
- package/lib/utils/libraryImpactConfig.js +63 -0
- 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 +142 -0
- package/lib/utils/mailSender.js +16 -25
- package/lib/utils/pullOrigin.js +28 -0
- package/lib/utils/reinstallDependencies.js +133 -0
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +59 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +59 -0
- package/lib/utils/setEnvVariables.js +13 -0
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +96 -64
- package/postpublish.js +6 -0
- package/templates/app/.eslintrc.js +140 -0
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -8
- 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 -13
- package/templates/app/package.json +37 -17
- package/templates/app/src/actions/SampleActions/index.js +37 -0
- package/templates/app/src/actions/index.js +65 -0
- package/templates/app/src/appUrls.js +19 -0
- package/templates/app/src/components/Alert/Alert.js +134 -0
- package/templates/app/src/components/Alert/Alert.module.css +79 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
- package/templates/app/src/components/Sample/Sample.module.css +11 -0
- package/templates/app/src/components/Sample/SampleList.js +61 -0
- package/templates/app/src/components/Slider/Slider.css +41 -0
- package/templates/app/src/components/Slider/Slider.js +55 -0
- package/templates/app/src/containers/AlertContainer/index.js +15 -0
- package/templates/app/src/containers/AppContainer/index.js +96 -0
- package/templates/app/src/containers/AppContainer/index.module.css +27 -0
- package/templates/app/src/containers/CustomMatch/index.js +65 -0
- package/templates/app/src/containers/DevTools/index.js +10 -0
- package/templates/app/src/containers/Header/index.js +67 -0
- package/templates/app/src/containers/Header/index.module.css +43 -0
- package/templates/app/src/containers/Redirect/index.js +63 -0
- package/templates/app/src/containers/Redirector/index.js +47 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
- package/templates/app/src/historyChange.js +5 -0
- package/templates/app/src/index.html +10 -0
- package/templates/app/src/index.js +24 -0
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
- package/templates/app/src/reducers/alertData.js +11 -0
- package/templates/app/src/reducers/index.js +6 -0
- package/templates/app/src/reducers/samples.js +19 -0
- package/templates/app/src/store/configureStore.dev.js +51 -0
- package/templates/app/src/store/configureStore.js +5 -0
- package/templates/app/src/store/configureStore.prod.js +26 -0
- package/templates/app/src/util/Common.js +5 -0
- package/templates/app/src/util/RequestAPI.js +132 -0
- package/templates/appold/README.md +12 -0
- package/templates/appold/app/index.html +8 -0
- package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
- package/templates/appold/app/properties/i18nkeys.json +3 -0
- package/templates/appold/docs/all.html +69 -0
- package/templates/appold/mockapi/index.js +13 -0
- package/templates/{app → appold}/mockapi/tickets.json +0 -0
- package/templates/appold/package.json +17 -0
- package/templates/appold/src/components/Text/Text.css +0 -0
- package/templates/appold/src/components/Text/Text.js +23 -0
- package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
- package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
- package/templates/appold/src/components/docs.js +1 -0
- package/templates/appold/src/components/index.js +5 -0
- package/templates/appold/src/index.js +13 -0
- package/templates/docs/all.html +1 -1
- package/templates/docs/component.html +110 -69
- package/templates/docs/components.html +221 -0
- package/templates/docs/css/component.css +12 -14
- package/templates/docs/css/componentTest.css +7 -0
- package/templates/docs/css/style.css +150 -206
- package/templates/docs/impactReportTemplate.html +154 -0
- package/templates/docs/index.html +1482 -1336
- package/templates/library/src/index.js +0 -0
- package/.npmignore +0 -3
- package/cert/cert.pem +0 -129
- package/cert/key.pem +0 -27
- package/lib/common/getInsertAt.js +0 -36
- package/lib/common/getInsertIntoFunction.js +0 -13
- package/lib/configs/webpack.server.config.js +0 -93
- package/lib/plugins/ChunkManifestReplacePlugin.js +0 -94
- package/lib/plugins/RuntimePublicPathPlugin.js +0 -46
- package/lib/rmcntrlm.sh +0 -14
- package/lib/servers/nodeServer.js +0 -238
- package/lib/templates/HMRTemplate.js +0 -256
- package/lib/templates/publicPathTemplate.js +0 -16
- package/lib/utils/setConfig.js +0 -14
- package/node_modules/history/CHANGES.md +0 -395
- package/node_modules/history/DOMUtils.js +0 -3
- package/node_modules/history/ExecutionEnvironment.js +0 -3
- package/node_modules/history/LICENSE +0 -21
- package/node_modules/history/LocationUtils.js +0 -3
- package/node_modules/history/PathUtils.js +0 -3
- package/node_modules/history/README.md +0 -282
- package/node_modules/history/cjs/history.js +0 -933
- package/node_modules/history/cjs/history.min.js +0 -1
- package/node_modules/history/createBrowserHistory.js +0 -3
- package/node_modules/history/createHashHistory.js +0 -3
- package/node_modules/history/createMemoryHistory.js +0 -3
- package/node_modules/history/createTransitionManager.js +0 -3
- package/node_modules/history/es/DOMUtils.js +0 -7
- package/node_modules/history/es/ExecutionEnvironment.js +0 -7
- package/node_modules/history/es/LocationUtils.js +0 -7
- package/node_modules/history/es/PathUtils.js +0 -7
- package/node_modules/history/es/createBrowserHistory.js +0 -7
- package/node_modules/history/es/createHashHistory.js +0 -7
- package/node_modules/history/es/createMemoryHistory.js +0 -7
- package/node_modules/history/es/createTransitionManager.js +0 -7
- package/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
- package/node_modules/history/esm/history.js +0 -904
- package/node_modules/history/index.js +0 -7
- package/node_modules/history/package.json +0 -134
- package/node_modules/history/umd/history.js +0 -1059
- package/node_modules/history/umd/history.min.js +0 -1
- package/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
- package/templates/app/.npmignore +0 -9
- package/templates/library/.npmignore +0 -9
@@ -1,123 +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
|
-
|
10
|
+
var _webpackSources = require("webpack-sources");
|
10
11
|
|
11
|
-
|
12
|
-
function ModuleStatsPlugin() {
|
13
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
13
|
|
15
|
-
|
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.includes(`@zohodesk${_path.default.sep}icons`) || name.includes(`@zohodesk${_path.default.sep}svg`)) && !name.endsWith('docs.js')) {
|
16
|
+
return true;
|
17
|
+
}
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
return !name.includes('index.js') && !name.endsWith('.css') && !name.endsWith('.png') && !name.includes('node_modules') && name.includes('src');
|
20
|
+
};
|
21
|
+
|
22
|
+
let getModuleName = modulePath => {
|
23
|
+
let [name] = _path.default.parse(modulePath).name.split('.');
|
24
|
+
|
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}`;
|
19
29
|
}
|
20
30
|
|
21
|
-
|
22
|
-
|
23
|
-
value: function apply(compiler) {
|
24
|
-
var _this = this;
|
25
|
-
|
26
|
-
compiler.hooks.emit.tap('ModuleStatsPlugin', function (compilation) {
|
27
|
-
var stats = compilation.getStats().toJson();
|
28
|
-
|
29
|
-
var modules = stats.modules;
|
30
|
-
|
31
|
-
var moduleName = '';
|
32
|
-
var rModuleName = '';
|
33
|
-
var rReferencesArray = [];
|
34
|
-
var rReferencedByArray = [];
|
35
|
-
var data = { results: [] };
|
36
|
-
var moduleDetails = {};
|
37
|
-
var references = '';
|
38
|
-
var referencedBy = '';
|
39
|
-
// let normalizedData = '';
|
40
|
-
var dre = void 0;
|
41
|
-
|
42
|
-
// eslint-disable-next-line guard-for-in
|
43
|
-
for (var i in modules) {
|
44
|
-
moduleName = modules[i].name;
|
45
|
-
if (moduleName.startsWith('./src') && !(moduleName.indexOf('index.js') > -1) && !moduleName.endsWith('css')) {
|
46
|
-
rModuleName = moduleName.substring(moduleName.lastIndexOf('/') + 1, moduleName.lastIndexOf('.'));
|
47
|
-
if (rModuleName.endsWith('docs')) {
|
48
|
-
rModuleName = rModuleName.substring(0, rModuleName.lastIndexOf('.'));
|
49
|
-
}
|
31
|
+
return name;
|
32
|
+
};
|
50
33
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
var referencedby = referencedBy.substring(referencedBy.lastIndexOf('/') + 1, referencedBy.lastIndexOf('.'));
|
57
|
-
if (referencedby.endsWith('docs')) {
|
58
|
-
rReferencedByArray.push(referencedby.substring(0, referencedby.lastIndexOf('.')));
|
59
|
-
} else {
|
60
|
-
rReferencedByArray.push(referencedBy.substring(referencedBy.lastIndexOf('/') + 1, referencedBy.lastIndexOf('.')));
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
34
|
+
class ModuleStatsPlugin {
|
35
|
+
constructor(options = {}) {
|
36
|
+
this.options = options;
|
37
|
+
this.options.filename = options.filename || 'js/moduleStats.js';
|
38
|
+
}
|
65
39
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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;
|
75
66
|
}
|
76
67
|
}
|
77
|
-
}
|
78
|
-
|
79
|
-
rReferencesArray = rReferencesArray.filter(function (item, index, inputArray) {
|
80
|
-
return inputArray.indexOf(item) === index;
|
81
68
|
});
|
69
|
+
});
|
70
|
+
let currentModuleName = 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 = moduleName;
|
80
|
+
referencedby.add(reasonedModuleName);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
82
84
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
};
|
85
|
+
for (let subModule of modules) {
|
86
|
+
let {
|
87
|
+
name: subModuleName,
|
88
|
+
reasons
|
89
|
+
} = subModule;
|
88
90
|
|
89
|
-
|
91
|
+
if (isValidModule(subModuleName)) {
|
92
|
+
let currentModuleName = subModuleName;
|
90
93
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
references = '';
|
94
|
+
if (Array.isArray(reasons)) {
|
95
|
+
for (let reason of reasons) {
|
96
|
+
let {
|
97
|
+
moduleName: reasonedModuleName
|
98
|
+
} = reason;
|
97
99
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
100
|
+
if (name === reasonedModuleName) {
|
101
|
+
references.add(currentModuleName);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
102
106
|
}
|
103
|
-
}
|
104
107
|
|
105
|
-
|
106
|
-
|
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
|
+
};
|
115
|
+
}
|
116
|
+
}
|
107
117
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
},
|
112
|
-
size: function size() {
|
113
|
-
return mResult.length;
|
114
|
-
}
|
115
|
-
};
|
116
|
-
});
|
117
|
-
}
|
118
|
-
}]);
|
118
|
+
compilation.assets[this.options.filename] = new _webpackSources.RawSource(JSON.stringify(results));
|
119
|
+
});
|
120
|
+
}
|
119
121
|
|
120
|
-
|
121
|
-
}();
|
122
|
+
}
|
122
123
|
|
123
124
|
exports.default = ModuleStatsPlugin;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _optimizeJs = _interopRequireDefault(require("optimize-js"));
|
9
|
+
|
10
|
+
var _webpackSources = require("webpack-sources");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
class OptimizeJSPlugin {
|
15
|
+
constructor(options = {}) {
|
16
|
+
this.optimize = options.optimize;
|
17
|
+
}
|
18
|
+
|
19
|
+
apply(compiler) {
|
20
|
+
compiler.hooks.compilation.tap('OptimizeJSPlugin', compilation => {
|
21
|
+
compilation.hooks.afterOptimizeChunks.tap('OptimizeJSPlugin', chunks => {
|
22
|
+
chunks.forEach(chunk => {
|
23
|
+
const files = chunk.files.map(file => file);
|
24
|
+
files.filter(file => /\.js$/.test(file)).forEach(file => {
|
25
|
+
try {
|
26
|
+
const asset = compilation.assets[file].source();
|
27
|
+
const result = (0, _optimizeJs.default)(asset);
|
28
|
+
compilation.assets[file] = new _webpackSources.RawSource(result);
|
29
|
+
} catch (e) {
|
30
|
+
compilation.errors.push(e);
|
31
|
+
}
|
32
|
+
});
|
33
|
+
});
|
34
|
+
});
|
35
|
+
});
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
39
|
+
|
40
|
+
var _default = OptimizeJSPlugin;
|
41
|
+
exports.default = _default;
|
@@ -0,0 +1,63 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
const MODULE_TYPE = 'css/mini-extract';
|
8
|
+
|
9
|
+
class PublicPathCallbackPlugin {
|
10
|
+
constructor({
|
11
|
+
callback
|
12
|
+
}) {
|
13
|
+
this.publicPathCallback = callback;
|
14
|
+
}
|
15
|
+
|
16
|
+
getCssChunkObject(mainChunk) {
|
17
|
+
const obj = {};
|
18
|
+
|
19
|
+
for (const chunk of mainChunk.getAllAsyncChunks()) {
|
20
|
+
for (const module of chunk.modulesIterable) {
|
21
|
+
if (module.type === MODULE_TYPE) {
|
22
|
+
obj[chunk.id] = 1;
|
23
|
+
break;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
return obj;
|
29
|
+
}
|
30
|
+
|
31
|
+
needChunkOnDemandLoadingCode(chunk) {
|
32
|
+
for (const chunkGroup of chunk.groupsIterable) {
|
33
|
+
if (chunkGroup.getNumberOfChildren() > 0) {
|
34
|
+
return true;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
|
41
|
+
apply(compiler) {
|
42
|
+
compiler.hooks.thisCompilation.tap('PublicPathCallbackPlugin', compilation => {
|
43
|
+
compilation.mainTemplate.hooks.requireEnsure.tap('PublicPathCallbackPlugin', (source, chunk) => {
|
44
|
+
const chunkMap = this.getCssChunkObject(chunk);
|
45
|
+
|
46
|
+
if (Object.keys(chunkMap).length > 0) {
|
47
|
+
return source.replace('__webpack_require__.p', `${this.publicPathCallback}("css")`);
|
48
|
+
}
|
49
|
+
});
|
50
|
+
});
|
51
|
+
compiler.hooks.compilation.tap('PublicPathCallbackPlugin', compilation => {
|
52
|
+
compilation.mainTemplate.hooks.localVars.tap('PublicPathCallbackPlugin', (source, chunk) => {
|
53
|
+
if (this.needChunkOnDemandLoadingCode(chunk)) {
|
54
|
+
return source.replace('__webpack_require__.p', `${this.publicPathCallback}("js")`);
|
55
|
+
}
|
56
|
+
});
|
57
|
+
});
|
58
|
+
}
|
59
|
+
|
60
|
+
}
|
61
|
+
|
62
|
+
var _default = PublicPathCallbackPlugin;
|
63
|
+
exports.default = _default;
|
@@ -0,0 +1,226 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
10
|
+
var _webpackSources = require("webpack-sources");
|
11
|
+
|
12
|
+
var _utils = require("../utils");
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
const MODULE_TYPE = 'css/mini-extract';
|
17
|
+
let {
|
18
|
+
chunkSplitEnable
|
19
|
+
} = (0, _utils.getOptions)().i18n || {};
|
20
|
+
|
21
|
+
let filenameParser = filename => {
|
22
|
+
let filepaths = filename.split('/');
|
23
|
+
let hashedName = filepaths[filepaths.length - 1];
|
24
|
+
|
25
|
+
let {
|
26
|
+
name,
|
27
|
+
ext
|
28
|
+
} = _path.default.parse(hashedName);
|
29
|
+
|
30
|
+
let nameparts = name.split('.');
|
31
|
+
return {
|
32
|
+
name: nameparts.slice(0, nameparts.length - 1).join('.') + ext,
|
33
|
+
hashedName,
|
34
|
+
ext
|
35
|
+
};
|
36
|
+
};
|
37
|
+
|
38
|
+
class PublicPathChangePlugin {
|
39
|
+
constructor({
|
40
|
+
publicPaths,
|
41
|
+
resourceHints
|
42
|
+
}) {
|
43
|
+
if (Array.isArray(publicPaths)) {
|
44
|
+
let [js, css, image, font, i18njs] = publicPaths; //eslint-disable-next-line
|
45
|
+
|
46
|
+
publicPaths = {
|
47
|
+
__REACT_CLI_PUBLIC_PATHS__: {
|
48
|
+
js,
|
49
|
+
css,
|
50
|
+
image,
|
51
|
+
font,
|
52
|
+
i18njs
|
53
|
+
}
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
this.publicPaths = publicPaths;
|
58
|
+
this.resourceHints = resourceHints;
|
59
|
+
}
|
60
|
+
|
61
|
+
getCssChunkObject(mainChunk) {
|
62
|
+
const obj = {};
|
63
|
+
|
64
|
+
for (const chunk of mainChunk.getAllAsyncChunks()) {
|
65
|
+
for (const module of chunk.modulesIterable) {
|
66
|
+
if (module.type === MODULE_TYPE) {
|
67
|
+
obj[chunk.id] = 1;
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
return obj;
|
74
|
+
}
|
75
|
+
|
76
|
+
needChunkOnDemandLoadingCode(chunk) {
|
77
|
+
for (const chunkGroup of chunk.groupsIterable) {
|
78
|
+
if (chunkGroup.getNumberOfChildren() > 0) {
|
79
|
+
return true;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
|
86
|
+
getResourceHints(resourceHints, manifest, publicPaths) {
|
87
|
+
let ruleMapping = {};
|
88
|
+
let validFiles = Object.keys(manifest).filter(filename => {
|
89
|
+
let isValidFile = false;
|
90
|
+
|
91
|
+
for (let pattern of resourceHints) {
|
92
|
+
if (typeof pattern === 'string') {
|
93
|
+
isValidFile = new RegExp(pattern).test(filename);
|
94
|
+
} else {
|
95
|
+
isValidFile = new RegExp(pattern.pattern).test(filename);
|
96
|
+
}
|
97
|
+
|
98
|
+
if (isValidFile) {
|
99
|
+
ruleMapping[filename] = typeof pattern !== 'string' ? pattern : {};
|
100
|
+
break;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
return isValidFile;
|
105
|
+
});
|
106
|
+
let resourceHintsContent = '';
|
107
|
+
|
108
|
+
for (let file of validFiles) {
|
109
|
+
let {
|
110
|
+
fileType,
|
111
|
+
filename
|
112
|
+
} = manifest[file];
|
113
|
+
let rules = ruleMapping[file];
|
114
|
+
resourceHintsContent += `<link rel=${rules.hint || 'preload'} href='${publicPaths[fileType] + filename}'${rules.hint === 'prefetch' ? '' : `as='${fileType}' crossorigin='${rules.crossorigin || 'false'}'`} />`;
|
115
|
+
}
|
116
|
+
|
117
|
+
return resourceHintsContent;
|
118
|
+
}
|
119
|
+
|
120
|
+
apply(compiler) {
|
121
|
+
compiler.hooks.thisCompilation.tap('PublicPathChangePlugin', compilation => {
|
122
|
+
compilation.mainTemplate.hooks.requireEnsure.tap('PublicPathChangePlugin', (source, chunk) => {
|
123
|
+
const chunkMap = this.getCssChunkObject(chunk);
|
124
|
+
|
125
|
+
if (Object.keys(chunkMap).length > 0) {
|
126
|
+
return source.replace('__webpack_require__.p', '__REACT_CLI_CSS_PUBLIC_PATH__');
|
127
|
+
}
|
128
|
+
});
|
129
|
+
});
|
130
|
+
compiler.hooks.compilation.tap('PublicPathChangePlugin', compilation => {
|
131
|
+
compilation.mainTemplate.hooks.localVars.tap('PublicPathChangePlugin', (source, chunk) => {
|
132
|
+
if (this.needChunkOnDemandLoadingCode(chunk)) {
|
133
|
+
return source.replace('__webpack_require__.p', '__REACT_CLI_JS_PUBLIC_PATH__');
|
134
|
+
}
|
135
|
+
});
|
136
|
+
});
|
137
|
+
compiler.hooks.emit.tap('PublicPathChangePlugin', compilation => {
|
138
|
+
let cdns = Object.keys(this.publicPaths);
|
139
|
+
let stats = compilation.getStats().toJson();
|
140
|
+
let manifest = stats.assets.reduce((files, asset) => {
|
141
|
+
let {
|
142
|
+
name: filename
|
143
|
+
} = asset;
|
144
|
+
let fileType = (0, _utils.getFileType)(filename);
|
145
|
+
|
146
|
+
if (fileType === 'image' || fileType === 'font') {
|
147
|
+
let {
|
148
|
+
name,
|
149
|
+
hashedName,
|
150
|
+
ext
|
151
|
+
} = filenameParser(filename);
|
152
|
+
files[name] = {
|
153
|
+
hashedName,
|
154
|
+
ext,
|
155
|
+
fileType,
|
156
|
+
filename
|
157
|
+
};
|
158
|
+
}
|
159
|
+
|
160
|
+
return files;
|
161
|
+
}, {});
|
162
|
+
Object.keys(compilation.assets).forEach(filename => {
|
163
|
+
if (Array.isArray(cdns)) {
|
164
|
+
cdns.forEach(cdn => {
|
165
|
+
let source = compilation.assets[filename].source();
|
166
|
+
|
167
|
+
if (/\.css$/g.test(filename)) {
|
168
|
+
let publicPaths = this.publicPaths[cdn];
|
169
|
+
source = (0, _utils.cssUrlReplacer)(source, publicPaths, manifest, cdn);
|
170
|
+
} else if (/\.js$/g.test(filename)) {
|
171
|
+
let {
|
172
|
+
js,
|
173
|
+
css,
|
174
|
+
image,
|
175
|
+
font
|
176
|
+
} = this.publicPaths[cdn];
|
177
|
+
|
178
|
+
if (typeof source === 'string') {
|
179
|
+
source = source.replace(/__REACT_CLI_JS_PUBLIC_PATH__/g, `"${js}"`);
|
180
|
+
source = source.replace(/__REACT_CLI_CSS_PUBLIC_PATH__/g, `"${css}"`);
|
181
|
+
source = source.replace(/__REACT_CLI_IMAGE_PUBLIC_PATH__/g, `"${image}"`);
|
182
|
+
source = source.replace(/__REACT_CLI_FONT_PUBLIC_PATH__/g, `"${font}"`);
|
183
|
+
}
|
184
|
+
} else if (/\.html$/g.test(filename)) {
|
185
|
+
let {
|
186
|
+
js,
|
187
|
+
css,
|
188
|
+
i18njs
|
189
|
+
} = this.publicPaths[cdn];
|
190
|
+
source = source.replace(new RegExp('<script defer src="([^"]*)"', 'g'), (match, arg) => match.replace(arg, js + arg));
|
191
|
+
source = source.replace(new RegExp('<link href="([^"]*)"', 'g'), (match, arg) => match.replace(arg, css + arg));
|
192
|
+
let [i18nStr] = source.match(/<!--I18nInfoToServer(.*?)I18nInfoToServer-->/gm);
|
193
|
+
|
194
|
+
if (i18nStr && !chunkSplitEnable) {
|
195
|
+
try {
|
196
|
+
let [i18nObj] = i18nStr.match(/{(.*?)}/gm);
|
197
|
+
i18nObj = JSON.parse(JSON.parse(JSON.stringify(i18nObj)));
|
198
|
+
Object.keys(i18nObj).forEach(locale => {
|
199
|
+
i18nObj[locale] = i18njs + i18nObj[locale];
|
200
|
+
});
|
201
|
+
source = source.replace(/<!--I18nInfoToServer(.*?)I18nInfoToServer-->/gm, `<!--I18nInfoToServer${JSON.stringify(i18nObj)}I18nInfoToServer-->`);
|
202
|
+
} catch (e) {
|
203
|
+
// eslint-disable-next-line no-console
|
204
|
+
console.warn('may be I18nInfoToServer inside object was not valid make sure it is parseable by JSON.parse'); // eslint-disable-next-line no-console
|
205
|
+
|
206
|
+
console.warn(e);
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
if (Array.isArray(this.resourceHints) && this.resourceHints.length) {
|
211
|
+
let resourceHintsContent = this.getResourceHints(this.resourceHints, manifest, this.publicPaths[cdn]);
|
212
|
+
source = source.replace(/<\/head>/g, `${resourceHintsContent}</head>`);
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
compilation.assets[cdn === '__REACT_CLI_PUBLIC_PATHS__' ? filename : `${cdn}/${filename}`] = new _webpackSources.RawSource(source);
|
217
|
+
});
|
218
|
+
}
|
219
|
+
});
|
220
|
+
});
|
221
|
+
}
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
var _default = PublicPathChangePlugin;
|
226
|
+
exports.default = _default;
|