@zohodesk/react-cli 1.1.29-exp.1 → 1.1.29-exp.2

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 (221) hide show
  1. package/lib/babel/babel-option-utils/babel-preset-react-option.js +0 -3
  2. package/lib/babel/cmjs-plugins-presets.js +1 -8
  3. package/lib/babel/es-plugins-presets.js +1 -8
  4. package/lib/common/buildEs.js +1 -0
  5. package/lib/common/getEntries.js +2 -13
  6. package/lib/common/getPublicPathConfig.js +0 -6
  7. package/lib/common/index.js +1 -6
  8. package/lib/common/runPreProcess.js +6 -15
  9. package/lib/common/splitChunks.js +2 -21
  10. package/lib/common/sslcertUpdater.js +7 -18
  11. package/lib/common/templateParameters.js +0 -2
  12. package/lib/common/testPattern.js +10 -21
  13. package/lib/common/valueReplacer.js +1 -16
  14. package/lib/configs/jest.config.js +1 -10
  15. package/lib/configs/libAlias.js +8 -14
  16. package/lib/configs/resolvers.js +4 -14
  17. package/lib/configs/webpack.component.umd.config.js +1 -6
  18. package/lib/configs/webpack.css.umd.config.js +6 -14
  19. package/lib/configs/webpack.dev.config.js +1 -14
  20. package/lib/configs/webpack.docs.config.js +1 -9
  21. package/lib/configs/webpack.impact.config.js +1 -8
  22. package/lib/configs/webpack.prod.config.js +4 -17
  23. package/lib/constants.js +9 -18
  24. package/lib/deprecationLogger.js +0 -7
  25. package/lib/hooks/docsProptypeHook.js +4 -8
  26. package/lib/jest/commitedFilesResult.js +4 -46
  27. package/lib/jest/coverageCollector.js +1 -12
  28. package/lib/jest/jsonMaker.js +0 -6
  29. package/lib/jest/preProcessors/cssPreprocessor.js +1 -9
  30. package/lib/jest/preProcessors/jsPreprocessor.js +1 -6
  31. package/lib/jest/preProcessors/otherFilesPreprocessor.js +1 -4
  32. package/lib/jest/result.js +1 -23
  33. package/lib/jest/run.js +7 -18
  34. package/lib/jest/setup.js +8 -60
  35. package/lib/loaderUtils/configsAssetsLoaders.js +2 -12
  36. package/lib/loaderUtils/getCSSLoaders.js +10 -22
  37. package/lib/loaderUtils/getDevJsLoaders.js +4 -13
  38. package/lib/loaderUtils/index.js +1 -4
  39. package/lib/loaderUtils/tests/windowsModification.test.js +0 -1
  40. package/lib/loaderUtils/windowsModification.js +2 -3
  41. package/lib/loaders/__test__/markdownLoader.spec.js +0 -1
  42. package/lib/loaders/composeLoader.js +13 -37
  43. package/lib/loaders/docsLoader.js +1 -12
  44. package/lib/loaders/docsPropsLoader.js +4 -8
  45. package/lib/loaders/enhancedReactLiveConverter.js +2 -23
  46. package/lib/loaders/fileBountryLoader.js +1 -3
  47. package/lib/loaders/fileLoader.js +12 -23
  48. package/lib/loaders/markdownLoader.js +14 -19
  49. package/lib/loaders/reactLiveConvertor.js +5 -15
  50. package/lib/loaders/scriptInstrumentLoader.js +7 -16
  51. package/lib/loaders/selectorMappingLoader.js +7 -26
  52. package/lib/loaders/workerLoader.js +9 -24
  53. package/lib/logger.js +0 -4
  54. package/lib/middlewares/HMRMiddleware.js +13 -27
  55. package/lib/middlewares/SSTMiddleware.js +1 -5
  56. package/lib/pluginUtils/configHtmlWebpackPlugins.js +1 -24
  57. package/lib/pluginUtils/getDevPlugins.js +9 -42
  58. package/lib/pluginUtils/getDocsPlugins.js +3 -13
  59. package/lib/pluginUtils/getLibraryImactPlugins.js +5 -6
  60. package/lib/pluginUtils/getLibraryPlugins.js +2 -8
  61. package/lib/pluginUtils/getProdPlugins.js +8 -47
  62. package/lib/pluginUtils/getServerPlugins.js +2 -8
  63. package/lib/pluginUtils/getUMDCSSPlugins.js +2 -10
  64. package/lib/pluginUtils/getUMDComponentPlugins.js +2 -10
  65. package/lib/pluginUtils/index.js +1 -9
  66. package/lib/plugins/CdnChangePlugin.js +2 -18
  67. package/lib/plugins/CleanupStatsPlugin.js +0 -5
  68. package/lib/plugins/CssOrderControlPlugin.js +3 -6
  69. package/lib/plugins/CustomAttributePlugin.js +14 -19
  70. package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +3 -23
  71. package/lib/plugins/EFCPlugin.js +20 -34
  72. package/lib/plugins/EFCTemplatePlugin.js +19 -30
  73. package/lib/plugins/EfcResourceCleanupPlugin.js +0 -3
  74. package/lib/plugins/EventsHandlingPlugin.js +2 -4
  75. package/lib/plugins/I18NInjectIntoIndexPlugin.js +11 -37
  76. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +10 -15
  77. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
  78. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +12 -25
  79. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +55 -133
  80. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +12 -23
  81. package/lib/plugins/I18nSplitPlugin/index.js +13 -24
  82. package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +64 -58
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
  84. package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +10 -29
  85. package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +8 -19
  86. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
  87. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
  88. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +1 -8
  89. package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
  90. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -20
  91. package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +0 -1
  92. package/lib/plugins/ManifestPlugin.js +1 -18
  93. package/lib/plugins/MinifyPlugin.js +1 -10
  94. package/lib/plugins/ModuleStatsPlugin.js +1 -24
  95. package/lib/plugins/OptimizeJSPlugin.js +2 -10
  96. package/lib/plugins/PublicPathCallbackPlugin.js +1 -12
  97. package/lib/plugins/PublicPathChangePlugin.js +6 -39
  98. package/lib/plugins/ReportGeneratePlugin.js +5 -32
  99. package/lib/plugins/RequireVariablePublicPlugin.js +1 -8
  100. package/lib/plugins/ResourceHintsPlugin.js +4 -13
  101. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
  102. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +10 -17
  103. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
  104. package/lib/plugins/ScriptInstrumentPlugin.js +1 -8
  105. package/lib/plugins/SelectorPlugin.js +6 -32
  106. package/lib/plugins/ServiceWorkerPlugin.js +5 -22
  107. package/lib/plugins/ShadowDOMSupportPlugin.js +4 -41
  108. package/lib/plugins/SourceMapHookPlugin.js +2 -12
  109. package/lib/plugins/StatsPlugin.js +0 -14
  110. package/lib/plugins/TPHashMappingPlugin.js +3 -18
  111. package/lib/plugins/UnusedFilesFindPlugin.js +4 -39
  112. package/lib/plugins/VariableConversionCollector.js +15 -42
  113. package/lib/plugins/index.js +1 -20
  114. package/lib/plugins/libraryImpactPlugin.js +1 -33
  115. package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +306 -0
  116. package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +363 -0
  117. package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +694 -0
  118. package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +1258 -0
  119. package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +542 -0
  120. package/lib/plugins/newi18nsplitplugin/18nplugin.js +974 -0
  121. package/lib/plugins/newi18nsplitplugin/ChunkManager.js +131 -0
  122. package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +59 -0
  123. package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +262 -0
  124. package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +166 -0
  125. package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +111 -0
  126. package/lib/plugins/newi18nsplitplugin/KeyCollector.js +163 -0
  127. package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +88 -0
  128. package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +101 -0
  129. package/lib/plugins/newi18nsplitplugin/constants.js +162 -0
  130. package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +78 -0
  131. package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +22 -0
  132. package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +18 -0
  133. package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +580 -0
  134. package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +54 -0
  135. package/lib/plugins/utils/classHandling.js +0 -6
  136. package/lib/plugins/utils/fileHandling.js +6 -15
  137. package/lib/plugins/utils/tests/fileHandling.test.js +0 -4
  138. package/lib/plugins/variableConvertorUtils.js +14 -29
  139. package/lib/plugins/webpackwatchrunplugin.js +0 -5
  140. package/lib/postcss-plugins/EmptyPlugin.js +3 -4
  141. package/lib/postcss-plugins/ExcludePlugin.js +1 -5
  142. package/lib/postcss-plugins/IncludePlugin.js +1 -5
  143. package/lib/postcss-plugins/RTLSplitPlugin.js +14 -27
  144. package/lib/postcss-plugins/SelectorReplace.js +1 -16
  145. package/lib/postcss-plugins/ValueReplacer.js +7 -6
  146. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
  147. package/lib/postcss-plugins/__test__/selectorReplace.test.js +6 -3
  148. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +2 -5
  149. package/lib/postcss-plugins/hoverActivePlugin.js +31 -67
  150. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -7
  151. package/lib/postcss-plugins/variableModificationPlugin/index.js +28 -49
  152. package/lib/schemas/index.js +3 -9
  153. package/lib/servers/clusterHubServer.js +1 -11
  154. package/lib/servers/devBuild.js +14 -26
  155. package/lib/servers/docsServer.js +1 -3
  156. package/lib/servers/docsServerCore.js +1 -22
  157. package/lib/servers/getCliPath.js +0 -9
  158. package/lib/servers/helpServer.js +1 -6
  159. package/lib/servers/httpsOptions.js +2 -8
  160. package/lib/servers/impactServer.js +3 -35
  161. package/lib/servers/mockserver.js +1 -10
  162. package/lib/servers/nowatchserver.js +12 -37
  163. package/lib/servers/requireLocalOrGlobal.js +6 -17
  164. package/lib/servers/scrServer.js +14 -21
  165. package/lib/servers/server.js +6 -36
  166. package/lib/servers/ssServer.js +1 -17
  167. package/lib/templates/CoverageScriptTemplate.js +0 -14
  168. package/lib/templates/WMSTemplate.js +7 -13
  169. package/lib/templates/linterConstant.js +2 -4
  170. package/lib/utils/babelPresets.js +3 -7
  171. package/lib/utils/clean.js +3 -9
  172. package/lib/utils/copy.js +1 -7
  173. package/lib/utils/copyTimezones.js +1 -9
  174. package/lib/utils/createEventStream.js +1 -6
  175. package/lib/utils/cssClassNameGenerate.js +10 -30
  176. package/lib/utils/cssURLReplacer.js +1 -22
  177. package/lib/utils/dependencyPostPublish.js +1 -10
  178. package/lib/utils/deprecationSupport.js +7 -32
  179. package/lib/utils/fileUtils.js +1 -28
  180. package/lib/utils/folderIterator.js +2 -13
  181. package/lib/utils/getComponents.js +0 -21
  182. package/lib/utils/getCurrentBranch.js +0 -5
  183. package/lib/utils/getDependenciesImpactList.js +1 -22
  184. package/lib/utils/getFileType.js +2 -10
  185. package/lib/utils/getHash.js +1 -8
  186. package/lib/utils/getIp.js +0 -2
  187. package/lib/utils/getOptions.js +16 -53
  188. package/lib/utils/getServerURL.js +1 -10
  189. package/lib/utils/index.js +4 -51
  190. package/lib/utils/init.js +0 -1
  191. package/lib/utils/initPreCommitHook.js +7 -30
  192. package/lib/utils/jsonHelper.js +3 -22
  193. package/lib/utils/libraryImpactConfig.js +2 -5
  194. package/lib/utils/lint/addScripts.js +2 -5
  195. package/lib/utils/lint/checkExistingConfig.js +3 -12
  196. package/lib/utils/lint/copyConfigs.js +0 -3
  197. package/lib/utils/lint/index.js +0 -9
  198. package/lib/utils/lint/lintScripts.js +0 -1
  199. package/lib/utils/lint/lintSetup.js +3 -4
  200. package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
  201. package/lib/utils/lint/question.js +0 -7
  202. package/lib/utils/lintReporter.js +0 -20
  203. package/lib/utils/log.js +0 -1
  204. package/lib/utils/mailSender.js +1 -8
  205. package/lib/utils/object-manipulation.js +1 -17
  206. package/lib/utils/pullOrigin.js +0 -4
  207. package/lib/utils/reinstallDependencies.js +1 -29
  208. package/lib/utils/removeAttributes.js +1 -8
  209. package/lib/utils/repoClone.js +3 -28
  210. package/lib/utils/request.js +0 -12
  211. package/lib/utils/rtl.js +5 -17
  212. package/lib/utils/selectorReplacer.js +10 -16
  213. package/lib/utils/setEnvVariables.js +0 -2
  214. package/lib/utils/ssTestHack.js +1 -11
  215. package/lib/utils/switchBranch.js +0 -5
  216. package/lib/utils/typeCheck.js +0 -1
  217. package/lib/utils/urlConcat.js +0 -4
  218. package/lib/utils/useExitCleanup.js +9 -10
  219. package/lib/utils/variableConverter.js +22 -31
  220. package/{npm-shrinkwrap.json → package-lock.json} +2098 -1999
  221. package/package.json +1 -1
