@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,27 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.markdownParser = markdownParser;
7
- const markdownIt = require('markdown-it');
8
- // const md = new markdownIt({ linkify: true,breaks:true });
7
+
8
+ const markdownIt = require('markdown-it'); // const md = new markdownIt({ linkify: true,breaks:true });
9
+
10
+
9
11
  const md = new markdownIt({
10
12
  html: false,
11
13
  linkify: true,
12
14
  typographer: true,
13
15
  breaks: true,
14
16
  xhtmlOut: true
15
- });
16
- //const md = new markdownIt();
17
+ }); //const md = new markdownIt();
18
+
17
19
  function markdownParser(source) {
18
20
  if (!source) {
19
21
  return '';
20
22
  }
23
+
21
24
  const startTag = '/* MD:START';
22
- const endTag = 'MD:END */';
25
+ const endTag = 'MD:END */'; // Iterate through all occurrences of the tags
23
26
 
24
- // Iterate through all occurrences of the tags
25
27
  let startIndex = source.indexOf(startTag);
28
+
26
29
  while (startIndex !== -1) {
27
30
  const endIndex = source.indexOf(endTag, startIndex);
31
+
28
32
  if (endIndex !== -1) {
29
33
  const extractedMarkdown = source.slice(startIndex + startTag.length, endIndex);
30
34
  let lines = extractedMarkdown.split('\n');
@@ -32,8 +36,8 @@ function markdownParser(source) {
32
36
  const firstLineIndentMatch = lines[0].match(/^\s+/);
33
37
  const firstLineIndent = firstLineIndentMatch ? firstLineIndentMatch[0] : '';
34
38
  const modifiedStr = lines.map(line => line.replace(new RegExp(`^${firstLineIndent}`), '')).join('\n').replace(/(:--)|(--:)/g, '---');
35
- let html = md.render(modifiedStr);
36
- //html = html.replace(/"|<hr>|<img src=(".*?")>|<br>|:--|--:|{|}|\$/g, match => {
39
+ let html = md.render(modifiedStr); //html = html.replace(/"|<hr>|<img src=(".*?")>|<br>|:--|--:|{|}|\$/g, match => {
40
+
37
41
  html = html.replace(/"|{|}|\$/g, match => {
38
42
  // if (match === '<hr>') {
39
43
  // return '<hr/>';
@@ -47,20 +51,21 @@ function markdownParser(source) {
47
51
  return '&#123;';
48
52
  } else if (match === '}') {
49
53
  return '&#125;';
50
- }
51
- // else if (match === ':--' || match === '--:' ) {
54
+ } // else if (match === ':--' || match === '--:' ) {
52
55
  // return '---';
53
56
  // }
54
57
  else if (match === '}') {
55
58
  return '&#125;';
56
59
  }
60
+
57
61
  return match;
58
- });
59
- // console.log(html,"html");
62
+ }); // console.log(html,"html");
63
+
60
64
  source = source.replace(source.slice(startIndex, endIndex + endTag.length), '<><div class="markDown">' + html + '</div></>');
61
65
  }
62
- startIndex = source.indexOf(startTag, startIndex + 1);
63
- // console.log(source)
66
+
67
+ startIndex = source.indexOf(startTag, startIndex + 1); // console.log(source)
64
68
  }
69
+
65
70
  return source;
66
71
  }
@@ -4,18 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.reactLiveConvertor = reactLiveConvertor;
7
+
7
8
  const parser = require('@babel/parser');
9
+
8
10
  const traverse = require('@babel/traverse').default;
11
+
9
12
  const path = require('path');
13
+
10
14
  function getFilename(originalFilePath) {
11
15
  const [fileName] = path.basename(originalFilePath).split('.');
12
16
  return fileName;
13
17
  }
18
+
14
19
  function reactLiveConvertor(source, originalFilePath) {
15
20
  const fileName = getFilename(originalFilePath);
21
+
16
22
  if (!source) {
17
23
  return '';
18
24
  }
25
+
19
26
  let importBlock = '';
20
27
  let docCode = '';
21
28
  const packages = new Set();
@@ -23,9 +30,8 @@ function reactLiveConvertor(source, originalFilePath) {
23
30
  const ast = parser.parse(fileContent, {
24
31
  sourceType: 'module',
25
32
  plugins: ['jsx', 'classProperties']
26
- });
33
+ }); // Traverse the AST and find the import and export blocks
27
34
 
