@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/README.md +1025 -1028
  5. package/bin/cli.js +482 -482
  6. package/cert/Tsicsezwild-22-23.crt +37 -37
  7. package/cert/Tsicsezwild-22-23.key +27 -27
  8. package/docs/CustomChunks.md +26 -26
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/SelectorWeight.md +6 -0
  13. package/docs/TODOS.md +10 -10
  14. package/docs/ValueReplacer.md +60 -60
  15. package/docs/VariableConversion.md +719 -678
  16. package/docs/warnings_while_install.txt +35 -35
  17. package/files/eslintrc.js +62 -62
  18. package/files/prettierrc.js +3 -3
  19. package/lib/babel/cmjs-plugins-presets.js +4 -0
  20. package/lib/babel/es-plugins-presets.js +4 -0
  21. package/lib/common/getEntries.js +10 -0
  22. package/lib/common/getPublicPathConfig.js +6 -0
  23. package/lib/common/index.js +5 -0
  24. package/lib/common/splitChunks.js +13 -2
  25. package/lib/common/sslcertUpdater.js +17 -6
  26. package/lib/common/templateParameters.js +2 -0
  27. package/lib/common/testPattern.js +21 -10
  28. package/lib/common/valueReplacer.js +15 -0
  29. package/lib/configs/jest.config.js +9 -0
  30. package/lib/configs/libAlias.js +2 -4
  31. package/lib/configs/webpack.component.umd.config.js +5 -0
  32. package/lib/configs/webpack.css.umd.config.js +13 -5
  33. package/lib/configs/webpack.dev.config.js +36 -2
  34. package/lib/configs/webpack.docs.config.js +21 -1
  35. package/lib/configs/webpack.impact.config.js +19 -1
  36. package/lib/configs/webpack.prod.config.js +37 -3
  37. package/lib/hooks/docsProptypeHook.js +7 -3
  38. package/lib/jest/commitedFilesResult.js +45 -3
  39. package/lib/jest/coverageCollector.js +11 -0
  40. package/lib/jest/jsonMaker.js +6 -0
  41. package/lib/jest/preProcessors/cssPreprocessor.js +8 -0
  42. package/lib/jest/preProcessors/jsPreprocessor.js +2 -0
  43. package/lib/jest/preProcessors/otherFilesPreprocessor.js +3 -0
  44. package/lib/jest/result.js +22 -0
  45. package/lib/jest/run.js +17 -6
  46. package/lib/jest/setup.js +57 -5
  47. package/lib/loaderUtils/configsAssetsLoaders.js +44 -34
  48. package/lib/loaderUtils/getCSSLoaders.js +35 -20
  49. package/lib/loaderUtils/getDevJsLoaders.js +8 -0
  50. package/lib/loaderUtils/index.js +3 -0
  51. package/lib/loaderUtils/windowsModification.js +11 -0
  52. package/lib/loaders/docsLoader.js +7 -0
  53. package/lib/loaders/docsPropsLoader.js +7 -3
  54. package/lib/loaders/fileBountryLoader.js +2 -0
  55. package/lib/loaders/fileLoader.js +22 -11
  56. package/lib/loaders/scriptInstrumentLoader.js +13 -5
  57. package/lib/loaders/selectorMappingLoader.js +25 -7
  58. package/lib/loaders/workerLoader.js +29 -13
  59. package/lib/middlewares/HMRMiddleware.js +26 -13
  60. package/lib/middlewares/SSTMiddleware.js +3 -0
  61. package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -3
  62. package/lib/pluginUtils/getDevPlugins.js +68 -22
  63. package/lib/pluginUtils/getDocsPlugins.js +10 -1
  64. package/lib/pluginUtils/getLibraryImactPlugins.js +5 -4
  65. package/lib/pluginUtils/getLibraryPlugins.js +5 -0
  66. package/lib/pluginUtils/getProdPlugins.js +77 -28
  67. package/lib/pluginUtils/getServerPlugins.js +5 -0
  68. package/lib/pluginUtils/getUMDCSSPlugins.js +7 -0
  69. package/lib/pluginUtils/getUMDComponentPlugins.js +7 -0
  70. package/lib/pluginUtils/index.js +8 -0
  71. package/lib/plugins/CdnChangePlugin.js +14 -0
  72. package/lib/plugins/CleanupStatsPlugin.js +5 -0
  73. package/lib/plugins/EFCPlugin.js +34 -23
  74. package/lib/plugins/EFCPlugin.md +6 -6
  75. package/lib/plugins/EFCTemplatePlugin.js +32 -23
  76. package/lib/plugins/I18NInjectIntoIndexPlugin.js +38 -12
  77. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
  78. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
  79. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +77 -46
  80. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +59 -44
  81. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +30 -21
  82. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  83. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  84. package/lib/plugins/I18nSplitPlugin/index.js +80 -70
  85. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
  86. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
  87. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
  88. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +6 -0
  89. package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
  90. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -2
  91. package/lib/plugins/ManifestPlugin.js +17 -0
  92. package/lib/plugins/ModuleStatsPlugin.js +23 -0
  93. package/lib/plugins/OptimizeJSPlugin.js +7 -0
  94. package/lib/plugins/PublicPathCallbackPlugin.js +10 -0
  95. package/lib/plugins/PublicPathChangePlugin.js +36 -4
  96. package/lib/plugins/ReportGeneratePlugin.js +30 -4
  97. package/lib/plugins/RequireVariablePublicPlugin.js +6 -0
  98. package/lib/plugins/ResourceHintsPlugin.js +27 -20
  99. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
  100. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +22 -15
  101. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  102. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
  103. package/lib/plugins/ScriptInstrumentPlugin.js +7 -0
  104. package/lib/plugins/SelectorPlugin.js +97 -0
  105. package/lib/plugins/ServiceWorkerPlugin.js +29 -13
  106. package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
  107. package/lib/plugins/SourceMapHookPlugin.js +9 -0
  108. package/lib/plugins/TPHashMappingPlugin.js +19 -5
  109. package/lib/plugins/UglifyCSSPlugin.js +9 -0
  110. package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
  111. package/lib/plugins/VariableConversionCollector.js +322 -0
  112. package/lib/plugins/composeCommonPlugin.js +30 -0
  113. package/lib/plugins/index.js +19 -0
  114. package/lib/plugins/libraryImpactPlugin.js +32 -0
  115. package/lib/plugins/webpackwatchrunplugin.js +5 -0
  116. package/lib/postcss-plugins/ExcludePlugin.js +4 -0
  117. package/lib/postcss-plugins/RTLSplitPlugin.js +37 -24
  118. package/lib/postcss-plugins/ValueReplacer.js +6 -9
  119. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
  120. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  121. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  122. package/lib/postcss-plugins/hoverActivePlugin.js +69 -33
  123. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +42 -13
  124. package/lib/postcss-plugins/variableModificationPlugin/index.js +216 -141
  125. package/lib/postcss-plugins/variableModifier.js +20 -13
  126. package/lib/schemas/index.js +23 -4
  127. package/lib/servers/clusterHubServer.js +10 -0
  128. package/lib/servers/devBuild.js +24 -13
  129. package/lib/servers/docsServer.js +2 -0
  130. package/lib/servers/docsServerCore.js +21 -0
  131. package/lib/servers/getCliPath.js +9 -0
  132. package/lib/servers/helpServer.js +5 -0
  133. package/lib/servers/httpsOptions.js +4 -0
  134. package/lib/servers/impactServer.js +34 -2
  135. package/lib/servers/mockserver.js +9 -0
  136. package/lib/servers/nowatchserver.js +34 -12
  137. package/lib/servers/scrServer.js +20 -13
  138. package/lib/servers/server.js +35 -7
  139. package/lib/servers/ssServer.js +16 -0
  140. package/lib/sh/pre-commit.sh +34 -34
  141. package/lib/sh/reportPublish.sh +45 -45
  142. package/lib/templates/CoverageScriptTemplate.js +14 -0
  143. package/lib/templates/WMSTemplate.js +12 -6
  144. package/lib/utils/babelPresets.js +2 -0
  145. package/lib/utils/buildstats.html +148 -148
  146. package/lib/utils/clean.js +8 -2
  147. package/lib/utils/copy.js +6 -0
  148. package/lib/utils/copyTimezones.js +8 -0
  149. package/lib/utils/createEventStream.js +4 -0
  150. package/lib/utils/cssClassNameGenerate.js +19 -3
  151. package/lib/utils/cssURLReplacer.js +25 -0
  152. package/lib/utils/dependencyPostPublish.js +9 -0
  153. package/lib/utils/fileUtils.js +26 -0
  154. package/lib/utils/folderIterator.js +10 -0
  155. package/lib/utils/getComponents.js +21 -0
  156. package/lib/utils/getCurrentBranch.js +5 -0
  157. package/lib/utils/getDependenciesImpactList.js +21 -0
  158. package/lib/utils/getHash.js +7 -0
  159. package/lib/utils/getIp.js +2 -0
  160. package/lib/utils/getOptions.js +39 -14
  161. package/lib/utils/getServerURL.js +7 -0
  162. package/lib/utils/index.js +47 -2
  163. package/lib/utils/init.js +1 -0
  164. package/lib/utils/initPreCommitHook.js +29 -6
  165. package/lib/utils/jsonHelper.js +19 -2
  166. package/lib/utils/libraryImpactConfig.js +2 -0
  167. package/lib/utils/lint/addScripts.js +5 -2
  168. package/lib/utils/lint/checkExistingConfig.js +12 -3
  169. package/lib/utils/lint/copyConfigs.js +3 -0
  170. package/lib/utils/lint/index.js +9 -0
  171. package/lib/utils/lint/lintScripts.js +1 -0
  172. package/lib/utils/lint/lintSetup.js +4 -3
  173. package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
  174. package/lib/utils/lint/question.js +7 -0
  175. package/lib/utils/lintReporter.js +20 -0
  176. package/lib/utils/mailSender.js +7 -0
  177. package/lib/utils/pullOrigin.js +4 -0
  178. package/lib/utils/reinstallDependencies.js +28 -0
  179. package/lib/utils/removeAttributes.js +7 -0
  180. package/lib/utils/repoClone.js +27 -2
  181. package/lib/utils/request.js +12 -0
  182. package/lib/utils/resultSchema.json +73 -73
  183. package/lib/utils/rtl.js +16 -4
  184. package/lib/utils/setEnvVariables.js +2 -0
  185. package/lib/utils/ssTestHack.js +10 -0
  186. package/lib/utils/switchBranch.js +4 -0
  187. package/lib/utils/urlConcat.js +4 -0
  188. package/lib/utils/useExitCleanup.js +10 -9
  189. package/npm8.md +9 -9
  190. package/package.json +146 -146
  191. package/postpublish.js +6 -6
  192. package/templates/app/.eslintrc.js +140 -140
  193. package/templates/app/README.md +12 -12
  194. package/templates/app/app/index.html +24 -24
  195. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  196. package/templates/app/app/properties/i18nkeys.json +3 -3
  197. package/templates/app/docs/all.html +69 -69
  198. package/templates/app/mockapi/index.js +18 -18
  199. package/templates/app/package.json +37 -37
  200. package/templates/app/src/actions/SampleActions/index.js +37 -37
  201. package/templates/app/src/actions/index.js +65 -65
  202. package/templates/app/src/appUrls.js +19 -19
  203. package/templates/app/src/components/Alert/Alert.js +134 -134
  204. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  205. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  206. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  207. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  208. package/templates/app/src/components/Sample/SampleList.js +61 -61
  209. package/templates/app/src/components/Slider/Slider.css +41 -41
  210. package/templates/app/src/components/Slider/Slider.js +55 -55
  211. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  212. package/templates/app/src/containers/AppContainer/index.js +96 -96
  213. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  214. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  215. package/templates/app/src/containers/DevTools/index.js +10 -10
  216. package/templates/app/src/containers/Header/index.js +67 -67
  217. package/templates/app/src/containers/Header/index.module.css +43 -43
  218. package/templates/app/src/containers/Redirect/index.js +63 -63
  219. package/templates/app/src/containers/Redirector/index.js +47 -47
  220. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  221. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  222. package/templates/app/src/historyChange.js +5 -5
  223. package/templates/app/src/index.html +10 -10
  224. package/templates/app/src/index.js +24 -24
  225. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  226. package/templates/app/src/reducers/alertData.js +11 -11
  227. package/templates/app/src/reducers/index.js +6 -6
  228. package/templates/app/src/reducers/samples.js +19 -19
  229. package/templates/app/src/store/configureStore.dev.js +51 -51
  230. package/templates/app/src/store/configureStore.js +5 -5
  231. package/templates/app/src/store/configureStore.prod.js +26 -26
  232. package/templates/app/src/util/Common.js +5 -5
  233. package/templates/app/src/util/RequestAPI.js +132 -132
  234. package/templates/docs/all.html +249 -249
  235. package/templates/docs/component.html +178 -178
  236. package/templates/docs/components.html +221 -221
  237. package/templates/docs/css/b.min.css +6 -6
  238. package/templates/docs/css/component.css +42 -42
  239. package/templates/docs/css/componentTest.css +6 -6
  240. package/templates/docs/css/hopscotch.css +585 -585
  241. package/templates/docs/css/style.css +1022 -1022
  242. package/templates/docs/impactReportTemplate.html +154 -154
  243. package/templates/docs/index.html +1501 -1501
  244. package/templates/docs/js/active-line.js +72 -72
  245. package/templates/docs/js/b.min.js +7 -7
  246. package/templates/docs/js/codemirror.js +9680 -9680
  247. package/templates/docs/js/designTokens.js +334 -334
  248. package/templates/docs/js/j.min.js +4 -4
  249. package/templates/docs/js/javascript.js +874 -874
  250. package/templates/docs/js/matchbrackets.js +145 -145
