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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -179
  3. package/.prettierrc +6 -6
  4. package/README.md +1028 -951
  5. package/bin/cli.js +483 -483
  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/TODOS.md +10 -10
  13. package/docs/ValueReplacer.md +60 -60
  14. package/docs/VariableConversion.md +678 -0
  15. package/docs/warnings_while_install.txt +35 -35
  16. package/files/eslintrc.js +62 -62
  17. package/files/prettierrc.js +3 -3
  18. package/lib/babel/cmjs-plugins-presets.js +0 -4
  19. package/lib/babel/es-plugins-presets.js +0 -4
  20. package/lib/common/getEntries.js +0 -10
  21. package/lib/common/getPublicPathConfig.js +0 -6
  22. package/lib/common/index.js +0 -5
  23. package/lib/common/splitChunks.js +2 -13
  24. package/lib/common/sslcertUpdater.js +6 -17
  25. package/lib/common/templateParameters.js +0 -2
  26. package/lib/common/testPattern.js +10 -21
  27. package/lib/common/valueReplacer.js +0 -15
  28. package/lib/configs/jest.config.js +8 -21
  29. package/lib/configs/libAlias.js +11 -2
  30. package/lib/configs/webpack.component.umd.config.js +0 -5
  31. package/lib/configs/webpack.css.umd.config.js +5 -13
  32. package/lib/configs/webpack.dev.config.js +13 -24
  33. package/lib/configs/webpack.docs.config.js +6 -12
  34. package/lib/configs/webpack.impact.config.js +6 -10
  35. package/lib/configs/webpack.prod.config.js +15 -26
  36. package/lib/hooks/docsProptypeHook.js +3 -7
  37. package/lib/jest/commitedFilesResult.js +3 -45
  38. package/lib/jest/coverageCollector.js +0 -11
  39. package/lib/jest/jsonMaker.js +0 -6
  40. package/lib/jest/preProcessors/cssPreprocessor.js +14 -13
  41. package/lib/jest/preProcessors/jsPreprocessor.js +0 -2
  42. package/lib/jest/preProcessors/otherFilesPreprocessor.js +0 -3
  43. package/lib/jest/result.js +0 -22
  44. package/lib/jest/run.js +6 -17
  45. package/lib/jest/setup.js +5 -57
  46. package/lib/loaderUtils/configsAssetsLoaders.js +34 -44
  47. package/lib/loaderUtils/getCSSLoaders.js +41 -28
  48. package/lib/loaderUtils/getDevJsLoaders.js +0 -8
  49. package/lib/loaderUtils/index.js +0 -3
  50. package/lib/loaders/docsLoader.js +0 -7
  51. package/lib/loaders/docsPropsLoader.js +3 -7
  52. package/lib/loaders/fileBountryLoader.js +0 -2
  53. package/lib/loaders/fileLoader.js +11 -22
  54. package/lib/loaders/scriptInstrumentLoader.js +5 -13
  55. package/lib/loaders/selectorMappingLoader.js +7 -25
  56. package/lib/loaders/workerLoader.js +13 -29
  57. package/lib/middlewares/HMRMiddleware.js +13 -26
  58. package/lib/middlewares/SSTMiddleware.js +0 -3
  59. package/lib/pluginUtils/configHtmlWebpackPlugins.js +53 -0
  60. package/lib/pluginUtils/getDevPlugins.js +20 -64
  61. package/lib/pluginUtils/getDocsPlugins.js +1 -10
  62. package/lib/pluginUtils/getLibraryImactPlugins.js +4 -5
  63. package/lib/pluginUtils/getLibraryPlugins.js +0 -5
  64. package/lib/pluginUtils/getProdPlugins.js +32 -78
  65. package/lib/pluginUtils/getServerPlugins.js +0 -5
  66. package/lib/pluginUtils/getUMDCSSPlugins.js +0 -7
  67. package/lib/pluginUtils/getUMDComponentPlugins.js +0 -7
  68. package/lib/pluginUtils/index.js +0 -8
  69. package/lib/plugins/CdnChangePlugin.js +0 -14
  70. package/lib/plugins/CleanupStatsPlugin.js +0 -5
  71. package/lib/plugins/EFCPlugin.js +23 -34
  72. package/lib/plugins/EFCPlugin.md +6 -6
  73. package/lib/plugins/EFCTemplatePlugin.js +23 -32
  74. package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -38
  75. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +12 -17
  76. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
  77. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +46 -77
  78. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +44 -59
  79. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +21 -30
  80. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  81. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  82. package/lib/plugins/I18nSplitPlugin/index.js +70 -80
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
  85. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
  86. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +0 -6
  87. package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
  88. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +2 -20
  89. package/lib/plugins/ManifestPlugin.js +0 -17
  90. package/lib/plugins/ModuleStatsPlugin.js +0 -23
  91. package/lib/plugins/OptimizeJSPlugin.js +0 -7
  92. package/lib/plugins/PublicPathCallbackPlugin.js +0 -10
  93. package/lib/plugins/PublicPathChangePlugin.js +4 -36
  94. package/lib/plugins/ReportGeneratePlugin.js +4 -30
  95. package/lib/plugins/RequireVariablePublicPlugin.js +0 -6
  96. package/lib/plugins/ResourceHintsPlugin.js +20 -27
  97. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
  98. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +23 -38
  99. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  100. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
  101. package/lib/plugins/ScriptInstrumentPlugin.js +0 -7
  102. package/lib/plugins/ServiceWorkerPlugin.js +13 -29
  103. package/lib/plugins/ShadowDOMSupportPlugin.js +3 -40
  104. package/lib/plugins/SourceMapHookPlugin.js +0 -9
  105. package/lib/plugins/TPHashMappingPlugin.js +5 -19
  106. package/lib/plugins/UglifyCSSPlugin.js +0 -9
  107. package/lib/plugins/UnusedFilesFindPlugin.js +2 -35
  108. package/lib/plugins/index.js +0 -19
  109. package/lib/plugins/libraryImpactPlugin.js +0 -32
  110. package/lib/plugins/webpackwatchrunplugin.js +0 -5
  111. package/lib/postcss-plugins/ExcludePlugin.js +0 -4
  112. package/lib/postcss-plugins/RTLSplitPlugin.js +24 -37
  113. package/lib/postcss-plugins/ValueReplacer.js +9 -6
  114. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
  115. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  116. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  117. package/lib/postcss-plugins/hoverActivePlugin.js +80 -92
  118. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +31 -0
  119. package/lib/postcss-plugins/variableModificationPlugin/index.js +232 -0
  120. package/lib/postcss-plugins/variableModifier.js +14 -20
  121. package/lib/schemas/index.js +28 -13
  122. package/lib/servers/clusterHubServer.js +0 -10
  123. package/lib/servers/devBuild.js +13 -24
  124. package/lib/servers/docsServer.js +0 -2
  125. package/lib/servers/docsServerCore.js +0 -21
  126. package/lib/servers/getCliPath.js +1 -10
  127. package/lib/servers/helpServer.js +0 -5
  128. package/lib/servers/httpsOptions.js +0 -4
  129. package/lib/servers/impactServer.js +2 -34
  130. package/lib/servers/mockserver.js +0 -9
  131. package/lib/servers/nowatchserver.js +12 -34
  132. package/lib/servers/scrServer.js +13 -20
  133. package/lib/servers/server.js +7 -35
  134. package/lib/servers/ssServer.js +0 -16
  135. package/lib/sh/pre-commit.sh +34 -34
  136. package/lib/sh/reportPublish.sh +45 -45
  137. package/lib/templates/CoverageScriptTemplate.js +0 -14
  138. package/lib/templates/WMSTemplate.js +6 -12
  139. package/lib/utils/babelPresets.js +0 -2
  140. package/lib/utils/buildstats.html +148 -148
  141. package/lib/utils/clean.js +2 -8
  142. package/lib/utils/copy.js +0 -6
  143. package/lib/utils/copyTimezones.js +0 -8
  144. package/lib/utils/createEventStream.js +0 -4
  145. package/lib/utils/cssClassNameGenerate.js +3 -19
  146. package/lib/utils/cssURLReplacer.js +0 -25
  147. package/lib/utils/dependencyPostPublish.js +0 -9
  148. package/lib/utils/fileUtils.js +0 -26
  149. package/lib/utils/folderIterator.js +0 -10
  150. package/lib/utils/getComponents.js +0 -21
  151. package/lib/utils/getCurrentBranch.js +0 -5
  152. package/lib/utils/getDependenciesImpactList.js +0 -21
  153. package/lib/utils/getHash.js +0 -7
  154. package/lib/utils/getIp.js +0 -2
  155. package/lib/utils/getOptions.js +38 -35
  156. package/lib/utils/getServerURL.js +0 -7
  157. package/lib/utils/index.js +2 -47
  158. package/lib/utils/init.js +0 -1
  159. package/lib/utils/initPreCommitHook.js +6 -29
  160. package/lib/utils/jsonHelper.js +2 -19
  161. package/lib/utils/libraryImpactConfig.js +0 -2
  162. package/lib/utils/lint/addScripts.js +2 -5
  163. package/lib/utils/lint/checkExistingConfig.js +3 -12
  164. package/lib/utils/lint/copyConfigs.js +0 -3
  165. package/lib/utils/lint/index.js +0 -9
  166. package/lib/utils/lint/lintScripts.js +0 -1
  167. package/lib/utils/lint/lintSetup.js +3 -4
  168. package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
  169. package/lib/utils/lint/question.js +0 -7
  170. package/lib/utils/lintReporter.js +0 -20
  171. package/lib/utils/mailSender.js +0 -7
  172. package/lib/utils/pullOrigin.js +0 -4
  173. package/lib/utils/reinstallDependencies.js +0 -28
  174. package/lib/utils/removeAttributes.js +0 -7
  175. package/lib/utils/repoClone.js +2 -27
  176. package/lib/utils/request.js +0 -12
  177. package/lib/utils/resultSchema.json +73 -73
  178. package/lib/utils/rtl.js +4 -16
  179. package/lib/utils/setEnvVariables.js +0 -2
  180. package/lib/utils/ssTestHack.js +0 -10
  181. package/lib/utils/switchBranch.js +0 -4
  182. package/lib/utils/urlConcat.js +0 -4
  183. package/lib/utils/useExitCleanup.js +9 -10
  184. package/npm8.md +9 -9
  185. package/package.json +146 -148
  186. package/postpublish.js +6 -6
  187. package/templates/app/.eslintrc.js +140 -140
  188. package/templates/app/README.md +12 -12
  189. package/templates/app/app/index.html +24 -24
  190. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  191. package/templates/app/app/properties/i18nkeys.json +3 -3
  192. package/templates/app/docs/all.html +69 -69
  193. package/templates/app/mockapi/index.js +18 -18
  194. package/templates/app/package.json +37 -37
  195. package/templates/app/src/actions/SampleActions/index.js +37 -37
  196. package/templates/app/src/actions/index.js +65 -65
  197. package/templates/app/src/appUrls.js +19 -19
  198. package/templates/app/src/components/Alert/Alert.js +134 -134
  199. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  200. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  201. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  202. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  203. package/templates/app/src/components/Sample/SampleList.js +61 -61
  204. package/templates/app/src/components/Slider/Slider.css +41 -41
  205. package/templates/app/src/components/Slider/Slider.js +55 -55
  206. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  207. package/templates/app/src/containers/AppContainer/index.js +96 -96
  208. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  209. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  210. package/templates/app/src/containers/DevTools/index.js +10 -10
  211. package/templates/app/src/containers/Header/index.js +67 -67
  212. package/templates/app/src/containers/Header/index.module.css +43 -43
  213. package/templates/app/src/containers/Redirect/index.js +63 -63
  214. package/templates/app/src/containers/Redirector/index.js +47 -47
  215. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  216. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  217. package/templates/app/src/historyChange.js +5 -5
  218. package/templates/app/src/index.html +10 -10
  219. package/templates/app/src/index.js +24 -24
  220. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  221. package/templates/app/src/reducers/alertData.js +11 -11
  222. package/templates/app/src/reducers/index.js +6 -6
  223. package/templates/app/src/reducers/samples.js +19 -19
  224. package/templates/app/src/store/configureStore.dev.js +51 -51
  225. package/templates/app/src/store/configureStore.js +5 -5
  226. package/templates/app/src/store/configureStore.prod.js +26 -26
  227. package/templates/app/src/util/Common.js +5 -5
  228. package/templates/app/src/util/RequestAPI.js +132 -132
  229. package/templates/docs/all.html +249 -249
  230. package/templates/docs/component.html +178 -178
  231. package/templates/docs/components.html +221 -221
  232. package/templates/docs/css/b.min.css +6 -6
  233. package/templates/docs/css/component.css +42 -42
  234. package/templates/docs/css/componentTest.css +6 -6
  235. package/templates/docs/css/hopscotch.css +585 -585
  236. package/templates/docs/css/style.css +1022 -1022
  237. package/templates/docs/impactReportTemplate.html +154 -154
  238. package/templates/docs/index.html +1501 -1493
  239. package/templates/docs/js/active-line.js +72 -72
  240. package/templates/docs/js/b.min.js +7 -7
  241. package/templates/docs/js/codemirror.js +9680 -9680
  242. package/templates/docs/js/designTokens.js +334 -334
  243. package/templates/docs/js/j.min.js +4 -4
  244. package/templates/docs/js/javascript.js +874 -874
  245. package/templates/docs/js/matchbrackets.js +145 -145