@@ -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
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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,21 @@ 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
- var _default = PublicPathChangePlugin;
226
- exports.default = _default;
193
+ var _default = exports.default = PublicPathChangePlugin;
@@ -4,19 +4,12 @@ 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
  var _log = require("../utils/log");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
13
  let options = (0, _utils.getOptions)();
21
14
  let {
22
15
  app: {
@@ -25,60 +18,47 @@ let {
25
18
  redisPort
26
19
  }
27
20
  } = options;
28
-
29
21
  class reportGeneratePlugin {
30
22
  apply(compiler) {
31
23
  compiler.hooks.emit.tapAsync('reportGeneratePlugin', (compilation, callback) => {
32
24
  function formatBytes(bytes) {
33
25
  if (bytes) {
34
26
  let isNegative;
35
-
36
27
  if (bytes < 0) {
37
28
  bytes = bytes * -1; //eslint-disable-line
38
-
39
29
  isNegative = true;
40
30
  }
41
-
42
31
  if (bytes < 1024) {
43
32
  if (isNegative) {
44
33
  return `- ${bytes} Bytes`;
45
34
  }
46
-
47
35
  return `${bytes} Bytes`;
48
36
  } else if (bytes < 1048576) {
49
37
  if (isNegative) {
50
38
  return `- ${(bytes / 1024).toFixed(3)} KB`;
51
39
  }
52
-
53
40
  return `${(bytes / 1024).toFixed(3)} KB`;
54
41
  } else if (bytes < 1073741824) {
55
42
  if (isNegative) {
56
43
  return `- ${(bytes / 1048576).toFixed(3)} MB`;
57
44
  }
58
-
59
45
  return `${(bytes / 1048576).toFixed(3)} MB`;
60
46
  }
61
-
62
47
  if (isNegative) {
63
48
  return `- ${(bytes / 1073741824).toFixed(3)} GB`;
64
49
  }
65
-
66
50
  return `${(bytes / 1073741824).toFixed(3)} GB`;
67
51
  }
68
52
  }
69
-
70
53
  let client = _redis.default.createClient(redisPort, redisHost);
71
-
72
54
  client.on('connect', () => {
73
55
  (0, _log.log)('Redis client connected');
74
56
  });
75
57
  client.on('error', err => {
76
58
  (0, _log.log)(`Something went wrong ${err}`);
77
59
  });
78
-
79
60
  if (_fs.default.existsSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'))) {
80
61
  let statsJSON = _fs.default.readFileSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'), 'utf8');
81
-
82
62
  statsJSON = JSON.parse(statsJSON);
83
63
  let finalObj = {};
84
64
  let branchName = branch ? branch : (0, _utils.getCurrentBranch)();
@@ -95,8 +75,8 @@ class reportGeneratePlugin {
95
75
  name,
96
76
  hash,
97
77
  size
98
- }; // eslint-disable-next-line
99
-
78
+ };
79
+ // eslint-disable-next-line
100
80
  if (!finalObj.hasOwnProperty(name)) {
101
81
  finalObj[name] = tempObject;
102
82
  }
@@ -116,7 +96,6 @@ class reportGeneratePlugin {
116
96
  (0, _log.log)(err);
117
97
  } else {
118
98
  reply = JSON.parse(reply); // eslint-disable-line
119
-
120
99
  Object.keys(reply).forEach(fileName => {
121
100
  // eslint-disable-next-line
122
101
  if (finalObj.hasOwnProperty(fileName)) {
@@ -130,7 +109,6 @@ class reportGeneratePlugin {
130
109
  }
131
110
  });
132
111
  }
133
-
134
112
  if (reply[fileName].hash !== finalObj[fileName].hash) {
135
113
  reportObj.hashChanged.push({
136
114
  name: fileName,
@@ -143,17 +121,16 @@ class reportGeneratePlugin {
143
121
  }
144
122
  });
145
123
  let json = JSON.stringify(reportObj);
146
-
147
124
  _fs.default.writeFile(_path.default.resolve(process.cwd(), 'build', 'buildtrack.js'), `let statsJson=${json}`, err => {
148
125
  if (err) {
149
126
  throw err;
150
127
  }
151
-
152
128
  (0, _log.log)('Stats Json generated!');
153
129
  });
154
130
  }
155
131
  });
156
- client.set(branchName, JSON.stringify(finalObj), _redis.default.print); // fs.copyFileSync(
132
+ client.set(branchName, JSON.stringify(finalObj), _redis.default.print);
133
+ // fs.copyFileSync(
157
134
  // path.resolve(
158
135
  // process.cwd(),
159
136
  // 'node_modules',
@@ -165,11 +142,9 @@ class reportGeneratePlugin {
165
142
  // ),
166
143
  // path.resolve(process.cwd(), 'build', 'buildstats.html')
167
144
  // );
168
-
169
145
  client.quit();
170
146
  callback && callback();
171
147
  }
172
-
173
148
  if (err) {
174
149
  (0, _log.log)(err);
175
150
  }
@@ -177,7 +152,5 @@ class reportGeneratePlugin {
177
152
  }
178
153
  });
179
154
  }
180
-
181
155
  }
