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

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 (222) hide show
  1. package/README.md +18 -0
  2. package/lib/babel/babel-option-utils/babel-preset-react-option.js +3 -0
  3. package/lib/babel/cmjs-plugins-presets.js +13 -2
  4. package/lib/babel/es-plugins-presets.js +14 -3
  5. package/lib/common/buildEs.js +0 -1
  6. package/lib/common/getEntries.js +13 -2
  7. package/lib/common/getPublicPathConfig.js +6 -0
  8. package/lib/common/index.js +6 -1
  9. package/lib/common/runPreProcess.js +15 -6
  10. package/lib/common/splitChunks.js +21 -2
  11. package/lib/common/sslcertUpdater.js +18 -7
  12. package/lib/common/templateParameters.js +2 -0
  13. package/lib/common/testPattern.js +21 -10
  14. package/lib/common/valueReplacer.js +16 -1
  15. package/lib/configs/jest.config.js +11 -2
  16. package/lib/configs/libAlias.js +16 -10
  17. package/lib/configs/resolvers.js +16 -6
  18. package/lib/configs/webpack.component.umd.config.js +6 -1
  19. package/lib/configs/webpack.css.umd.config.js +14 -6
  20. package/lib/configs/webpack.dev.config.js +14 -1
  21. package/lib/configs/webpack.docs.config.js +9 -1
  22. package/lib/configs/webpack.impact.config.js +8 -1
  23. package/lib/configs/webpack.prod.config.js +17 -4
  24. package/lib/constants.js +18 -9
  25. package/lib/deprecationLogger.js +7 -0
  26. package/lib/hooks/docsProptypeHook.js +8 -4
  27. package/lib/jest/commitedFilesResult.js +46 -4
  28. package/lib/jest/coverageCollector.js +12 -1
  29. package/lib/jest/jsonMaker.js +6 -0
  30. package/lib/jest/preProcessors/cssPreprocessor.js +9 -1
  31. package/lib/jest/preProcessors/jsPreprocessor.js +11 -2
  32. package/lib/jest/preProcessors/otherFilesPreprocessor.js +4 -1
  33. package/lib/jest/result.js +23 -1
  34. package/lib/jest/run.js +18 -7
  35. package/lib/jest/setup.js +60 -8
  36. package/lib/loaderUtils/configsAssetsLoaders.js +12 -2
  37. package/lib/loaderUtils/getCSSLoaders.js +22 -10
  38. package/lib/loaderUtils/getDevJsLoaders.js +13 -4
  39. package/lib/loaderUtils/index.js +4 -1
  40. package/lib/loaderUtils/tests/windowsModification.test.js +1 -0
  41. package/lib/loaderUtils/windowsModification.js +3 -2
  42. package/lib/loaders/__test__/markdownLoader.spec.js +1 -0
  43. package/lib/loaders/composeLoader.js +37 -13
  44. package/lib/loaders/docsLoader.js +12 -1
  45. package/lib/loaders/docsPropsLoader.js +8 -4
  46. package/lib/loaders/enhancedReactLiveConverter.js +23 -2
  47. package/lib/loaders/fileBountryLoader.js +3 -1
  48. package/lib/loaders/fileLoader.js +23 -12
  49. package/lib/loaders/markdownLoader.js +19 -14
  50. package/lib/loaders/reactLiveConvertor.js +15 -5
  51. package/lib/loaders/scriptInstrumentLoader.js +16 -7
  52. package/lib/loaders/selectorMappingLoader.js +26 -7
  53. package/lib/loaders/workerLoader.js +24 -9
  54. package/lib/logger.js +4 -0
  55. package/lib/middlewares/HMRMiddleware.js +27 -13
  56. package/lib/middlewares/SSTMiddleware.js +5 -1
  57. package/lib/pluginUtils/configHtmlWebpackPlugins.js +24 -1
  58. package/lib/pluginUtils/getDevPlugins.js +42 -9
  59. package/lib/pluginUtils/getDocsPlugins.js +13 -3
  60. package/lib/pluginUtils/getLibraryImactPlugins.js +6 -5
  61. package/lib/pluginUtils/getLibraryPlugins.js +8 -2
  62. package/lib/pluginUtils/getProdPlugins.js +47 -8
  63. package/lib/pluginUtils/getServerPlugins.js +8 -2
  64. package/lib/pluginUtils/getUMDCSSPlugins.js +10 -2
  65. package/lib/pluginUtils/getUMDComponentPlugins.js +10 -2
  66. package/lib/pluginUtils/index.js +9 -1
  67. package/lib/plugins/CdnChangePlugin.js +18 -2
  68. package/lib/plugins/CleanupStatsPlugin.js +5 -0
  69. package/lib/plugins/CssOrderControlPlugin.js +6 -3
  70. package/lib/plugins/CustomAttributePlugin.js +19 -14
  71. package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +23 -3
  72. package/lib/plugins/EFCPlugin.js +34 -20
  73. package/lib/plugins/EFCTemplatePlugin.js +30 -19
  74. package/lib/plugins/EfcResourceCleanupPlugin.js +3 -0
  75. package/lib/plugins/EventsHandlingPlugin.js +4 -2
  76. package/lib/plugins/I18NInjectIntoIndexPlugin.js +37 -14
  77. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +15 -10
  78. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
  79. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +155 -78
  80. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +81 -198
  81. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +23 -12
  82. package/lib/plugins/I18nSplitPlugin/index.js +24 -13
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
  85. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
  86. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +8 -1
  87. package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
  88. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -0
  89. package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +1 -0
  90. package/lib/plugins/ManifestPlugin.js +18 -1
  91. package/lib/plugins/MinifyPlugin.js +10 -1
  92. package/lib/plugins/ModuleStatsPlugin.js +24 -1
  93. package/lib/plugins/OptimizeJSPlugin.js +10 -2
  94. package/lib/plugins/PublicPathCallbackPlugin.js +12 -1
  95. package/lib/plugins/PublicPathChangePlugin.js +39 -6
  96. package/lib/plugins/ReportGeneratePlugin.js +32 -5
  97. package/lib/plugins/RequireVariablePublicPlugin.js +8 -1
  98. package/lib/plugins/ResourceHintsPlugin.js +13 -4
  99. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
  100. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +17 -10
  101. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
  102. package/lib/plugins/ScriptInstrumentPlugin.js +8 -1
  103. package/lib/plugins/SelectorPlugin.js +32 -6
  104. package/lib/plugins/ServiceWorkerPlugin.js +22 -5
  105. package/lib/plugins/ShadowDOMSupportPlugin.js +41 -4
  106. package/lib/plugins/SourceMapHookPlugin.js +12 -2
  107. package/lib/plugins/StatsPlugin.js +14 -0
  108. package/lib/plugins/TPHashMappingPlugin.js +18 -3
  109. package/lib/plugins/UnusedFilesFindPlugin.js +39 -4
  110. package/lib/plugins/VariableConversionCollector.js +42 -15
  111. package/lib/plugins/index.js +20 -1
  112. package/lib/plugins/libraryImpactPlugin.js +33 -1
  113. package/lib/plugins/utils/classHandling.js +6 -0
  114. package/lib/plugins/utils/fileHandling.js +15 -6
  115. package/lib/plugins/utils/tests/fileHandling.test.js +4 -0
  116. package/lib/plugins/variableConvertorUtils.js +29 -14
  117. package/lib/plugins/webpackwatchrunplugin.js +5 -0
  118. package/lib/postcss-plugins/EmptyPlugin.js +4 -3
  119. package/lib/postcss-plugins/ExcludePlugin.js +5 -1
  120. package/lib/postcss-plugins/IncludePlugin.js +5 -1
  121. package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
  122. package/lib/postcss-plugins/SelectorReplace.js +16 -1
  123. package/lib/postcss-plugins/ValueReplacer.js +6 -7
  124. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
  125. package/lib/postcss-plugins/__test__/selectorReplace.test.js +3 -6
  126. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +5 -2
  127. package/lib/postcss-plugins/hoverActivePlugin.js +67 -31
  128. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +7 -0
  129. package/lib/postcss-plugins/variableModificationPlugin/index.js +49 -28
  130. package/lib/schemas/index.js +10 -3
  131. package/lib/servers/clusterHubServer.js +11 -1
  132. package/lib/servers/devBuild.js +26 -14
  133. package/lib/servers/docsServer.js +3 -1
  134. package/lib/servers/docsServerCore.js +22 -1
  135. package/lib/servers/getCliPath.js +9 -0
  136. package/lib/servers/helpServer.js +6 -1
  137. package/lib/servers/httpsOptions.js +8 -2
  138. package/lib/servers/impactServer.js +35 -3
  139. package/lib/servers/mockserver.js +10 -1
  140. package/lib/servers/nowatchserver.js +37 -12
  141. package/lib/servers/requireLocalOrGlobal.js +17 -6
  142. package/lib/servers/scrServer.js +21 -14
  143. package/lib/servers/server.js +36 -6
  144. package/lib/servers/ssServer.js +17 -1
  145. package/lib/templates/CoverageScriptTemplate.js +14 -0
  146. package/lib/templates/WMSTemplate.js +13 -7
  147. package/lib/templates/linterConstant.js +4 -2
  148. package/lib/utils/babelPresets.js +7 -3
  149. package/lib/utils/clean.js +9 -3
  150. package/lib/utils/copy.js +7 -1
  151. package/lib/utils/copyTimezones.js +9 -1
  152. package/lib/utils/createEventStream.js +6 -1
  153. package/lib/utils/cssClassNameGenerate.js +30 -10
  154. package/lib/utils/cssURLReplacer.js +22 -1
  155. package/lib/utils/dependencyPostPublish.js +10 -1
  156. package/lib/utils/deprecationSupport.js +32 -7
  157. package/lib/utils/fileUtils.js +28 -1
  158. package/lib/utils/folderIterator.js +13 -2
  159. package/lib/utils/getComponents.js +21 -0
  160. package/lib/utils/getCurrentBranch.js +5 -0
  161. package/lib/utils/getDependenciesImpactList.js +22 -1
  162. package/lib/utils/getFileType.js +10 -2
  163. package/lib/utils/getHash.js +8 -1
  164. package/lib/utils/getIp.js +2 -0
  165. package/lib/utils/getOptions.js +53 -16
  166. package/lib/utils/getServerURL.js +10 -1
  167. package/lib/utils/index.js +51 -4
  168. package/lib/utils/init.js +1 -0
  169. package/lib/utils/initPreCommitHook.js +30 -7
  170. package/lib/utils/jsonHelper.js +22 -3
  171. package/lib/utils/libraryImpactConfig.js +5 -2
  172. package/lib/utils/lint/addScripts.js +5 -2
  173. package/lib/utils/lint/checkExistingConfig.js +12 -3
  174. package/lib/utils/lint/copyConfigs.js +3 -0
  175. package/lib/utils/lint/index.js +9 -0
  176. package/lib/utils/lint/lintScripts.js +1 -0
  177. package/lib/utils/lint/lintSetup.js +4 -3
  178. package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
  179. package/lib/utils/lint/question.js +7 -0
  180. package/lib/utils/lintReporter.js +20 -0
  181. package/lib/utils/log.js +1 -0
  182. package/lib/utils/mailSender.js +8 -1
  183. package/lib/utils/object-manipulation.js +17 -1
  184. package/lib/utils/pullOrigin.js +4 -0
  185. package/lib/utils/reinstallDependencies.js +29 -1
  186. package/lib/utils/removeAttributes.js +8 -1
  187. package/lib/utils/repoClone.js +28 -3
  188. package/lib/utils/request.js +12 -0
  189. package/lib/utils/rtl.js +17 -5
  190. package/lib/utils/selectorReplacer.js +16 -10
  191. package/lib/utils/setEnvVariables.js +2 -0
  192. package/lib/utils/ssTestHack.js +11 -1
  193. package/lib/utils/switchBranch.js +5 -0
  194. package/lib/utils/typeCheck.js +1 -0
  195. package/lib/utils/urlConcat.js +4 -0
  196. package/lib/utils/useExitCleanup.js +10 -9
  197. package/lib/utils/variableConverter.js +31 -22
  198. package/{package-lock.json → npm-shrinkwrap.json} +2333 -2101
  199. package/package.json +3 -2
  200. package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +0 -279
  201. package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +0 -51
  202. package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +0 -48
  203. package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +0 -306
  204. package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +0 -363
  205. package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +0 -694
  206. package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +0 -1258
  207. package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +0 -542
  208. package/lib/plugins/newi18nsplitplugin/18nplugin.js +0 -974
  209. package/lib/plugins/newi18nsplitplugin/ChunkManager.js +0 -131
  210. package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +0 -59
  211. package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +0 -262
  212. package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +0 -166
  213. package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +0 -111
  214. package/lib/plugins/newi18nsplitplugin/KeyCollector.js +0 -163
  215. package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +0 -88
  216. package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +0 -101
  217. package/lib/plugins/newi18nsplitplugin/constants.js +0 -162
  218. package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +0 -78
  219. package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +0 -22
  220. package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +0 -18
  221. package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +0 -580
  222. package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +0 -54