@@ -6,11 +6,15 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getAllI18n = getAllI18n;
7
7
  exports.getPropertiesAsJSON = getPropertiesAsJSON;
8
8
  exports.jsonToString = jsonToString;
9
+
9
10
  var _fs = require("fs");
11
+
10
12
  var _path = require("path");
13
+
11
14
  function isComment(line) {
12
15
  return line[0] === '#';
13
16
  }
17
+
14
18
  function getPropertiesAsJSON(filePath) {
15
19
  try {
16
20
  const data = (0, _fs.readFileSync)(filePath);
@@ -18,12 +22,15 @@ function getPropertiesAsJSON(filePath) {
18
22
  const i18nObj = {};
19
23
  source.split(/\r?\n\r?/).forEach(fline => {
20
24
  const line = fline.trim();
25
+
21
26
  if (!line || isComment(line)) {
22
27
  return;
23
28
  }
29
+
24
30
  const ind = line.indexOf('=');
25
31
  const key = line.slice(0, ind).replace(/\\ /g, ' ');
26
32
  const value = line.slice(ind + 1);
33
+
27
34
  if (key && value) {
28
35
  i18nObj[key] = value;
29
36
  }
@@ -33,15 +40,19 @@ function getPropertiesAsJSON(filePath) {
33
40
  return {};
34
41
  }
35
42
  }
43
+
36
44
  function getLang(file) {
37
45
  let underScoreIndex = file.indexOf('_');
38
46
  let language = 'en_US';
47
+
39
48
  if (underScoreIndex !== -1) {
40
49
  language = file.substring(underScoreIndex + 1);
41
50
  language = language.slice(0, language.indexOf('.'));
42
51
  }
52
+
43
53
  return language;
44
54
  }
55
+
45
56
  function getAllI18n({
46
57
  folderPath,
47
58
  disableDefault,
@@ -55,11 +66,13 @@ function getAllI18n({
55
66
  const context = (0, _path.join)(process.cwd(), folderPath);
56
67
  files.forEach(file => {
57
68
  const filePath = (0, _path.join)(context, file);
69
+
58
70
  if (exclude.test(filePath) || !include.test(filePath)) {
59
71
  // console.log('exclude', filePath);
60
72
  return;
61
- }
62
- // console.log('include', filePath);
73
+ } // console.log('include', filePath);
74
+
75
+
63
76
  const i18n = getPropertiesAsJSON(filePath);
64
77
  allLangI18n[getLang(file)] = disableDefault ? i18n : Object.assign({}, jsResourceI18nKeys, i18n);
65
78
  });
@@ -69,22 +82,27 @@ function getAllI18n({
69
82
  return {};
70
83
  }
71
84
  }
85
+
72
86
  function jsonToString(json, keySeperator) {
73
87
  let str = '{';
74
88
  let keys = Object.keys(json);
75
89
  keys.forEach((key, i) => {
76
90
  let value = json[key];
91
+
77
92
  if (!value) {
78
93
  return;
79
94
  }
95
+
80
96
  str += `"${keySeperator ? key.replace(/(\.|\\(\s+))/g, keySeperator) : key}":"${value.replace(/.?"/g, match => {
81
97
  if (match[0] === '\\') {
82
98
  return match;
83
99
  } else if (match.length === 2) {
84
100
  return `${match[0]}\\${match[1]}`;
85
101
  }
102
+
86
103
  return `\\${match}`;
87
104
  }).replace(/(\r\n|\n|\r)/g, '')}"`;
105
+
88
106
  if (i !== keys.length - 1) {
89
107
  str += ',';
90
108
  }
@@ -4,32 +4,42 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _webpackSources = require("webpack-sources");
11
+
9
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
10
14
  let filenameParser = filename => {
11
15
  let filepaths = filename.split('/');
12
16
  let hashedName = filepaths[filepaths.length - 1];
17
+
13
18
  let {
14
19
  name,
15
20
  ext
16
21
  } = _path.default.parse(hashedName);
22
+
17
23
  let nameparts = name.split('.');
24
+
18
25
  if (ext === '.css' && /^(rtl|ltr)$/.test(nameparts[nameparts.length - 1])) {
19
26
  return {
20
27
  name: nameparts.slice(0, nameparts.length - 2).join('.') + ext,
21
28
  hashedName
22
29
  };
23
30
  }
31
+
24
32
  return {
25
33
  name: nameparts.slice(0, nameparts.length - 1).join('.') + ext,
26
34
  hashedName
27
35
  };
28
36
  };
37
+
29
38
  class ManifestPlugin {
30
39
  constructor(options) {
31
40
  this.options = options;
32
41
  }
42
+
33
43
  apply(compiler) {
34
44
  compiler.hooks.emit.tap('PublicPathChangePlugin', compilation => {
35
45
  let stats = compilation.getStats().toJson();
@@ -38,20 +48,25 @@ class ManifestPlugin {
38
48
  name: filename,
39
49
  hashedName
40
50
  } = filenameParser(name);
51
+
41
52
  if (chunk.canBeInitial()) {
42
53
  if (!files.entryFiles) {
43
54
  files.entryFiles = {};
44
55
  }
56
+
45
57
  files.entryFiles[filename] = hashedName;
46
58
  }
59
+
47
60
  files[filename] = hashedName;
48
61
  return files;
49
62
  }, files), {});
50
63
  manifest = stats.assets.reduce((files, asset) => {
51
64
  let isEntryAsset = asset.chunks.length > 0;
65
+
52
66
  if (isEntryAsset) {
53
67
  return files;
54
68
  }
69
+
55
70
  let {
56
71
  name: filename
57
72
  } = asset;
@@ -65,5 +80,7 @@ class ManifestPlugin {
65
80
  compilation.assets[this.options.fileName] = new _webpackSources.RawSource(JSON.stringify(manifest));
66
81
  });
67
82
  }
83
+
68
84
  }
85
+
69
86
  exports.default = ManifestPlugin;
@@ -4,29 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _webpackSources = require("webpack-sources");
11
+
9
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
10
14
  let isValidModule = name => {
11
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')) {
12
16
  return true;
13
17
  }
18
+
14
19
  return !name.includes('index.js') && !name.endsWith('.css') && !name.endsWith('.png') && !name.includes('node_modules') && name.includes('src');
15
20
  };
21
+
16
22
  let getModuleName = modulePath => {
17
23
  let [name] = _path.default.parse(modulePath).name.split('.');
24
+
18
25
  if (modulePath.includes(`@zohodesk${_path.default.sep}components`)) {
19
26
  name = `@zohodesk/components/${name}`;
20
27
  } else if (modulePath.includes(`@zohodesk${_path.default.sep}dot`)) {
21
28
  name = `@zohodesk/dot/${name}`;
22
29
  }
30
+
23
31
  return name;
24
32
  };
33
+
25
34
  class ModuleStatsPlugin {
26
35
  constructor(options = {}) {
27
36
  this.options = options;
28
37
  this.options.filename = options.filename || 'js/moduleStats.js';
29
38
  }
39
+
30
40
  apply(compiler) {
31
41
  compiler.hooks.emit.tap('ModuleStatsPlugin', compilation => {
32
42
  let stats = compilation.getStats().toJson();
@@ -34,11 +44,13 @@ class ModuleStatsPlugin {
34
44
  let {
35
45
  modules
36
46
  } = stats;
47
+
37
48
  for (let module of modules) {
38
49
  let {
39
50
  name,
40
51
  reasons
41
52
  } = module;
53
+
42
54
  if (isValidModule(name)) {
43
55
  let references = new Set();
44
56
  let referencedby = new Set();
@@ -47,6 +59,7 @@ class ModuleStatsPlugin {
47
59
  compilation.modules.forEach(module => {
48
60
  module.reasons.forEach(reason => {
49
61
  let exportedValue = reason.dependency;
62
+
50
63
  if (exportedValue.type === 'harmony export imported specifier') {
51
64
  if (exportedValue.module.userRequest.includes(name.replace('.', ''))) {
52
65
  docsName = exportedValue.name;
@@ -55,29 +68,35 @@ class ModuleStatsPlugin {
55
68
  });
56
69
  });
57
70
  let currentModuleName = name;
71
+
58
72
  if (Array.isArray(reasons)) {
59
73
  for (let reason of reasons) {
60
74
  let {
61
75
  moduleName
62
76
  } = reason;
77
+
63
78
  if (isValidModule(moduleName)) {
64
79
  let reasonedModuleName = moduleName;
65
80
  referencedby.add(reasonedModuleName);
66
81
  }
67
82
  }
68
83
  }
84
+
69
85
  for (let subModule of modules) {
70
86
  let {
71
87
  name: subModuleName,
72
88
  reasons
73
89
  } = subModule;
90
+
74
91
  if (isValidModule(subModuleName)) {
75
92
  let currentModuleName = subModuleName;
93
+
76
94
  if (Array.isArray(reasons)) {
77
95
  for (let reason of reasons) {
78
96
  let {
79
97
  moduleName: reasonedModuleName
80
98
  } = reason;
99
+
81
100
  if (name === reasonedModuleName) {
82
101
  references.add(currentModuleName);
83
102
  }
@@ -85,6 +104,7 @@ class ModuleStatsPlugin {
85
104
  }
86
105
  }
87
106
  }
107
+
88
108
  results[currentModuleName] = {
89
109
  name: currentModuleName,
90
110
  references: Array.from(references),
@@ -94,8 +114,11 @@ class ModuleStatsPlugin {
94
114
  };
95
115
  }
96
116
  }
117
+
97
118
  compilation.assets[this.options.filename] = new _webpackSources.RawSource(JSON.stringify(results));
98
119
  });
99
120
  }
121
+
100
122
  }
123
+
101
124
  exports.default = ModuleStatsPlugin;
@@ -4,13 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _optimizeJs = _interopRequireDefault(require("optimize-js"));
9
+
8
10
  var _webpackSources = require("webpack-sources");
11
+
9
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
10
14
  class OptimizeJSPlugin {
11
15
  constructor(options = {}) {
12
16
  this.optimize = options.optimize;
13
17
  }
18
+
14
19
  apply(compiler) {
15
20
  compiler.hooks.compilation.tap('OptimizeJSPlugin', compilation => {
16
21
  compilation.hooks.afterOptimizeChunks.tap('OptimizeJSPlugin', chunks => {
@@ -29,6 +34,8 @@ class OptimizeJSPlugin {
29
34
  });
30
35
  });
31
36
  }
37
+
32
38
  }
39
+
33
40
  var _default = OptimizeJSPlugin;
34
41
  exports.default = _default;
@@ -5,14 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  const MODULE_TYPE = 'css/mini-extract';
8
+
8
9
  class PublicPathCallbackPlugin {
9
10
  constructor({
10
11
  callback
11
12
  }) {
12
13
  this.publicPathCallback = callback;
13
14
  }
15
+
14
16
  getCssChunkObject(mainChunk) {
15
17
  const obj = {};
18
+
16
19
  for (const chunk of mainChunk.getAllAsyncChunks()) {
17
20
  for (const module of chunk.modulesIterable) {
18
21
  if (module.type === MODULE_TYPE) {
@@ -21,20 +24,25 @@ class PublicPathCallbackPlugin {
21
24
  }
22
25
  }
23
26
  }
27
+
24
28
  return obj;
25
29
  }
30
+
26
31
  needChunkOnDemandLoadingCode(chunk) {
27
32
  for (const chunkGroup of chunk.groupsIterable) {
28
33
  if (chunkGroup.getNumberOfChildren() > 0) {
29
34
  return true;
30
35
  }
31
36
  }
37
+
32
38
  return false;
33
39
  }
40
+
34
41
  apply(compiler) {
35
42
  compiler.hooks.thisCompilation.tap('PublicPathCallbackPlugin', compilation => {
36
43
  compilation.mainTemplate.hooks.requireEnsure.tap('PublicPathCallbackPlugin', (source, chunk) => {
37
44
  const chunkMap = this.getCssChunkObject(chunk);
45
+
38
46
  if (Object.keys(chunkMap).length > 0) {
39
47
  return source.replace('__webpack_require__.p', `${this.publicPathCallback}("css")`);
40
48
  }
@@ -48,6 +56,8 @@ class PublicPathCallbackPlugin {
48
56
  });
49
57
  });
50
58
  }
59
+
51
60
  }
61
+
52
62
  var _default = PublicPathCallbackPlugin;
53
63
  exports.default = _default;
@@ -4,21 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _webpackSources = require("webpack-sources");
11
+
9
12
  var _utils = require("../utils");
13
+
10
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
11
16
  const MODULE_TYPE = 'css/mini-extract';
12
17
  let {
13
18
  chunkSplitEnable
14
19
  } = (0, _utils.getOptions)().i18n || {};
20
+
15
21
  let filenameParser = filename => {
16
22
  let filepaths = filename.split('/');
17
23
  let hashedName = filepaths[filepaths.length - 1];
24
+
18
25
  let {
19
26
  name,
20
27
  ext
21
28
  } = _path.default.parse(hashedName);
29
+
22
30
  let nameparts = name.split('.');
23
31
  return {
24
32
  name: nameparts.slice(0, nameparts.length - 1).join('.') + ext,
@@ -26,14 +34,15 @@ let filenameParser = filename => {
26
34
  ext
27
35
  };
28
36
  };
37
+
29
38
  class PublicPathChangePlugin {
30
39
  constructor({
31
40
  publicPaths,
32
41
  resourceHints
33
42
  }) {
34
43
  if (Array.isArray(publicPaths)) {
35
- let [js, css, image, font, i18njs] = publicPaths;
36
- //eslint-disable-next-line
44
+ let [js, css, image, font, i18njs] = publicPaths; //eslint-disable-next-line
45
+
37
46
  publicPaths = {
38
47
  __REACT_CLI_PUBLIC_PATHS__: {
39
48
  js,
@@ -44,11 +53,14 @@ class PublicPathChangePlugin {
44
53
  }
45
54
  };
46
55
  }
56
+
47
57
  this.publicPaths = publicPaths;
48
58
  this.resourceHints = resourceHints;
49
59
  }
60
+
50
61
  getCssChunkObject(mainChunk) {
51
62
  const obj = {};
63
+
52
64
  for (const chunk of mainChunk.getAllAsyncChunks()) {
53
65
  for (const module of chunk.modulesIterable) {
54
66
  if (module.type === MODULE_TYPE) {
@@ -57,34 +69,42 @@ class PublicPathChangePlugin {
57
69
  }
58
70
  }
59
71
  }
72
+
60
73
  return obj;
61
74
  }
75
+
62
76
  needChunkOnDemandLoadingCode(chunk) {
63
77
  for (const chunkGroup of chunk.groupsIterable) {
64
78
  if (chunkGroup.getNumberOfChildren() > 0) {
65
79
  return true;
66
80
  }
67
81
  }
82
+
68
83
  return false;
69
84
  }
85
+
70
86
  getResourceHints(resourceHints, manifest, publicPaths) {
71
87
  let ruleMapping = {};
72
88
  let validFiles = Object.keys(manifest).filter(filename => {
73
89
  let isValidFile = false;
90
+
74
91
  for (let pattern of resourceHints) {
75
92
  if (typeof pattern === 'string') {
76
93
  isValidFile = new RegExp(pattern).test(filename);
77
94
  } else {
78
95
  isValidFile = new RegExp(pattern.pattern).test(filename);
79
96
  }
97
+
80
98
  if (isValidFile) {
81
99
  ruleMapping[filename] = typeof pattern !== 'string' ? pattern : {};
82
100
  break;
83
101
  }
84
102
  }
103
+
85
104
  return isValidFile;
86
105
  });
87
106
  let resourceHintsContent = '';
107
+
88
108
  for (let file of validFiles) {
89
109
  let {
90
110
  fileType,
@@ -93,12 +113,15 @@ class PublicPathChangePlugin {
93
113
  let rules = ruleMapping[file];
94
114
  resourceHintsContent += `<link rel=${rules.hint || 'preload'} href='${publicPaths[fileType] + filename}'${rules.hint === 'prefetch' ? '' : `as='${fileType}' crossorigin='${rules.crossorigin || 'false'}'`} />`;
95
115
  }
116
+
96
117
  return resourceHintsContent;
97
118
  }
119
+
98
120
  apply(compiler) {
99
121
  compiler.hooks.thisCompilation.tap('PublicPathChangePlugin', compilation => {
100
122
  compilation.mainTemplate.hooks.requireEnsure.tap('PublicPathChangePlugin', (source, chunk) => {
101
123
  const chunkMap = this.getCssChunkObject(chunk);
124
+
102
125
  if (Object.keys(chunkMap).length > 0) {
103
126
  return source.replace('__webpack_require__.p', '__REACT_CLI_CSS_PUBLIC_PATH__');
104
127
  }
@@ -119,6 +142,7 @@ class PublicPathChangePlugin {
119
142
  name: filename
120
143
  } = asset;
121
144
  let fileType = (0, _utils.getFileType)(filename);
145
+
122
146
  if (fileType === 'image' || fileType === 'font') {
123
147
  let {
124
148
  name,
@@ -132,12 +156,14 @@ class PublicPathChangePlugin {
132
156
  filename
133
157
  };
134
158
  }
159
+
135
160
  return files;
136
161
  }, {});
137
162
  Object.keys(compilation.assets).forEach(filename => {
138
163
  if (Array.isArray(cdns)) {
139
164
  cdns.forEach(cdn => {
140
165
  let source = compilation.assets[filename].source();
166
+
141
167
  if (/\.css$/g.test(filename)) {
142
168
  let publicPaths = this.publicPaths[cdn];
143
169
  source = (0, _utils.cssUrlReplacer)(source, publicPaths, manifest, cdn);
@@ -148,6 +174,7 @@ class PublicPathChangePlugin {
148
174
  image,
149
175
  font
150
176
  } = this.publicPaths[cdn];
177
+
151
178
  if (typeof source === 'string') {
152
179
  source = source.replace(/__REACT_CLI_JS_PUBLIC_PATH__/g, `"${js}"`);
153
180
  source = source.replace(/__REACT_CLI_CSS_PUBLIC_PATH__/g, `"${css}"`);
@@ -163,6 +190,7 @@ class PublicPathChangePlugin {
163
190
  source = source.replace(new RegExp('<script defer src="([^"]*)"', 'g'), (match, arg) => match.replace(arg, js + arg));
164
191
  source = source.replace(new RegExp('<link href="([^"]*)"', 'g'), (match, arg) => match.replace(arg, css + arg));
165
192
  let [i18nStr] = source.match(/<!--I18nInfoToServer(.*?)I18nInfoToServer-->/gm);
193
+
166
194
  if (i18nStr && !chunkSplitEnable) {
167
195
  try {
168
196
  let [i18nObj] = i18nStr.match(/{(.*?)}/gm);
@@ -173,22 +201,26 @@ class PublicPathChangePlugin {
173
201
  source = source.replace(/<!--I18nInfoToServer(.*?)I18nInfoToServer-->/gm, `<!--I18nInfoToServer${JSON.stringify(i18nObj)}I18nInfoToServer-->`);
174
202
  } catch (e) {
175
203
  // eslint-disable-next-line no-console
176
- console.warn('may be I18nInfoToServer inside object was not valid make sure it is parseable by JSON.parse');
177
- // 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
+
178
206
  console.warn(e);
179
207
  }
180
208
  }
209
+
181
210
  if (Array.isArray(this.resourceHints) && this.resourceHints.length) {
182
211
  let resourceHintsContent = this.getResourceHints(this.resourceHints, manifest, this.publicPaths[cdn]);
183
212
  source = source.replace(/<\/head>/g, `${resourceHintsContent}</head>`);
184
213
  }
185
214
  }
215
+
186
216
  compilation.assets[cdn === '__REACT_CLI_PUBLIC_PATHS__' ? filename : `${cdn}/${filename}`] = new _webpackSources.RawSource(source);
187
217
  });
188
218
  }
189
219
  });
190
220
  });
191
221
  }
222
+
192
223
  }
224
+
193
225
  var _default = PublicPathChangePlugin;
194
226
  exports.default = _default;
@@ -4,11 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _fs = _interopRequireDefault(require("fs"));
9
+
8
10
  var _path = _interopRequireDefault(require("path"));
11
+
9
12
  var _redis = _interopRequireDefault(require("redis"));
13
+
10
14
  var _utils = require("../utils");
15
+
11
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
12
18
  let options = (0, _utils.getOptions)();
13
19
  let {
14
20
  app: {
@@ -17,47 +23,60 @@ let {
17
23
  redisPort
18
24
  }
19
25
  } = options;
26
+
20
27
  class reportGeneratePlugin {
21
28
  apply(compiler) {
22
29
  compiler.hooks.emit.tapAsync('reportGeneratePlugin', (compilation, callback) => {
23
30
  function formatBytes(bytes) {
24
31
  if (bytes) {
25
32
  let isNegative;
33
+
26
34
  if (bytes < 0) {
27
35
  bytes = bytes * -1; //eslint-disable-line
36
+
28
37
  isNegative = true;
29
38
  }
39
+
30
40
  if (bytes < 1024) {
31
41
  if (isNegative) {
32
42
  return `- ${bytes} Bytes`;
33
43
  }
44
+
34
45
  return `${bytes} Bytes`;
35
46
  } else if (bytes < 1048576) {
36
47
  if (isNegative) {
37
48
  return `- ${(bytes / 1024).toFixed(3)} KB`;
38
49
  }
50
+
39
51
  return `${(bytes / 1024).toFixed(3)} KB`;
40
52
  } else if (bytes < 1073741824) {
41
53
  if (isNegative) {
42
54
  return `- ${(bytes / 1048576).toFixed(3)} MB`;
43
55
  }
56
+
44
57
  return `${(bytes / 1048576).toFixed(3)} MB`;
45
58
  }
59
+
46
60
  if (isNegative) {
47
61
  return `- ${(bytes / 1073741824).toFixed(3)} GB`;
48
62
  }
63
+
49
64
  return `${(bytes / 1073741824).toFixed(3)} GB`;
50
65
  }
51
66
  }
67
+
52
68
  let client = _redis.default.createClient(redisPort, redisHost);
69
+
53
70
  client.on('connect', () => {
54
71
  (0, _utils.log)('Redis client connected');
55
72
  });
56
73
  client.on('error', err => {
57
74
  (0, _utils.log)(`Something went wrong ${err}`);
58
75
  });
76
+
59
77
  if (_fs.default.existsSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'))) {
60
78
  let statsJSON = _fs.default.readFileSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'), 'utf8');
79
+
61
80
  statsJSON = JSON.parse(statsJSON);
62
81
  let finalObj = {};
63
82
  let branchName = branch ? branch : (0, _utils.getCurrentBranch)();
@@ -74,8 +93,8 @@ class reportGeneratePlugin {
74
93
  name,
75
94
  hash,
76
95
  size
77
- };
78
- // eslint-disable-next-line
96
+ }; // eslint-disable-next-line
97
+
79
98
  if (!finalObj.hasOwnProperty(name)) {
80
99
  finalObj[name] = tempObject;
81
100
  }
@@ -95,6 +114,7 @@ class reportGeneratePlugin {
95
114
  (0, _utils.log)(err);
96
115
  } else {
97
116
  reply = JSON.parse(reply); // eslint-disable-line
117
+
98
118
  Object.keys(reply).forEach(fileName => {
99
119
  // eslint-disable-next-line
100
120
  if (finalObj.hasOwnProperty(fileName)) {
@@ -108,6 +128,7 @@ class reportGeneratePlugin {
108
128
  }
109
129
  });
110
130
  }
131
+
111
132
  if (reply[fileName].hash !== finalObj[fileName].hash) {
112
133
  reportObj.hashChanged.push({
113
134
  name: fileName,
@@ -120,16 +141,17 @@ class reportGeneratePlugin {
120
141
  }
121
142
  });
122
143
  let json = JSON.stringify(reportObj);
144
+
123
145
  _fs.default.writeFile(_path.default.resolve(process.cwd(), 'build', 'buildtrack.js'), `let statsJson=${json}`, err => {
124
146
  if (err) {
125
147
  throw err;
126
148
  }
149
+
127
150
  (0, _utils.log)('Stats Json generated!');
128
151
  });
129
152
  }
130
153
  });
131
- client.set(branchName, JSON.stringify(finalObj), _redis.default.print);
132
- // fs.copyFileSync(
154
+ client.set(branchName, JSON.stringify(finalObj), _redis.default.print); // fs.copyFileSync(
133
155
  // path.resolve(
134
156
  // process.cwd(),
135
157
  // 'node_modules',
@@ -141,9 +163,11 @@ class reportGeneratePlugin {
141
163
  // ),
142
164
  // path.resolve(process.cwd(), 'build', 'buildstats.html')
143
165
  // );
166
+
144
167
  client.quit();
145
168
  callback && callback();
146
169
  }
170
+
147
171
  if (err) {
148
172
  (0, _utils.log)(err);
149
173
  }
@@ -151,5 +175,7 @@ class reportGeneratePlugin {
151
175
  }
152
176
  });
153
177
  }
178
+
154
179
  }
180
+
155
181
  exports.default = reportGeneratePlugin;