182
-
183
156
  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,5 @@ 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
- var _default = RequireVariablePublicPlugin;
30
- exports.default = _default;
23
+ var _default = exports.default = RequireVariablePublicPlugin;
@@ -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 = 'prefetch-preload-chunk-plugin';
13
-
14
11
  class ResourceHintsPlugin {
15
12
  constructor(options) {
16
13
  this.options = options;
17
14
  }
18
-
19
15
  apply(compiler) {
20
16
  compiler.hooks.thisCompilation.tap(pluginName, ({
21
17
  mainTemplate
@@ -27,18 +23,15 @@ class ResourceHintsPlugin {
27
23
  const idNameMap = chunk.getChunkMaps().name;
28
24
  const nameIdMap = {};
29
25
  let needsMap = allowPrefetchingMultipleChunks;
30
-
31
26
  for (const key in idNameMap) {
32
27
  if (Object.prototype.hasOwnProperty.call(idNameMap, key)) {
33
28
  const value = idNameMap[key];
34
29
  nameIdMap[value] = key;
35
-
36
30
  if (key !== value) {
37
31
  needsMap = true;
38
32
  }
39
33
  }
40
34
  }
41
-
42
35
  return Template.asString([source, Template.indent([`const nameToChunkIdMap = ${JSON.stringify(needsMap ? nameIdMap : {})};`, 'const chunkNames = Object.keys(nameToChunkIdMap);']), `${mainTemplate.requireFn}.getChunkIds = function getChunkIds(chunkId) {`, Template.indent([allowPrefetchingMultipleChunks ? `const isRegExAsChunkId = chunkId instanceof RegExp;
43
36
  return isRegExAsChunkId ? chunkNames.filter(chunkName => chunkId.test(chunkName)).map(chunkName => nameToChunkIdMap[chunkName]) : [nameToChunkIdMap[chunkId] || chunkId];` : needsMap ? 'return [nameToChunkIdMap[chunkId] || chunkId];' : 'return [chunkId];']), '}', `// Prefetch a chunk (${pluginName})`, `${mainTemplate.requireFn}.pfc = function prefetchChunk(chunkId) {`, Template.indent([`let chunkIds = ${mainTemplate.requireFn}.getChunkIds(chunkId)`, `chunkIds.forEach(idOfAChunk => {
44
37
  ${mainTemplate.requireFn}.e(idOfAChunk);
@@ -54,7 +47,6 @@ class ResourceHintsPlugin {
54
47
  'installedChunks[chunkId] = null;',
55
48
  /* mainTemplate.hooks.linkPrefetch.call('', chunk, hash),
56
49
  'document.head.appendChild(link);', */
57
-
58
50
  /*
59
51
  mainTemplate.hooks.requireEnsure.call('', chunk, hash)
60
52
  ]),
@@ -63,15 +55,14 @@ class ResourceHintsPlugin {
63
55
  ),
64
56
  '}',
65
57
  */
66
- `// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkIds(chunkId)[0]`, '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];',
58
+ `// Preload a chunk (${pluginName})`, `${mainTemplate.requireFn}.plc = function preloadChunk(chunkId) {`, Template.indent([`chunkId = ${mainTemplate.requireFn}.getChunkIds(chunkId)[0]`, 'if(installedChunks[chunkId] === undefined) {', Template.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'document.head.appendChild(link);', `${mainTemplate.requireFn}.e(chunkId);`
59
+
60
+ // 'var head = document.getElementsByTagName(\'head\')[0];',
67
61
  // mainTemplate.hooks.jsonpScript.call('', chunk, hash),
68
62
  // 'head.appendChild(script);'
69
63
  ]), '}']), '};']);
70
64
  });
71
65
  });
72
66
  }
73
-
74
67
  }