@@ -4,12 +4,19 @@ 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
  var _log = require("../utils/log");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
13
20
  let options = (0, _utils.getOptions)();
14
21
  let {
15
22
  app: {
@@ -18,47 +25,60 @@ let {
18
25
  redisPort
19
26
  }
20
27
  } = options;
28
+
21
29
  class reportGeneratePlugin {
22
30
  apply(compiler) {
23
31
  compiler.hooks.emit.tapAsync('reportGeneratePlugin', (compilation, callback) => {
24
32
  function formatBytes(bytes) {
25
33
  if (bytes) {
26
34
  let isNegative;
35
+
27
36
  if (bytes < 0) {
28
37
  bytes = bytes * -1; //eslint-disable-line
38
+
29
39
  isNegative = true;
30
40
  }
41
+
31
42
  if (bytes < 1024) {
32
43
  if (isNegative) {
33
44
  return `- ${bytes} Bytes`;
34
45
  }
46
+
35
47
  return `${bytes} Bytes`;
36
48
  } else if (bytes < 1048576) {
37
49
  if (isNegative) {
38
50
  return `- ${(bytes / 1024).toFixed(3)} KB`;
39
51
  }
52
+
40
53
  return `${(bytes / 1024).toFixed(3)} KB`;
41
54
  } else if (bytes < 1073741824) {
42
55
  if (isNegative) {
43
56
  return `- ${(bytes / 1048576).toFixed(3)} MB`;
44
57
  }
58
+
45
59
  return `${(bytes / 1048576).toFixed(3)} MB`;
46
60
  }
61
+
47
62
  if (isNegative) {
48
63
  return `- ${(bytes / 1073741824).toFixed(3)} GB`;
49
64
  }
65
+
50
66
  return `${(bytes / 1073741824).toFixed(3)} GB`;
51
67
  }
52
68
  }
69
+
53
70
  let client = _redis.default.createClient(redisPort, redisHost);
71
+
54
72
  client.on('connect', () => {
55
73
  (0, _log.log)('Redis client connected');
56
74
  });
57
75
  client.on('error', err => {
58
76
  (0, _log.log)(`Something went wrong ${err}`);
59
77
  });
78
+
60
79
  if (_fs.default.existsSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'))) {
61
80
  let statsJSON = _fs.default.readFileSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'), 'utf8');
81
+
62
82
  statsJSON = JSON.parse(statsJSON);
63
83
  let finalObj = {};
64
84
  let branchName = branch ? branch : (0, _utils.getCurrentBranch)();
@@ -75,8 +95,8 @@ class reportGeneratePlugin {
75
95
  name,
76
96
  hash,
77
97
  size
78
- };
79
- // eslint-disable-next-line
98
+ }; // eslint-disable-next-line
99
+
80
100
  if (!finalObj.hasOwnProperty(name)) {
81
101
  finalObj[name] = tempObject;
82
102
  }
@@ -96,6 +116,7 @@ class reportGeneratePlugin {
96
116
  (0, _log.log)(err);
97
117
  } else {
98
118
  reply = JSON.parse(reply); // eslint-disable-line
119
+
99
120
  Object.keys(reply).forEach(fileName => {
100
121
  // eslint-disable-next-line
101
122
  if (finalObj.hasOwnProperty(fileName)) {
@@ -109,6 +130,7 @@ class reportGeneratePlugin {
109
130
  }
110
131
  });
111
132
  }
133
+
112
134
  if (reply[fileName].hash !== finalObj[fileName].hash) {
113
135
  reportObj.hashChanged.push({
114
136
  name: fileName,
@@ -121,16 +143,17 @@ class reportGeneratePlugin {
121
143
  }
122
144
  });
123
145
  let json = JSON.stringify(reportObj);
146
+
124
147
  _fs.default.writeFile(_path.default.resolve(process.cwd(), 'build', 'buildtrack.js'), `let statsJson=${json}`, err => {
125
148
  if (err) {
126
149
  throw err;
127
150
  }
151
+
128
152
  (0, _log.log)('Stats Json generated!');
129
153
  });
130
154
  }
131
155
  });
132
- client.set(branchName, JSON.stringify(finalObj), _redis.default.print);
133
- // fs.copyFileSync(
156
+ client.set(branchName, JSON.stringify(finalObj), _redis.default.print); // fs.copyFileSync(
134
157
  // path.resolve(
135
158
  // process.cwd(),
136
159
  // 'node_modules',
@@ -142,9 +165,11 @@ class reportGeneratePlugin {
142
165
  // ),
143
166
  // path.resolve(process.cwd(), 'build', 'buildstats.html')
144
167
  // );
168
+
145
169
  client.quit();
146
170
  callback && callback();
147
171
  }
172
+
148
173
  if (err) {
149
174
  (0, _log.log)(err);
150
175
  }
@@ -152,5 +177,7 @@ class reportGeneratePlugin {
152
177
  }
153
178
  });
154
179
  }
180
+
155
181
  }