28
- // Traverse the AST and find the import and export blocks
29
35
  let remainingCode = ast.program.body.filter(node => node.type !== 'ImportDeclaration').map(node => fileContent.substring(node.start, node.end)).join('').replace(/export default/, '').replace(/export /, '').trim();
30
36
  traverse(ast, {
31
37
  ImportDeclaration(path) {
@@ -34,31 +40,35 @@ function reactLiveConvertor(source, originalFilePath) {
34
40
  if (specifier.type === 'ImportSpecifier') {
35
41
  packages.add(specifier.imported.name);
36
42
  }
43
+
37
44
  if (specifier.local.type === 'Identifier') {
38
45
  packages.add(specifier.local.name);
39
46
  }
40
47
  });
41
48
  },
49
+
42
50
  ExpressionStatement(path) {
43
51
  const expression = path.get('expression');
44
52
  const expressionLeft = expression.get('left');
53
+
45
54
  if (path.isExpressionStatement() && expression.isAssignmentExpression() && expressionLeft.isMemberExpression()) {
46
55
  const docCheck = expressionLeft.toString();
56
+
47
57
  if (docCheck === `${fileName}.docs`) {
48
58
  docCode = expression.toString();
49
59
  }
50
60
  }
51
- }
52
- // IfStatement(path){
61
+ } // IfStatement(path){
53
62
  // if(path.node.type == 'IfStatement'){
54
63
  // if(path.node.test.name == '__DOCS__'){
55
64
  // let final = fileContent.slice(path.node.start,path.node.end)
56
65
  // fileContent = fileContent.replace(final,'')
57
66
  // console.log(fileContent);
58
-
59
67
  // }
60
68
  // }
61
69
  // }
70
+
71
+
62
72
  });
63
73
  remainingCode = remainingCode.replace(/__DOCS__/, true);