75
-
76
- var _default = ResourceHintsPlugin;
77
- exports.default = _default;
68
+ var _default = exports.default = ResourceHintsPlugin;
@@ -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");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ // const HtmlWebpackPlugin = require('html-webpack-plugin');
11
11
 
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const pluginName = 'OverwriteCssPathForRTL';
13
+ // const pluginName = 'rtl-css-transform-webpack-plugin';
13
14
 
14
- // const HtmlWebpackPlugin = require('html-webpack-plugin');
15
- const pluginName = 'OverwriteCssPathForRTL'; // const pluginName = 'rtl-css-transform-webpack-plugin';
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,24 +4,20 @@ 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
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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
23
  /**
@@ -43,17 +39,16 @@ 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 => {
@@ -63,10 +58,10 @@ class RtlCssPlugin {
63
58
  const {
64
59
  ltr,
65
60
  rtl
66
- } = (0, _RTLSplitPlugin.separateRtlAndLtr)(sourceStr, this.rtlSplitOptions); // const result = rtlcss
61
+ } = (0, _RTLSplitPlugin.separateRtlAndLtr)(sourceStr, this.rtlSplitOptions);
62
+ // const result = rtlcss
67
63
  // .configure(config)
68
64
  // .process(asset.source(), postcssOptions);
69
-
70
65
  const assetFilename = chunkFilename.replace('.ltr.', '.rtl.');
71
66
  compilation.assets[chunkFilename] = new _webpackSources.RawSource(ltr);
72
67
  compilation.assets[assetFilename] = new _webpackSources.RawSource(rtl);
@@ -76,7 +71,5 @@ class RtlCssPlugin {
76
71
  });
77
72
  });
78
73
  }
79
-
80
74
  }
81
-
82
75
  exports.RtlCssPlugin = RtlCssPlugin;
@@ -6,21 +6,18 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.replaceCssDirTemplate = replaceCssDirTemplate;
7
7
  exports.replaceCssDirTemplateMapper = replaceCssDirTemplateMapper;
8
8
  exports.strFunctionTempalteToReplaceCssDir = void 0;
9
-
10
9
  function replaceCssDirTemplate(filePath, cssDirTemplate) {
11
- return filePath.endsWith('.ltr.css') ? // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
10
+ return filePath.endsWith('.ltr.css') ?
11
+ // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
12
12
  filePath.replace('.ltr.css', `.${cssDirTemplate}.css`) : filePath;
13
13
  }
14
-
15
14
  function replaceCssDirTemplateMapper(assets, cssDirTemplate) {
16
15
  return assets.map(filePath => replaceCssDirTemplate(filePath, cssDirTemplate));
17
16
  }
18
-
19
17
  const strFunctionTempalteToReplaceCssDir = cssDirTemplate => `function replaceCssDirTemplate(filePath, cssDirTemplate) {
20
18
  return filePath.endsWith(".ltr.css")
21
19
  ? // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
22
20
  filePath.replace(".ltr.css", ".${cssDirTemplate}.css")
23
21
  : filePath;
24
22
  }`;
25
-
26
23
  exports.strFunctionTempalteToReplaceCssDir = strFunctionTempalteToReplaceCssDir;
@@ -4,15 +4,10 @@ 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
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
10
  let coverageScript = _fs.default.readFileSync(_path.default.resolve(__dirname, '..', 'templates', 'CoverageScriptTemplate.js')).toString();
15
-
16
11
  class ScriptInstrumentPlugin {
17
12
  apply(compiler) {
18
13
  compiler.hooks.emit.tapAsync('ScriptInstrumentPlugin', (compilation, callback) => {
@@ -30,7 +25,5 @@ class ScriptInstrumentPlugin {
30
25
  callback();
31
26
  });
32
27
  }
33
-
34
28
  }
35
-
36
29
  exports.default = ScriptInstrumentPlugin;