182
+
156
183
  exports.default = reportGeneratePlugin;
@@ -4,14 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  const {
8
9
  Template
9
10
  } = require('webpack');
11
+
10
12
  const pluginName = 'RequireVariablePublicPlugin';
13
+
11
14
  class RequireVariablePublicPlugin {
12
15
  constructor(options) {
13
16
  this.requireFuncName = options.requireFuncName;
14
17
  }
18
+
15
19
  apply(compiler) {
16
20
  compiler.hooks.thisCompilation.tap(pluginName, ({
17
21
  mainTemplate
@@ -19,5 +23,8 @@ class RequireVariablePublicPlugin {
19
23
  mainTemplate.hooks.requireExtensions.tap(pluginName, source => Template.asString([source, '', `window[${JSON.stringify(this.requireFuncName)}] = ${mainTemplate.requireFn};`]));
20
24
  });
21
25
  }
26
+
22
27
  }
23
- var _default = exports.default = RequireVariablePublicPlugin;
28
+
29
+ var _default = RequireVariablePublicPlugin;
30
+ exports.default = _default;
@@ -4,14 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  const {
8
9
  Template
9
10
  } = require('webpack');
11
+
10
12
  const pluginName = 'prefetch-preload-chunk-plugin';
13
+
11
14
  class ResourceHintsPlugin {
12
15
  constructor(options) {
13
16
  this.options = options;
14
17
  }
18
+
15
19
  apply(compiler) {
16
20
  compiler.hooks.thisCompilation.tap(pluginName, ({
17
21
  mainTemplate
@@ -23,15 +27,18 @@ class ResourceHintsPlugin {
23
27
  const idNameMap = chunk.getChunkMaps().name;
24
28
  const nameIdMap = {};
25
29
  let needsMap = allowPrefetchingMultipleChunks;
30
+
26
31
  for (const key in idNameMap) {
27
32
  if (Object.prototype.hasOwnProperty.call(idNameMap, key)) {
28
33
  const value = idNameMap[key];
29
34
  nameIdMap[value] = key;
35
+
30
36
  if (key !== value) {
31
37
  needsMap = true;
32
38
  }
33
39
  }
34
40
  }
41
+
35
42
  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;
36
43
  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 => {
37
44
  ${mainTemplate.requireFn}.e(idOfAChunk);
@@ -47,6 +54,7 @@ class ResourceHintsPlugin {
47
54
  'installedChunks[chunkId] = null;',
48
55
  /* mainTemplate.hooks.linkPrefetch.call('', chunk, hash),
49
56
  'document.head.appendChild(link);', */
57
+
50
58
  /*
51
59
  mainTemplate.hooks.requireEnsure.call('', chunk, hash)
52
60
  ]),
@@ -55,14 +63,15 @@ class ResourceHintsPlugin {
55
63
  ),
56
64
  '}',
57
65
  */
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];',
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];',
61
67
  // mainTemplate.hooks.jsonpScript.call('', chunk, hash),
62
68
  // 'head.appendChild(script);'
63
69
  ]), '}']), '};']);
64
70
  });