@@ -5,17 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  const MODULE_TYPE = 'css/mini-extract';
8
-
9
8
  class PublicPathCallbackPlugin {
10
9
  constructor({
11
10
  callback
12
11
  }) {
13
12
  this.publicPathCallback = callback;
14
13
  }
15
-
16
14
  getCssChunkObject(mainChunk) {
17
15
  const obj = {};
18
-
19
16
  for (const chunk of mainChunk.getAllAsyncChunks()) {
20
17
  for (const module of chunk.modulesIterable) {
21
18
  if (module.type === MODULE_TYPE) {
@@ -24,25 +21,20 @@ class PublicPathCallbackPlugin {
24
21
  }
25
22
  }
26
23
  }
27
-
28
24
  return obj;
29
25
  }
30
-
31
26
  needChunkOnDemandLoadingCode(chunk) {
32
27
  for (const chunkGroup of chunk.groupsIterable) {
33
28
  if (chunkGroup.getNumberOfChildren() > 0) {
34
29
  return true;
35
30
  }
36
31
  }
37
-
38
32
  return false;
39
33
  }
40
-
41
34
  apply(compiler) {
42
35
  compiler.hooks.thisCompilation.tap('PublicPathCallbackPlugin', compilation => {
43
36
  compilation.mainTemplate.hooks.requireEnsure.tap('PublicPathCallbackPlugin', (source, chunk) => {
44
37
  const chunkMap = this.getCssChunkObject(chunk);
45
-
46
38
  if (Object.keys(chunkMap).length > 0) {
47
39
  return source.replace('__webpack_require__.p', `${this.publicPathCallback}("css")`);
48
40
  }
@@ -56,8 +48,6 @@ class PublicPathCallbackPlugin {
56
48
  });
57
49
  });
58
50
  }
59
-
60
51
  }
61
-
62
52
  var _default = PublicPathCallbackPlugin;
63
53
  exports.default = _default;
@@ -4,29 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _webpackSources = require("webpack-sources");
11
-
12
9
  var _utils = require("../utils");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  const MODULE_TYPE = 'css/mini-extract';
17
12
  let {
18
13
  chunkSplitEnable
19
14
  } = (0, _utils.getOptions)().i18n || {};
20
-
21
15
  let filenameParser = filename => {
22
16
  let filepaths = filename.split('/');
23
17
  let hashedName = filepaths[filepaths.length - 1];
24
-
25
18
  let {
26
19
  name,
27
20
  ext
28
21
  } = _path.default.parse(hashedName);
29
-
30
22
  let nameparts = name.split('.');
31
23
  return {
32
24
  name: nameparts.slice(0, nameparts.length - 1).join('.') + ext,
@@ -34,15 +26,14 @@ let filenameParser = filename => {
34
26
  ext
35
27
  };
36
28
  };
37
-
38
29
  class PublicPathChangePlugin {
39
30
  constructor({
40
31
  publicPaths,
41
32
  resourceHints
42
33
  }) {
43
34
  if (Array.isArray(publicPaths)) {
44
- let [js, css, image, font, i18njs] = publicPaths; //eslint-disable-next-line
45
-
35
+ let [js, css, image, font, i18njs] = publicPaths;
36
+ //eslint-disable-next-line
46
37
  publicPaths = {
47
38
  __REACT_CLI_PUBLIC_PATHS__: {
48
39
  js,
@@ -53,14 +44,11 @@ class PublicPathChangePlugin {
53
44
  }
54
45
  };
55
46
  }
56
-
57
47
  this.publicPaths = publicPaths;
58
48
  this.resourceHints = resourceHints;
59
49
  }
60
-
61
50
  getCssChunkObject(mainChunk) {
62
51
  const obj = {};
63
-
64
52
  for (const chunk of mainChunk.getAllAsyncChunks()) {
65
53
  for (const module of chunk.modulesIterable) {
66
54
  if (module.type === MODULE_TYPE) {
@@ -69,42 +57,34 @@ class PublicPathChangePlugin {
69
57
  }
70
58
  }
71
59
  }
72
-
73
60
  return obj;
74
61
  }
75
-
76
62
  needChunkOnDemandLoadingCode(chunk) {
77
63
  for (const chunkGroup of chunk.groupsIterable) {
78
64
  if (chunkGroup.getNumberOfChildren() > 0) {
79
65
  return true;
80
66
  }
81
67
  }
82
-
83
68
  return false;
84
69
  }
85
-
86
70
  getResourceHints(resourceHints, manifest, publicPaths) {
87
71
  let ruleMapping = {};
88
72
  let validFiles = Object.keys(manifest).filter(filename => {
89
73
  let isValidFile = false;
90
-
91
74
  for (let pattern of resourceHints) {
92
75
  if (typeof pattern === 'string') {
93
76
  isValidFile = new RegExp(pattern).test(filename);
94
77
  } else {
95
78
  isValidFile = new RegExp(pattern.pattern).test(filename);
96
79
  }
97
-
98
80
  if (isValidFile) {
99
81
  ruleMapping[filename] = typeof pattern !== 'string' ? pattern : {};
100
82
  break;
101
83
  }
102
84
  }
103
-
104
85
  return isValidFile;
105
86
  });
106
87
  let resourceHintsContent = '';
107
-
108
88
  for (let file of validFiles) {
109
89
  let {
110
90
  fileType,
@@ -113,15 +93,12 @@ class PublicPathChangePlugin {
113
93
  let rules = ruleMapping[file];
114
94
  resourceHintsContent += `<link rel=${rules.hint || 'preload'} href='${publicPaths[fileType] + filename}'${rules.hint === 'prefetch' ? '' : `as='${fileType}' crossorigin='${rules.crossorigin || 'false'}'`} />`;
115
95
  }
116
-
117
96
  return resourceHintsContent;
118
97
  }
119
-
120
98
  apply(compiler) {
121
99
  compiler.hooks.thisCompilation.tap('PublicPathChangePlugin', compilation => {
122
100
  compilation.mainTemplate.hooks.requireEnsure.tap('PublicPathChangePlugin', (source, chunk) => {
123
101
  const chunkMap = this.getCssChunkObject(chunk);
124
-
125
102
  if (Object.keys(chunkMap).length > 0) {
126
103
  return source.replace('__webpack_require__.p', '__REACT_CLI_CSS_PUBLIC_PATH__');
127
104
  }
@@ -142,7 +119,6 @@ class PublicPathChangePlugin {
142
119
  name: filename
143
120
  } = asset;
144
121
  let fileType = (0, _utils.getFileType)(filename);
145
-
146
122
  if (fileType === 'image' || fileType === 'font') {
147
123
  let {
148
124
  name,
@@ -156,14 +132,12 @@ class PublicPathChangePlugin {
156
132
  filename
157
133
  };
158
134
  }
159
-
160
135
  return files;
161
136
  }, {});
162
137
  Object.keys(compilation.assets).forEach(filename => {
163
138
  if (Array.isArray(cdns)) {
164
139
  cdns.forEach(cdn => {
165
140
  let source = compilation.assets[filename].source();
166
-
167
141
  if (/\.css$/g.test(filename)) {
168
142
  let publicPaths = this.publicPaths[cdn];
169
143
  source = (0, _utils.cssUrlReplacer)(source, publicPaths, manifest, cdn);
@@ -174,7 +148,6 @@ class PublicPathChangePlugin {
174
148
  image,
175
149
  font
176
150
  } = this.publicPaths[cdn];
177
-
178
151
  if (typeof source === 'string') {
179
152
  source = source.replace(/__REACT_CLI_JS_PUBLIC_PATH__/g, `"${js}"`);
180
153
  source = source.replace(/__REACT_CLI_CSS_PUBLIC_PATH__/g, `"${css}"`);
@@ -190,7 +163,6 @@ class PublicPathChangePlugin {
190
163
  source = source.replace(new RegExp('<script defer src="([^"]*)"', 'g'), (match, arg) => match.replace(arg, js + arg));
191
164
  source = source.replace(new RegExp('<link href="([^"]*)"', 'g'), (match, arg) => match.replace(arg, css + arg));
192
165
  let [i18nStr] = source.match(/<!--I18nInfoToServer(.*?)I18nInfoToServer-->/gm);
193
-
194
166
  if (i18nStr && !chunkSplitEnable) {
195
167
  try {
196
168
  let [i18nObj] = i18nStr.match(/{(.*?)}/gm);
@@ -201,26 +173,22 @@ class PublicPathChangePlugin {
201
173
  source = source.replace(/<!--I18nInfoToServer(.*?)I18nInfoToServer-->/gm, `<!--I18nInfoToServer${JSON.stringify(i18nObj)}I18nInfoToServer-->`);
202
174
  } catch (e) {
203
175
  // 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
-
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
206
178
  console.warn(e);
207
179
  }
208
180
  }
209
-
210
181
  if (Array.isArray(this.resourceHints) && this.resourceHints.length) {
211
182
  let resourceHintsContent = this.getResourceHints(this.resourceHints, manifest, this.publicPaths[cdn]);
212
183
  source = source.replace(/<\/head>/g, `${resourceHintsContent}</head>`);
213
184
  }
214
185
  }
215
-
216
186
  compilation.assets[cdn === '__REACT_CLI_PUBLIC_PATHS__' ? filename : `${cdn}/${filename}`] = new _webpackSources.RawSource(source);
217
187
  });
218
188
  }
219
189
  });
220
190
  });
221
191
  }
222
-
223
192
  }
224
-
225
193
  var _default = PublicPathChangePlugin;
226
194
  exports.default = _default;
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _fs = _interopRequireDefault(require("fs"));
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
-
12
9
  var _redis = _interopRequireDefault(require("redis"));
13
-
14
10
  var _utils = require("../utils");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  let options = (0, _utils.getOptions)();
19
13
  let {
20
14
  app: {
@@ -23,60 +17,47 @@ let {
23
17
  redisPort
24
18
  }
25
19
  } = options;
26
-
27
20
  class reportGeneratePlugin {
28
21
  apply(compiler) {
29
22
  compiler.hooks.emit.tapAsync('reportGeneratePlugin', (compilation, callback) => {
30
23
  function formatBytes(bytes) {
31
24
  if (bytes) {
32
25
  let isNegative;
33
-
34
26
  if (bytes < 0) {
35
27
  bytes = bytes * -1; //eslint-disable-line
36
-
37
28
  isNegative = true;
38
29
  }
39
-
40
30
  if (bytes < 1024) {
41
31
  if (isNegative) {
42
32
  return `- ${bytes} Bytes`;
43
33
  }
44
-
45
34
  return `${bytes} Bytes`;
46
35
  } else if (bytes < 1048576) {
47
36
  if (isNegative) {
48
37
  return `- ${(bytes / 1024).toFixed(3)} KB`;
49
38
  }
50
-
51
39
  return `${(bytes / 1024).toFixed(3)} KB`;
52
40
  } else if (bytes < 1073741824) {
53
41
  if (isNegative) {
54
42
  return `- ${(bytes / 1048576).toFixed(3)} MB`;
55
43
  }
56
-
57
44
  return `${(bytes / 1048576).toFixed(3)} MB`;
58
45
  }
59
-
60
46
  if (isNegative) {
61
47
  return `- ${(bytes / 1073741824).toFixed(3)} GB`;
62
48
  }
63
-
64
49
  return `${(bytes / 1073741824).toFixed(3)} GB`;
65
50
  }
66
51
  }
67
-
68
52
  let client = _redis.default.createClient(redisPort, redisHost);
69
-
70
53
  client.on('connect', () => {
71
54
  (0, _utils.log)('Redis client connected');
72
55
  });
73
56
  client.on('error', err => {
74
57
  (0, _utils.log)(`Something went wrong ${err}`);
75
58
  });
76
-
77
59
  if (_fs.default.existsSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'))) {
78
60
  let statsJSON = _fs.default.readFileSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'), 'utf8');
79
-
80
61
  statsJSON = JSON.parse(statsJSON);
81
62
  let finalObj = {};
82
63
  let branchName = branch ? branch : (0, _utils.getCurrentBranch)();
@@ -93,8 +74,8 @@ class reportGeneratePlugin {
93
74
  name,
94
75
  hash,
95
76
  size
96
- }; // eslint-disable-next-line
97
-
77
+ };
78
+ // eslint-disable-next-line
98
79
  if (!finalObj.hasOwnProperty(name)) {
99
80
  finalObj[name] = tempObject;
100
81
  }
@@ -114,7 +95,6 @@ class reportGeneratePlugin {
114
95
  (0, _utils.log)(err);
115
96
  } else {
116
97
  reply = JSON.parse(reply); // eslint-disable-line
117
-
118
98
  Object.keys(reply).forEach(fileName => {
119
99
  // eslint-disable-next-line
120
100
  if (finalObj.hasOwnProperty(fileName)) {
@@ -128,7 +108,6 @@ class reportGeneratePlugin {
128
108
  }
129
109
  });
130
110
  }
131
-
132
111
  if (reply[fileName].hash !== finalObj[fileName].hash) {
133
112
  reportObj.hashChanged.push({
134
113
  name: fileName,
@@ -141,17 +120,16 @@ class reportGeneratePlugin {
141
120
  }
142
121
  });
143
122
  let json = JSON.stringify(reportObj);
144
-
145
123
  _fs.default.writeFile(_path.default.resolve(process.cwd(), 'build', 'buildtrack.js'), `let statsJson=${json}`, err => {
146
124
  if (err) {
147
125
  throw err;
148
126
  }
149
-
150
127
  (0, _utils.log)('Stats Json generated!');
151
128
  });
152
129
  }
153
130
  });
154
- client.set(branchName, JSON.stringify(finalObj), _redis.default.print); // fs.copyFileSync(
131
+ client.set(branchName, JSON.stringify(finalObj), _redis.default.print);
132
+ // fs.copyFileSync(
155
133
  // path.resolve(
156
134
  // process.cwd(),
157
135
  // 'node_modules',
@@ -163,11 +141,9 @@ class reportGeneratePlugin {
163
141
  // ),
164
142
  // path.resolve(process.cwd(), 'build', 'buildstats.html')
165
143
  // );
166
-
167
144
  client.quit();
168
145
  callback && callback();
169
146
  }
170
-
171
147
  if (err) {
172
148
  (0, _utils.log)(err);
173
149
  }
@@ -175,7 +151,5 @@ class reportGeneratePlugin {
175
151
  }
176
152
  });
177
153
  }
178
-
179
154
  }
180
-
181
155
  exports.default = reportGeneratePlugin;
@@ -4,18 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  const {
9
8
  Template
10
9
  } = require('webpack');
11
-
12
10
  const pluginName = 'RequireVariablePublicPlugin';
13
-
14
11
  class RequireVariablePublicPlugin {
15
12
  constructor(options) {
16
13
  this.requireFuncName = options.requireFuncName;
17
14
  }
18
-
19
15
  apply(compiler) {
20
16
  compiler.hooks.thisCompilation.tap(pluginName, ({
21
17
  mainTemplate
@@ -23,8 +19,6 @@ class RequireVariablePublicPlugin {
23
19
  mainTemplate.hooks.requireExtensions.tap(pluginName, source => Template.asString([source, '', `window[${JSON.stringify(this.requireFuncName)}] = ${mainTemplate.requireFn};`]));
24
20
  });
25
21
  }
26
-
27
22
  }
28
-
29
23
  var _default = RequireVariablePublicPlugin;
30
24
  exports.default = _default;
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  const {
9
8
  Template
10
9
  } = require('webpack');
11
-
12
10
  const pluginName = 'prefetch-preload-chunk-plugin';
13
-
14
11
  class ResourceHintsPlugin {
15
12
  apply(compiler) {
16
13
  compiler.hooks.thisCompilation.tap(pluginName, ({
@@ -20,48 +17,44 @@ class ResourceHintsPlugin {
20
17
  const idNameMap = chunk.getChunkMaps().name;
21
18
  const nameIdMap = {};
22
19
  let needsMap = false;
23
-
24
20
  for (const key in idNameMap) {
25
21
  if (Object.prototype.hasOwnProperty.call(idNameMap, key)) {
26
22
  const value = idNameMap[key];
27
23
  nameIdMap[value] = key;
28
-
29
24
  if (key !== value) {
30
25
  needsMap = true;
31
26
  }
32
27
  }
33
28
  }
34
-
35
29
  return Template.asString([source, '', `${mainTemplate.requireFn}.getChunkId = function getChunkId(chunkId) {`, Template.indent((needsMap ? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`] : []).concat(['return chunkId;'])), '}', `// Prefetch a chunk (${pluginName})`, `${mainTemplate.requireFn}.pfc = function prefetchChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, `${mainTemplate.requireFn}.e(chunkId);`]), '};',
36
- /*
37
- (needsMap
38
- ? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`]
39
- : []
40
- ).concat([
41
- 'var promises = [];',
42
- 'if(installedChunks[chunkId] === undefined) {',
43
- Template.indent([
44
- 'installedChunks[chunkId] = null;',
45
- /* mainTemplate.hooks.linkPrefetch.call('', chunk, hash),
30
+ /*
31
+ (needsMap
32
+ ? [`chunkId = ${JSON.stringify(nameIdMap)}[chunkId]||chunkId;`]
33
+ : []
34
+ ).concat([
35
+ 'var promises = [];',
36
+ 'if(installedChunks[chunkId] === undefined) {',
37
+ Template.indent([
38
+ 'installedChunks[chunkId] = null;',
39
+ /* mainTemplate.hooks.linkPrefetch.call('', chunk, hash),
46
40
  'document.head.appendChild(link);', */
47
-
48
- /*
49
- mainTemplate.hooks.requireEnsure.call('', chunk, hash)
50
- ]),
51
- '}'
52
- ])
53
- ),
54
- '}',
41
+ /*
42
+ mainTemplate.hooks.requireEnsure.call('', chunk, hash)
43
+ ]),
44
+ '}'
45
+ ])
46
+ ),
47
+ '}',
55
48
  */
56
- `// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, 'if(installedChunks[chunkId] === undefined) {', Template.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'document.head.appendChild(link);', `${mainTemplate.requireFn}.e(chunkId);` // 'var head = document.getElementsByTagName(\'head\')[0];',
49
+ `// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkId(chunkId)`, 'if(installedChunks[chunkId] === undefined) {', Template.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'document.head.appendChild(link);', `${mainTemplate.requireFn}.e(chunkId);`
50
+
51
+ // 'var head = document.getElementsByTagName(\'head\')[0];',
57
52
  // mainTemplate.hooks.jsonpScript.call('', chunk, hash),
58
53
  // 'head.appendChild(script);'
59
54
  ]), '}']), '};']);
60
55
  });
61
56
  });
62
57
  }
63
-
64
58
  }
65
-
66
59
  var _default = ResourceHintsPlugin;
67
60
  exports.default = _default;
@@ -4,18 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
9
-
10
8
  var _replaceCssDirTemplate = require("./replaceCssDirTemplate");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  // const HtmlWebpackPlugin = require('html-webpack-plugin');
15
- const pluginName = 'OverwriteCssPathForRTL'; // const pluginName = 'rtl-css-transform-webpack-plugin';
11
+
12
+ const pluginName = 'OverwriteCssPathForRTL';
13
+ // const pluginName = 'rtl-css-transform-webpack-plugin';
14
+
16
15
  // if we choose file name as style.ltr.css and style.rtl.css it will be easy for html template
17
- // this plugin code copy from https://github.com/nicolashemonic/rtl-css-transform-webpack-plugin
18
16
 
17
+ // this plugin code copy from https://github.com/nicolashemonic/rtl-css-transform-webpack-plugin
19
18
  class OverwriteCssPathForRTL {
20
19
  constructor(options = {
21
20
  dirVarName: 'document.dir'
@@ -23,7 +22,6 @@ class OverwriteCssPathForRTL {
23
22
  this.dirVarName = options.dirVarName || 'document.dir';
24
23
  this.templateLabel = options.templateLabel || '{{--dir}}';
25
24
  }
26
-
27
25
  overwriteCssPathinHTML(compilation) {
28
26
  _htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tapAsync(pluginName, (data, cb) => {
29
27
  let {
@@ -36,26 +34,27 @@ class OverwriteCssPathForRTL {
36
34
  }));
37
35
  });
38
36
  }
39
-
40
37
  overwriteCssPathinRequireEnsure(compilation) {
41
38
  // NOTE: if you goig to change an thing here you may check with EFCPlugin, ServiceWorkerPlugin
42
39
  const {
43
40
  mainTemplate
44
- } = compilation; // TODO: must verify when we move to webpack5 ay be we need to change this
41
+ } = compilation;
42
+ // TODO: must verify when we move to webpack5 ay be we need to change this
45
43
  // TODO it's may not be perfect solution, but it will work
46
44
  // mainTemplate.hooks.assetPath.tap(pluginName, (path, data) => {
47
-
48
45
  mainTemplate.hooks.assetPath.tap(pluginName, filePath => {
49
46
  if (!filePath.endsWith('.css"')) {
50
47
  return filePath;
51
48
  }
49
+ const ENDS = '.ltr.css"';
50
+ // if we need total differend temlate for file name it will be too hard
51
+ const templateText = `"+(${this.dirVarName} === "rtl" ? ".rtl": ".ltr")+".css"`;
52
52
 
53
- const ENDS = '.ltr.css"'; // if we need total differend temlate for file name it will be too hard
54
-
55
- const templateText = `"+(${this.dirVarName} === "rtl" ? ".rtl": ".ltr")+".css"`; // const templateText = `"+(${this.dirVarName} === "rtl" ? ".rtl": "")+".css"`;
53
+ // const templateText = `"+(${this.dirVarName} === "rtl" ? ".rtl": "")+".css"`;
56
54
  // NOTE:
57
55
  // we don't use rtlFilename as full replace because it may increace runtime chunk file size
58
56
  // they replace [chunkhash] with object full chunk hash so it may dub
57
+
59
58
  // const templateText = `(${this.dirVarName} === "rtl" ? ${JSON.stringify(this.rtlFilename)}: ${filePath})`;
60
59
  // const templateText = '."+(document.dir === "rtl" ? ".rtl": "")+".css"';
61
60
  // File path going to be like below
@@ -63,18 +62,14 @@ class OverwriteCssPathForRTL {
63
62
  // '"style.css"' ==>> `"style."+(document.dir === "rtl" ? ".rtl": "")+".css"`
64
63
  // replace like this
65
64
  // '.ltr.css"' ==>> `."+(document.dir === "rtl" ? ".rtl": ".ltr")+".css"`
66
-
67
65
  return filePath.replace(ENDS, templateText);
68
66
  });
69
67
  }
70
-
71
68
  apply(compiler) {
72
69
  compiler.hooks.thisCompilation.tap(pluginName, compilation => {
73
70
  this.overwriteCssPathinHTML(compilation);
74
71
  this.overwriteCssPathinRequireEnsure(compilation);
75
72
  });
76
73
  }
77
-
78
74
  }
79
-
80
75
  exports.default = OverwriteCssPathForRTL;
@@ -4,32 +4,28 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.RtlCssPlugin = void 0;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _webpackSources = require("webpack-sources");
11
-
12
9
  var _OverwriteCssPathForRTL = _interopRequireDefault(require("./OverwriteCssPathForRTL"));
13
-
14
10
  var _RTLSplitPlugin = require("../../postcss-plugins/RTLSplitPlugin");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  // import HtmlWebpackPlugin from 'html-webpack-plugin';
19
- // import rtlcss from 'rtlcss';
20
- const pluginName = 'RtlCssPlugin'; // const pluginName = 'rtl-css-transform-webpack-plugin';
21
13
 
22
- const isCss = filename => _path.default.extname(filename) === '.css'; // this plugin code copy from https://github.com/nicolashemonic/rtl-css-transform-webpack-plugin
14
+ // import rtlcss from 'rtlcss';
23
15
 
16
+ const pluginName = 'RtlCssPlugin';
17
+ // const pluginName = 'rtl-css-transform-webpack-plugin';
18
+ const isCss = filename => _path.default.extname(filename) === '.css';
24
19
 
20
+ // this plugin code copy from https://github.com/nicolashemonic/rtl-css-transform-webpack-plugin
25
21
  class RtlCssPlugin {
26
22
  constructor(options = {}) {
27
- /**
28
- * @typedef {Object} Options
29
- * @property {String} filename [not used]
30
- * @property {String} dirVarName
31
- * @property {Boolean} sourcemap
32
- * @property {Object} config
23
+ /**
24
+ * @typedef {Object} Options
25
+ * @property {String} filename [not used]
26
+ * @property {String} dirVarName
27
+ * @property {Boolean} sourcemap
28
+ * @property {Object} config
33
29
  */
34
30
  this.options = {
35
31
  filename: options.filename || '[name].rtl.css',
@@ -43,48 +39,37 @@ class RtlCssPlugin {
43
39
  disableMiniFiySelector: options.disableMiniFiySelector
44
40
  };
45
41
  }
46
-
47
42
  apply(compiler) {
48
43
  new _OverwriteCssPathForRTL.default({
49
44
  templateLabel: this.templateLabel,
50
45
  dirVarName: this.dirVarName
51
- }).apply(compiler); // const { filename, sourcemap, config } = this.options;
46
+ }).apply(compiler);
47
+ // const { filename, sourcemap, config } = this.options;
52
48
  // const { devtool } = compiler.options;
53
49
  // const postcssOptions = {
54
50
  // map: (sourcemap === undefined && !!devtool) || !!sourcemap
55
51
  // };
56
-
57
52
  compiler.hooks.compilation.tap(pluginName, compilation => {
58
53
  compilation.hooks.optimizeChunkAssets.tapAsync(pluginName, (chunks, callback) => {
59
54
  chunks.forEach(chunk => {
60
55
  chunk.files.filter(isCss).forEach(chunkFilename => {
61
56
  const asset = compilation.assets[chunkFilename];
62
57
  const sourceStr = asset.source();
63
-
64
- try {
65
- const {
66
- ltr,
67
- rtl
68
- } = (0, _RTLSplitPlugin.separateRtlAndLtr)(sourceStr, this.rtlSplitOptions); // const result = rtlcss
69
- // .configure(config)
70
- // .process(asset.source(), postcssOptions);
71
-
72
- const assetFilename = chunkFilename.replace('.ltr.', '.rtl.');
73
- compilation.assets[chunkFilename] = new _webpackSources.RawSource(ltr);
74
- compilation.assets[assetFilename] = new _webpackSources.RawSource(rtl);
75
- } catch (error) {
76
- let arr = Array.from(chunk.modulesIterable).map(x => x.resource).filter(x => /\.css$/.test(x));
77
- console.log(chunkFilename); // console.log(arr);
78
-
79
- console.log(arr.length);
80
- }
58
+ const {
59
+ ltr,
60
+ rtl
61
+ } = (0, _RTLSplitPlugin.separateRtlAndLtr)(sourceStr, this.rtlSplitOptions);
62
+ // const result = rtlcss
63
+ // .configure(config)
64
+ // .process(asset.source(), postcssOptions);
65
+ const assetFilename = chunkFilename.replace('.ltr.', '.rtl.');
66
+ compilation.assets[chunkFilename] = new _webpackSources.RawSource(ltr);
67
+ compilation.assets[assetFilename] = new _webpackSources.RawSource(rtl);
81
68
  });
82
69
  });
83
70
  callback();
84
71
  });
85
72
  });
86
73
  }
87
-
88
74
  }
89
-
90
75
  exports.RtlCssPlugin = RtlCssPlugin;