64
74
  remainingCode = remainingCode.replace(/`/g, '\\`').replace(/\$\{/g, '$\\{');
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var esprima = _interopRequireWildcard(require("esprima"));
4
+
4
5
  var _escodegen = _interopRequireDefault(require("escodegen"));
5
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
6
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
7
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
6
+
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+
9
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+
11
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+
8
13
  let start = {
9
14
  type: 'ExpressionStatement',
10
15
  expression: {
@@ -48,21 +53,26 @@ let start = {
48
53
  }]
49
54
  }
50
55
  };
56
+
51
57
  let scriptInstrumentLoader = function (source) {
52
58
  let parsed = esprima.parseModule(source, {
53
59
  jsx: true
54
60
  });
61
+
55
62
  for (let i in parsed.body) {
56
63
  if (parsed.body[i].type === 'FunctionDeclaration' || parsed.body[i].type === 'ExportDefaultDeclaration' || parsed.body[i].type === 'ExportNamedDeclaration') {
57
64
  let ParsedTemp;
65
+
58
66
  if (parsed.body[i].type === 'FunctionDeclaration') {
59
67
  ParsedTemp = parsed.body[i];
60
68
  } else {
61
69
  ParsedTemp = parsed.body[i].declaration;
62
70
  }
71
+
63
72
  if (ParsedTemp) {
64
73
  if (ParsedTemp.id) {
65
74
  let funcname = ParsedTemp.id.name;
75
+
66
76
  if (funcname !== 'mapStateToProps') {
67
77
  if (!funcname.includes('_')) {
68
78
  let startFunc = JSON.parse(JSON.stringify(start));
@@ -77,8 +87,8 @@ let scriptInstrumentLoader = function (source) {
77
87
  }
78
88
  }
79
89
  }
80
- return _escodegen.default.generate(parsed);
81
- // function removeDuplicates(arr) {
90
+
91
+ return _escodegen.default.generate(parsed); // function removeDuplicates(arr) {
82
92
  // let uniqueArray = [];
83
93
  // for (let i = 0; i < arr.length; i++) {
84
94
  // if (uniqueArray.indexOf(arr[i]) == -1) {
@@ -89,9 +99,8 @@ let scriptInstrumentLoader = function (source) {
89
99
  // }
90
100
  // funcArray = removeDuplicates(funcArray);
91
101
  };
92
- module.exports = scriptInstrumentLoader;
93
102
 
94
- // let start = {
103
+ module.exports = scriptInstrumentLoader; // let start = {
95
104
  // type: 'ExpressionStatement',
96
105
  // expression: {
97
106
  // type: 'CallExpression',
@@ -1,56 +1,75 @@
1
1
  "use strict";
2
2
 
3
3
  var _path = _interopRequireDefault(require("path"));
4
+
4
5
  var _fs = _interopRequireDefault(require("fs"));
6
+
5
7
  var _utils = require("../utils");
8
+
6
9
  var _logger = require("../logger");
7
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
8
13
  const options = (0, _utils.getOptions)();
9
14
  const {
10
15
  cssSelectorZipPath
11
16
  } = options.impactService;
12
- const zipname = _path.default.parse(cssSelectorZipPath).name;
13
17
 
14
- // TODO:NOTE: need to check about .. path related files creation
18
+ const zipname = _path.default.parse(cssSelectorZipPath).name; // TODO:NOTE: need to check about .. path related files creation
15
19
  // for now no css files have given form react-cli need to make sure about it.
16
20
 
21
+
17
22
  const zippath = _path.default.join(process.cwd(), cssSelectorZipPath);
23
+
18
24
  if (_fs.default.existsSync(_path.default.join(process.cwd(), cssSelectorZipPath))) {
19
25
  _fs.default.rmSync(zippath);
20
- (0, _logger.messageLogger)('zip file deleted', zippath);
21
- // fs.rmSync(zippath, {force:true})
22
- }
23
26
 
24
- // const minicssComment =
27
+ (0, _logger.messageLogger)('zip file deleted', zippath); // fs.rmSync(zippath, {force:true})
28
+ } // const minicssComment =
25
29
  // '// extracted by mini-css-extract-plugin\n';
30
+
31
+
26
32
  const startStr = '// extracted by mini-css-extract-plugin\n' + 'module.exports = ';
33
+
27
34
  module.exports = function (source) {
28
35
  const {
29
36
  rootContext,
30
37
  resourcePath
31
38
  } = this;
39
+
32
40
  const relativePath = _path.default.relative(rootContext, resourcePath);
41
+
33
42
  const fpath = _path.default.join(rootContext, zipname, relativePath);
43
+
34
44
  const originalpath = _path.default.join(rootContext, relativePath);
45
+
35
46
  if (relativePath.startsWith('..')) {
36
47
  throw `unexpected path ${relativePath}`;
37
48
  }
49
+
38
50
  const dpath = fpath.slice(0, fpath.lastIndexOf(_path.default.sep));
51
+
39
52
  if (!_fs.default.existsSync(originalpath)) {
40
53
  throw `originalpath not exixt ${originalpath}`;
41
54
  }
55
+
42
56
  if (!_fs.default.existsSync(dpath)) {
43
57
  _fs.default.mkdirSync(dpath, {
44
58
  recursive: true
45
59
  });
46
60
  }
61
+
47
62
  let jsonStr = '{}';
63
+
48
64
  if (source.startsWith(startStr)) {
49
65
  // source will be like
50
66
  // `// extracted by mini-css-extract-plugin\nmodule.exports = {"app":"zd-app"};`
51
67
  jsonStr = source.slice(startStr.length, -1);
52
68
  }
69
+
53
70
  _fs.default.writeFileSync(`${fpath}_map`, jsonStr);
71
+
54
72
  _fs.default.writeFileSync(fpath, _fs.default.readFileSync(originalpath));
73
+
55
74
  return source;
56
75
  };
@@ -5,14 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = loader;
7
7
  exports.pitch = pitch;
8
+
8
9
  var _path = _interopRequireDefault(require("path"));
10
+
9
11
  var _loaderUtils = require("loader-utils");
12
+
10
13
  var _schemaUtils = _interopRequireDefault(require("schema-utils"));
14
+
11
15
  var _SingleEntryPlugin = _interopRequireDefault(require("webpack/lib/SingleEntryPlugin"));
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+
13
19
  /* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
14
20
  import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
15
-
16
21
  const schema = {
17
22
  type: 'object',
18
23
  properties: {
@@ -40,18 +45,22 @@ const schema = {
40
45
  }
41
46
  },
42
47
  additionalProperties: false
43
- };
44
- // eslint-disable-next-line
48
+ }; // eslint-disable-next-line
49
+
45
50
  function loader() {}
51
+
46
52
  function getDefaultFilename(filename) {
47
53
  if (typeof filename === 'function') {
48
54
  return filename;
49
55
  }
56
+
50
57
  return filename.replace(/\.([a-z]+)(\?.+)?$/i, '.worker.$1$2');
51
58
  }
59
+
52
60
  function getDefaultChunkFilename(chunkFilename) {
53
61
  return chunkFilename.replace(/\.([a-z]+)(\?.+)?$/i, '.worker.$1$2');
54
62
  }
63
+
55
64
  function pitch(request) {
56
65
  this.cacheable(false);
57
66
  const options = (0, _loaderUtils.getOptions)(this);
@@ -71,7 +80,6 @@ function pitch(request) {
71
80
  globalObject: 'self'
72
81
  };
73
82
  workerContext.compiler = this._compilation.createChildCompiler(`worker-loader ${request}`, workerContext.options);
74
-
75
83
  /*
76
84
  new WebWorkerTemplatePlugin().apply(workerContext.compiler);
77
85
 
@@ -87,22 +95,28 @@ function pitch(request) {
87
95
  const cb = this.async();
88
96
  workerContext.compiler.runAsChild((errorArg, entries, compilation) => {
89
97
  let error = errorArg;
98
+
90
99
  if (!error && compilation.errors && compilation.errors.length) {
91
100
  // eslint-disable-next-line
92
101
  error = compilation.errors[0];
93
102
  }
103
+
94
104
  const entry = entries && entries[0] && entries[0].files.values().next().value;
105
+
95
106
  if (!error && !entry) {
96
107
  error = Error(`WorkerPlugin: no entry for ${request}`);
97
108
  }
109
+
98
110
  if (error) {
99
111
  return cb(error);
100
112
  }
113
+
101
114
  function workerCode() {
102
115
  // if (this.workerInstance) {
103
116
  // return this.workerInstance;
104
117
  // }
105
118
  let blob;
119
+
106
120
  try {
107
121
  blob = new Blob([`importScripts('${this.workerUrl}');`], {
108
122
  type: 'application/javascript'
@@ -110,21 +124,22 @@ function pitch(request) {
110
124
  } catch (e1) {
111
125
  throw new Error(e1);
112
126
  }
127
+
113
128
  const url = window.URL || window.webkitURL;
114
- const blobUrl = url.createObjectURL(blob);
115
- // this.workerInstance = new Worker(blobUrl);
129
+ const blobUrl = url.createObjectURL(blob); // this.workerInstance = new Worker(blobUrl);
116
130
  // return this.workerInstance;
131
+
117
132
  let worker = new Worker(blobUrl);
118
133
  return worker;
119
134
  }
135
+
120
136
  return cb(null, `const workerObj ={\n
121
137
  workerInstance: null, \n
122
138
  workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
123
139
  getInstance: ${workerCode} \n
124
140
  };\n
125
141
  ${options.esModule ? 'export default' : 'module.exports ='} workerObj;
126
- `);
127
- // return cb(
142
+ `); // return cb(
128
143
  // null,
129
144
  // `${options.esModule ? 'export default' : 'module.exports ='} {\n
130
145
  // workerInstance: null, \n
package/lib/logger.js CHANGED
@@ -7,16 +7,20 @@ exports.errorLogger = errorLogger;
7
7
  exports.messageLogger = messageLogger;
8
8
  exports.verboseLogger = verboseLogger;
9
9
  exports.warnLogger = warnLogger;
10
+
10
11
  /* eslint-disable no-console */
11
12
  function messageLogger(...args) {
12
13
  console.log(...args);
13
14
  }
15
+
14
16
  function errorLogger(...args) {
15
17
  console.error(...args);
16
18
  }
19
+
17
20
  function warnLogger(...args) {
18
21
  console.warn(...args);
19
22
  }
23
+
20
24
  function verboseLogger(...args) {
21
25
  // TODO: need to be remove when publish happens
22
26
  process.env.VERBOSE === 'true' && console.log('\x1b[33m [verbose] \x1b[0m', ...args);
@@ -4,24 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = HMRMiddleware;
7
+
7
8
  function pathMatch(url, path) {
8
9
  if (url === path) {
9
10
  return true;
10
11
  }
12
+
11
13
  let q = url.indexOf('?');
14
+
12
15
  if (q === -1) {
13
16
  return false;
14
17
  }
18
+
15
19
  return url.substring(0, q) === path;
16
20
  }
21
+
17
22
  function createEventStream(heartbeat) {
18
23
  let clientId = 0;
19
24
  let clients = {};
25
+
20
26
  function everyClient(fn) {
21
27
  Object.keys(clients).forEach(id => {
22
28
  fn(clients[id]);
23
29
  });
24
30
  }
31
+
25
32
  setInterval(() => {
26
33
  everyClient(client => {
27
34
  client.write(`data: ${JSON.stringify({
@@ -52,20 +59,22 @@ function createEventStream(heartbeat) {
52
59
  }
53
60
  };
54
61
  }
62
+
55
63
  function extractBundles(stats) {
56
64
  // Stats has modules, single bundle
57
65
  if (stats.modules) {
58
66
  return [stats];
59
- }
67
+ } // Stats has children, multiple bundles
68
+
60
69
 
61
- // Stats has children, multiple bundles
62
70
  if (stats.children && stats.children.length) {
63
71
  return stats.children;
64
- }
72
+ } // Not sure, assume single
73
+
65
74
 
66
- // Not sure, assume single
67
75
  return [stats];
68
76
  }
77
+
69
78
  function publishStats(action, statsResult, eventStream, log) {
70
79
  // For multi-compiler, stats will be an object with a 'children' array of stats
71
80
  let bundles = extractBundles(statsResult.toJson({
@@ -74,8 +83,7 @@ function publishStats(action, statsResult, eventStream, log) {
74
83
  bundles.forEach(stats => {
75
84
  if (log) {
76
85
  log(`webpack built ${stats.name ? `${stats.name} ` : ''}${stats.hash} in ${stats.time}ms`);
77
- }
78
- // if (
86
+ } // if (
79
87
  // // !force &&
80
88
  // action !== 'sync' &&
81
89
  // stats &&
@@ -87,10 +95,13 @@ function publishStats(action, statsResult, eventStream, log) {
87
95
  // type: 'still-ok'
88
96
  // });
89
97
  // }
98
+
99
+
90
100
  eventStream.publish({
91
101
  type: 'hash',
92
102
  data: stats.hash
93
103
  });
104
+
94
105
  if (stats.errors.length > 0) {
95
106
  eventStream.publish({
96
107
  type: 'errors',
@@ -108,9 +119,9 @@ function publishStats(action, statsResult, eventStream, log) {
108
119
  }
109
120
  });
110
121
  }
122
+
111
123
  function HMRMiddleware(compiler, opts = {}) {
112
- opts.log =
113
- // eslint-disable-next-line no-console
124
+ opts.log = // eslint-disable-next-line no-console
114
125
  typeof opts.log === 'undefined' ? console.log.bind(console) : opts.log;
115
126
  opts.path = opts.path || '/__webpack_hmr';
116
127
  opts.heartbeat = opts.heartbeat || 10 * 1000;
@@ -122,13 +133,16 @@ function HMRMiddleware(compiler, opts = {}) {
122
133
  opts.log('webpack compilation starts...');
123
134
  loggedInfo = true;
124
135
  }
136
+
125
137
  callback && callback();
126
138
  });
127
139
  compiler.hooks.compile.tap('HMRMiddleware', () => {
128
140
  latestStats = null;
141
+
129
142
  if (opts.log) {
130
143
  opts.log('webpack building...');
131
144
  }
145
+
132
146
  eventStream.publish({
133
147
  type: 'building'
134
148
  });
@@ -138,22 +152,22 @@ function HMRMiddleware(compiler, opts = {}) {
138
152
  latestStats = statsResult;
139
153
  publishStats('built', latestStats, eventStream, opts.log);
140
154
  });
155
+
141
156
  let middleware = function (req, res, next) {
142
157
  if (!pathMatch(req.url, opts.path)) {
143
158
  return next();
144
159
  }
145
- eventStream.handler(req, res);
146
- // if (latestStats) {
160
+
161
+ eventStream.handler(req, res); // if (latestStats) {
147
162
  // // Explicitly not passing in `log` fn as we don't want to log again on
148
163
  // // the server
149
164
  // // publishStats('sync', latestStats, eventStream);
150
165
  // }
151
166
  };
167
+
152
168
  middleware.publish = eventStream.publish;
153
169
  return middleware;
154
- }
155
-
156
- // function buildModuleMap(modules) {
170
+ } // function buildModuleMap(modules) {
157
171
  // let map = {};
158
172
  // modules.forEach(function(module) {
159
173
  // map[module.id] = module.name;
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _utils = require("../utils");
9
+
8
10
  function SSTMiddleware(compiler, callback) {
9
11
  compiler.hooks.done.tap('SSTMiddleware', stats => {
10
12
  (0, _utils.log)('Compilation finished!');
@@ -14,4 +16,6 @@ function SSTMiddleware(compiler, callback) {
14
16
  next();
15
17
  };
16
18
  }
17
- var _default = exports.default = SSTMiddleware;
19
+
20
+ var _default = SSTMiddleware;
21
+ exports.default = _default;
@@ -4,13 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.configHtmlWebpackPlugins = configHtmlWebpackPlugins;
7
+
7
8
  var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
11
+
9
12
  var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
13
+
10
14
  var _common = require("../common");
15
+
11
16
  var _utils = require("../utils");
17
+
12
18
  var _CustomScriptLoadingStrategyPlugin = _interopRequireDefault(require("../plugins/CustomScriptLoadingStrategyPlugin"));
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 defaultHTMLMiniFyOption = {
15
23
  collapseWhitespace: true,
16
24
  minifyCSS: true,
@@ -24,39 +32,50 @@ const defaultHTMLMiniFyOption = {
24
32
  };
25
33
  const defaultScriptLoadingStrategy = 'defer';
26
34
  const allowedScriptLoadingStrategies = ['blocking', 'defer', 'async', 'module'];
35
+
27
36
  function isAllowedScriptLoadingStrategyUsed(scriptLoadingStategey) {
28
37
  return allowedScriptLoadingStrategies.includes(scriptLoadingStategey);
29
38
  }
39
+
30
40
  function getScriptLoadingStrategyForStringType(scriptLoadingStategey) {
31
41
  if (isAllowedScriptLoadingStrategyUsed(scriptLoadingStategey)) {
32
42
  return scriptLoadingStategey;
33
43
  }
44
+
34
45
  return defaultScriptLoadingStrategy;
35
46
  }
47
+
36
48
  function getScriptLoadingStrategyForObject(scriptLoadingStategey) {
37
49
  if (Object.keys(scriptLoadingStategey).length === 0) {
38
50
  return defaultScriptLoadingStrategy;
39
51
  }
52
+
40
53
  const isAllowedScriptLoadingStrategy = Object.keys(scriptLoadingStategey).every(key => isAllowedScriptLoadingStrategyUsed(key));
54
+
41
55
  if (isAllowedScriptLoadingStrategy) {
42
56
  return Object.assign({}, scriptLoadingStategey);
43
57
  }
58
+
44
59
  console.warn('un supported script loading strategy used', scriptLoadingStategey);
45
60
  return defaultScriptLoadingStrategy;
46
61
  }
62
+
47
63
  function getScriptLoadingStrategy(scriptLoadingStategey) {
48
64
  if ((0, _utils.getTypeOf)(scriptLoadingStategey) === 'string') {
49
65
  return {
50
66
  [getScriptLoadingStrategyForStringType(scriptLoadingStategey)]: [/.*/]
51
67
  };
52
68
  }
69
+
53
70
  if ((0, _utils.getTypeOf)(scriptLoadingStategey) === 'object') {
54
71
  return getScriptLoadingStrategyForObject(scriptLoadingStategey);
55
72
  }
73
+
56
74
  return {
57
75
  [defaultScriptLoadingStrategy]: [/.*/]
58
76
  };
59
77
  }
78
+
60
79
  function configHtmlWebpackPlugins(plugins, {
61
80
  enableChunkHash = false,
62
81
  folder,
@@ -78,15 +97,19 @@ function configHtmlWebpackPlugins(plugins, {
78
97
  scriptLoading: defaultScriptLoadingStrategy,
79
98
  inject: inject
80
99
  };
100
+
81
101
  if (hasEFC) {
82
102
  optionsHtmlWebpack.excludeChunks = ['efc', 'widget'];
83
103
  }
104
+
84
105
  plugins.push(new _htmlWebpackPlugin.default(optionsHtmlWebpack));
85
106
  crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
86
107
  crossorigin: 'anonymous'
87
108
  }));
109
+
88
110
  if (customScriptLoadingStrategey.enable) {
89
111
  const currentScriptLoadingStrategy = getScriptLoadingStrategy(customScriptLoadingStrategey.options);
112
+
90
113
  if ((0, _utils.getTypeOf)(currentScriptLoadingStrategy) === 'object') {
91
114
  plugins.push(new _CustomScriptLoadingStrategyPlugin.default({
92
115
  scriptLoadingStategey: currentScriptLoadingStrategy