65
71
  });
66
72
  }
73
+
67
74
  }
68
- var _default = exports.default = ResourceHintsPlugin;
75
+
76
+ var _default = ResourceHintsPlugin;
77
+ exports.default = _default;
@@ -4,17 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
9
+
8
10
  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
- const pluginName = 'OverwriteCssPathForRTL';
13
- // const pluginName = 'rtl-css-transform-webpack-plugin';
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
13
 
14
+ // const HtmlWebpackPlugin = require('html-webpack-plugin');
15
+ const pluginName = 'OverwriteCssPathForRTL'; // const pluginName = 'rtl-css-transform-webpack-plugin';
15
16
  // if we choose file name as style.ltr.css and style.rtl.css it will be easy for html template
16
-
17
17
  // this plugin code copy from https://github.com/nicolashemonic/rtl-css-transform-webpack-plugin
18
+
18
19
  class OverwriteCssPathForRTL {
19
20
  constructor(options = {
20
21
  dirVarName: 'document.dir'
@@ -22,6 +23,7 @@ class OverwriteCssPathForRTL {
22
23
  this.dirVarName = options.dirVarName || 'document.dir';
23
24
  this.templateLabel = options.templateLabel || '{{--dir}}';
24
25
  }
26
+
25
27
  overwriteCssPathinHTML(compilation) {
26
28
  _htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tapAsync(pluginName, (data, cb) => {
27
29
  let {
@@ -34,27 +36,26 @@ class OverwriteCssPathForRTL {
34
36
  }));
35
37
  });
36
38
  }
39
+
37
40
  overwriteCssPathinRequireEnsure(compilation) {
38
41
  // NOTE: if you goig to change an thing here you may check with EFCPlugin, ServiceWorkerPlugin
39
42
  const {
40
43
  mainTemplate
41
- } = compilation;
42
- // TODO: must verify when we move to webpack5 ay be we need to change this
44
+ } = compilation; // TODO: must verify when we move to webpack5 ay be we need to change this
43
45
  // TODO it's may not be perfect solution, but it will work
44
46
  // mainTemplate.hooks.assetPath.tap(pluginName, (path, data) => {
47
+
45
48
  mainTemplate.hooks.assetPath.tap(pluginName, filePath => {
46
49
  if (!filePath.endsWith('.css"')) {
47
50
  return filePath;
48
51
  }
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 templateText = `"+(${this.dirVarName} === "rtl" ? ".rtl": "")+".css"`;
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"`;
54
56
  // NOTE:
55
57
  // we don't use rtlFilename as full replace because it may increace runtime chunk file size
56
58
  // they replace [chunkhash] with object full chunk hash so it may dub
57
-
58
59
  // const templateText = `(${this.dirVarName} === "rtl" ? ${JSON.stringify(this.rtlFilename)}: ${filePath})`;
59
60
  // const templateText = '."+(document.dir === "rtl" ? ".rtl": "")+".css"';
60
61
  // File path going to be like below
@@ -62,14 +63,18 @@ class OverwriteCssPathForRTL {
62
63
  // '"style.css"' ==>> `"style."+(document.dir === "rtl" ? ".rtl": "")+".css"`
63
64
  // replace like this
64
65
  // '.ltr.css"' ==>> `."+(document.dir === "rtl" ? ".rtl": ".ltr")+".css"`
66
+
65
67
  return filePath.replace(ENDS, templateText);
66
68
  });
67
69
  }
70
+
68
71
  apply(compiler) {
69
72
  compiler.hooks.thisCompilation.tap(pluginName, compilation => {
70
73
  this.overwriteCssPathinHTML(compilation);
71
74
  this.overwriteCssPathinRequireEnsure(compilation);
72
75
  });
73
76
  }
77
+
74
78
  }
79
+
75
80
  exports.default = OverwriteCssPathForRTL;
@@ -4,20 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.RtlCssPlugin = void 0;
7
+
7
8
  var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _webpackSources = require("webpack-sources");
11
+
9
12
  var _OverwriteCssPathForRTL = _interopRequireDefault(require("./OverwriteCssPathForRTL"));
13
+
10
14
  var _RTLSplitPlugin = require("../../postcss-plugins/RTLSplitPlugin");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- // import HtmlWebpackPlugin from 'html-webpack-plugin';
13
15
 
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ // import HtmlWebpackPlugin from 'html-webpack-plugin';
14
19
  // import rtlcss from 'rtlcss';
20
+ const pluginName = 'RtlCssPlugin'; // const pluginName = 'rtl-css-transform-webpack-plugin';
21
+
22
+ const isCss = filename => _path.default.extname(filename) === '.css'; // this plugin code copy from https://github.com/nicolashemonic/rtl-css-transform-webpack-plugin
15
23
 
16
- const pluginName = 'RtlCssPlugin';
17
- // const pluginName = 'rtl-css-transform-webpack-plugin';
18
- const isCss = filename => _path.default.extname(filename) === '.css';
19
24
 
20
- // this plugin code copy from https://github.com/nicolashemonic/rtl-css-transform-webpack-plugin
21
25
  class RtlCssPlugin {
22
26
  constructor(options = {}) {
23
27
  /**
@@ -39,16 +43,17 @@ class RtlCssPlugin {
39
43
  disableMiniFiySelector: options.disableMiniFiySelector
40
44
  };
41
45
  }
46
+
42
47
  apply(compiler) {
43
48
  new _OverwriteCssPathForRTL.default({
44
49
  templateLabel: this.templateLabel,
45
50
  dirVarName: this.dirVarName
46
- }).apply(compiler);
47
- // const { filename, sourcemap, config } = this.options;
51
+ }).apply(compiler); // const { filename, sourcemap, config } = this.options;
48
52
  // const { devtool } = compiler.options;
49
53
  // const postcssOptions = {
50
54
  // map: (sourcemap === undefined && !!devtool) || !!sourcemap
51
55
  // };
56
+
52
57
  compiler.hooks.compilation.tap(pluginName, compilation => {
53
58
  compilation.hooks.optimizeChunkAssets.tapAsync(pluginName, (chunks, callback) => {
54
59
  chunks.forEach(chunk => {
@@ -58,10 +63,10 @@ class RtlCssPlugin {
58
63
  const {
59
64
  ltr,
60
65
  rtl
61
- } = (0, _RTLSplitPlugin.separateRtlAndLtr)(sourceStr, this.rtlSplitOptions);
62
- // const result = rtlcss
66
+ } = (0, _RTLSplitPlugin.separateRtlAndLtr)(sourceStr, this.rtlSplitOptions); // const result = rtlcss
63
67
  // .configure(config)
64
68
  // .process(asset.source(), postcssOptions);
69
+
65
70
  const assetFilename = chunkFilename.replace('.ltr.', '.rtl.');
66
71
  compilation.assets[chunkFilename] = new _webpackSources.RawSource(ltr);
67
72
  compilation.assets[assetFilename] = new _webpackSources.RawSource(rtl);
@@ -71,5 +76,7 @@ class RtlCssPlugin {
71
76
  });
72
77
  });
73
78
  }
79
+
74
80
  }
81
+
75
82
  exports.RtlCssPlugin = RtlCssPlugin;
@@ -6,18 +6,21 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.replaceCssDirTemplate = replaceCssDirTemplate;
7
7
  exports.replaceCssDirTemplateMapper = replaceCssDirTemplateMapper;
8
8
  exports.strFunctionTempalteToReplaceCssDir = void 0;
9
+
9
10
  function replaceCssDirTemplate(filePath, cssDirTemplate) {
10
- return filePath.endsWith('.ltr.css') ?
11
- // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
11
+ return filePath.endsWith('.ltr.css') ? // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
12
12
  filePath.replace('.ltr.css', `.${cssDirTemplate}.css`) : filePath;
13
13
  }
14
+
14
15
  function replaceCssDirTemplateMapper(assets, cssDirTemplate) {
15
16
  return assets.map(filePath => replaceCssDirTemplate(filePath, cssDirTemplate));
16
17
  }
18
+
17
19
  const strFunctionTempalteToReplaceCssDir = cssDirTemplate => `function replaceCssDirTemplate(filePath, cssDirTemplate) {
18
20
  return filePath.endsWith(".ltr.css")
19
21
  ? // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
20
22
  filePath.replace(".ltr.css", ".${cssDirTemplate}.css")
21
23
  : filePath;
22
24
  }`;
25
+
23
26
  exports.strFunctionTempalteToReplaceCssDir = strFunctionTempalteToReplaceCssDir;
@@ -4,10 +4,15 @@ 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"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
10
14
  let coverageScript = _fs.default.readFileSync(_path.default.resolve(__dirname, '..', 'templates', 'CoverageScriptTemplate.js')).toString();
15
+
11
16
  class ScriptInstrumentPlugin {
12
17
  apply(compiler) {
13
18
  compiler.hooks.emit.tapAsync('ScriptInstrumentPlugin', (compilation, callback) => {
@@ -25,5 +30,7 @@ class ScriptInstrumentPlugin {
25
30
  callback();
26
31
  });
27
32
  }
33
+
28
34
  }
35
+
29
36
  exports.default = ScriptInstrumentPlugin;
@@ -4,46 +4,62 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _postcss = _interopRequireDefault(require("postcss"));
9
+
8
10
  var _fs = _interopRequireDefault(require("fs"));
11
+
9
12
  var _classHandling = require("./utils/classHandling");
13
+
10
14
  var _fileHandling = require("./utils/fileHandling");
15
+
11
16
  var _windowsModification = require("../loaderUtils/windowsModification");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
13
20
  function selectorWeightPrefixAdder(rootOriginal, selector, excludeStrings) {
14
21
  rootOriginal.walkRules((rule, index) => {
15
22
  const prevNode = rootOriginal.nodes[index - 1] || null;
23
+
16
24
  if ((0, _classHandling.hasPrevNodeIgnore)(index, prevNode, 'updateselector:ignore')) {
17
25
  return;
18
- }
19
- // console.log(rule.selector.split(','));
26
+ } // console.log(rule.selector.split(','));
27
+
28
+
20
29
  const selectorArr = rule.selector.split(',');
21
30
  selectorArr.forEach((singleSelectorStr, index) => {
22
31
  if (excludeStrings.includes(singleSelectorStr.trim())) {
23
32
  return;
24
- }
25
- // NOTE: below logic for attrbute related
33
+ } // NOTE: below logic for attrbute related
34
+
35
+
26
36
  if (singleSelectorStr.includes(']')) {
27
37
  // console.log(singleSelectorStr);
28
38
  const prefixPart = singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim();
29
39
  const selectorPart = singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 1).trim();
40
+
30
41
  if (excludeStrings.includes(selectorPart.trim())) {
31
42
  return;
32
43
  }
44
+
33
45
  if (/^:/gi.test(selectorPart)) {
34
46
  return;
35
47
  }
48
+
36
49
  if (selectorPart !== '') {
37
50
  selectorArr[index] = `${prefixPart} ${selector}${selectorPart}`;
38
51
  }
52
+
39
53
  return;
40
54
  }
55
+
41
56
  selectorArr[index] = `${selector}${singleSelectorStr}`;
42
57
  });
43
58
  rule.selector = selectorArr.join(',\n');
44
59
  });
45
60
  return rootOriginal;
46
61
  }
62
+
47
63
  class SelectorPlugin {
48
64
  constructor(options = {}) {
49
65
  this.optimize = options.optimize;
@@ -51,13 +67,16 @@ class SelectorPlugin {
51
67
  this.exclude = options.exclude;
52
68
  this.patterns = options.patterns;
53
69
  }
70
+
54
71
  apply(compiler) {
55
72
  const {
56
73
  defaultSelector,
57
74
  customFileDetails,
58
75
  excludeStrings
59
76
  } = this.selectorWeightConfig;
77
+
60
78
  const rawdata = _fs.default.readFileSync(customFileDetails);
79
+
61
80
  const data = JSON.parse(rawdata);
62
81
  this.exclude = (0, _windowsModification.windowsModification)(this.exclude);
63
82
  compiler.hooks.compilation.tap('selector-weight-rewrite', compilation => {
@@ -65,6 +84,7 @@ class SelectorPlugin {
65
84
  const mods = modules.filter(x => x.type.includes('css'));
66
85
  mods.forEach(module => {
67
86
  const rootOriginal = _postcss.default.parse(module.content);
87
+
68
88
  const filename = module.issuer.resource;
69
89
  /*
70
90
  input :
@@ -81,6 +101,7 @@ class SelectorPlugin {
81
101
  output :
82
102
  true or false
83
103
  */
104
+
84
105
  if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
85
106
  filename,
86
107
  filterArr: this.patterns.selectorWeight
@@ -102,10 +123,15 @@ class SelectorPlugin {
102
123
  case filename is different ?
103
124
  defaultSelector = '.zoho_desk_ui'
104
125
  */
126
+
127
+
105
128
  module.content = selectorWeightPrefixAdder(rootOriginal, data[filename] ? data[filename].defaultSelector : defaultSelector, excludeStrings).toString();
106
129
  });
107
130
  });
108
131
  });
109
132
  }
133
+
110
134
  }
111
- var _default = exports.default = SelectorPlugin;
135
+
136
+ var _default = SelectorPlugin;
137
+ exports.default = _default;
@@ -4,13 +4,21 @@ 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 _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
13
+
10
14
  var _utils = require("../utils");
15
+
11
16
  var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
17
+
12
18
  var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
14
22
  const {
15
23
  css: {
16
24
  enableRTLSplit
@@ -19,21 +27,24 @@ const {
19
27
  chunkSplitEnable
20
28
  }
21
29
  } = (0, _utils.getOptions)();
30
+
22
31
  class ServiceWorkerPlugin {
23
32
  constructor(options) {
24
33
  this.i18nFileNameTemplate = options.i18nFileNameTemplate;
25
34
  this.fileName = options.fileName;
26
35
  this.serviceWorkerPath = options.filePath;
27
36
  this.writePath = options.exitPath;
28
- this.replaceText = options.replaceText;
29
- // this.publicPaths = options.publicPaths;
37
+ this.replaceText = options.replaceText; // this.publicPaths = options.publicPaths;
30
38
  }
39
+
31
40
  isInitialChunk(chunk) {
32
41
  if ('canBeInitial' in chunk) {
33
42
  return chunk.canBeInitial();
34
43
  }
44
+
35
45
  return chunk.isInitial();
36
46
  }
47
+
37
48
  apply(compiler) {
38
49
  compiler.hooks.emit.tap('ServiceWorkerPlugin', compilation => {
39
50
  _fs.default.readFile(this.serviceWorkerPath, 'utf-8', (err, data) => {
@@ -46,7 +57,6 @@ class ServiceWorkerPlugin {
46
57
  }
47
58
  return chunk.isInitial();
48
59
  }); */
49
-
50
60
  // let [js, css, , , i18nPublicPath] = this.publicPaths;
51
61
  // let initialChunkUrls = [];
52
62
  let allChunkUrls = [];
@@ -59,32 +69,39 @@ class ServiceWorkerPlugin {
59
69
  * if chunkSplitEnable is false means,
60
70
  * serviceWorker will get i18n files path for html
61
71
  */
72
+
62
73
  let initalI18nAssets = chunkSplitEnable ? entrypoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')) : [];
63
74
  chunkSplitEnable && compilation.chunks.filter(c => !this.isInitialChunk(c)).filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).forEach(chunk => {
64
75
  // let isInitial = this.isInitialChunk(chunk);
65
76
  allChunkUrls = allChunkUrls.concat(chunk.files);
66
77
  allI18nAssets.push((0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
67
78
  });
68
-
69
79
  /** Removing source map files from getting added */
80
+
70
81
  initialChunkUrls = initialChunkUrls.filter(fileName => !fileName.endsWith('.map'));
71
82
  allChunkUrls = allChunkUrls.filter(fileName => !fileName.endsWith('.map'));
83
+
72
84
  if (enableRTLSplit) {
73
85
  initialChunkUrls = (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(initialChunkUrls, cssDirTemplate);
74
86
  allChunkUrls = (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(allChunkUrls, cssDirTemplate);
75
87
  }
88
+
76
89
  let mod = data.replace(this.replaceText, `
77
90
  self.assets = ${JSON.stringify(initialChunkUrls.concat(initalI18nAssets))};
78
91
  self.allChunks = ${JSON.stringify(allChunkUrls.concat(allI18nAssets))};`);
92
+
79
93
  if (!_fs.default.existsSync(this.writePath)) {
80
94
  _fs.default.mkdirSync(this.writePath, {
81
95
  recursive: true
82
96
  });
83
97
  }
98
+
84
99
  _fs.default.writeFileSync(_path.default.join(this.writePath, this.fileName), mod);
85
100
  }
86
101
  });
87
102
  });
88
103
  }
104
+
89
105
  }
106
+
90
107
  exports.default = ServiceWorkerPlugin;