@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.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 (250) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/README.md +1025 -1028
  5. package/bin/cli.js +482 -482
  6. package/cert/Tsicsezwild-22-23.crt +37 -37
  7. package/cert/Tsicsezwild-22-23.key +27 -27
  8. package/docs/CustomChunks.md +26 -26
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/SelectorWeight.md +6 -0
  13. package/docs/TODOS.md +10 -10
  14. package/docs/ValueReplacer.md +60 -60
  15. package/docs/VariableConversion.md +719 -678
  16. package/docs/warnings_while_install.txt +35 -35
  17. package/files/eslintrc.js +62 -62
  18. package/files/prettierrc.js +3 -3
  19. package/lib/babel/cmjs-plugins-presets.js +4 -0
  20. package/lib/babel/es-plugins-presets.js +4 -0
  21. package/lib/common/getEntries.js +10 -0
  22. package/lib/common/getPublicPathConfig.js +6 -0
  23. package/lib/common/index.js +5 -0
  24. package/lib/common/splitChunks.js +13 -2
  25. package/lib/common/sslcertUpdater.js +17 -6
  26. package/lib/common/templateParameters.js +2 -0
  27. package/lib/common/testPattern.js +21 -10
  28. package/lib/common/valueReplacer.js +15 -0
  29. package/lib/configs/jest.config.js +9 -0
  30. package/lib/configs/libAlias.js +2 -4
  31. package/lib/configs/webpack.component.umd.config.js +5 -0
  32. package/lib/configs/webpack.css.umd.config.js +13 -5
  33. package/lib/configs/webpack.dev.config.js +36 -2
  34. package/lib/configs/webpack.docs.config.js +21 -1
  35. package/lib/configs/webpack.impact.config.js +19 -1
  36. package/lib/configs/webpack.prod.config.js +37 -3
  37. package/lib/hooks/docsProptypeHook.js +7 -3
  38. package/lib/jest/commitedFilesResult.js +45 -3
  39. package/lib/jest/coverageCollector.js +11 -0
  40. package/lib/jest/jsonMaker.js +6 -0
  41. package/lib/jest/preProcessors/cssPreprocessor.js +8 -0
  42. package/lib/jest/preProcessors/jsPreprocessor.js +2 -0
  43. package/lib/jest/preProcessors/otherFilesPreprocessor.js +3 -0
  44. package/lib/jest/result.js +22 -0
  45. package/lib/jest/run.js +17 -6
  46. package/lib/jest/setup.js +57 -5
  47. package/lib/loaderUtils/configsAssetsLoaders.js +44 -34
  48. package/lib/loaderUtils/getCSSLoaders.js +35 -20
  49. package/lib/loaderUtils/getDevJsLoaders.js +8 -0
  50. package/lib/loaderUtils/index.js +3 -0
  51. package/lib/loaderUtils/windowsModification.js +11 -0
  52. package/lib/loaders/docsLoader.js +7 -0
  53. package/lib/loaders/docsPropsLoader.js +7 -3
  54. package/lib/loaders/fileBountryLoader.js +2 -0
  55. package/lib/loaders/fileLoader.js +22 -11
  56. package/lib/loaders/scriptInstrumentLoader.js +13 -5
  57. package/lib/loaders/selectorMappingLoader.js +25 -7
  58. package/lib/loaders/workerLoader.js +29 -13
  59. package/lib/middlewares/HMRMiddleware.js +26 -13
  60. package/lib/middlewares/SSTMiddleware.js +3 -0
  61. package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -3
  62. package/lib/pluginUtils/getDevPlugins.js +68 -22
  63. package/lib/pluginUtils/getDocsPlugins.js +10 -1
  64. package/lib/pluginUtils/getLibraryImactPlugins.js +5 -4
  65. package/lib/pluginUtils/getLibraryPlugins.js +5 -0
  66. package/lib/pluginUtils/getProdPlugins.js +77 -28
  67. package/lib/pluginUtils/getServerPlugins.js +5 -0
  68. package/lib/pluginUtils/getUMDCSSPlugins.js +7 -0
  69. package/lib/pluginUtils/getUMDComponentPlugins.js +7 -0
  70. package/lib/pluginUtils/index.js +8 -0
  71. package/lib/plugins/CdnChangePlugin.js +14 -0
  72. package/lib/plugins/CleanupStatsPlugin.js +5 -0
  73. package/lib/plugins/EFCPlugin.js +34 -23
  74. package/lib/plugins/EFCPlugin.md +6 -6
  75. package/lib/plugins/EFCTemplatePlugin.js +32 -23
  76. package/lib/plugins/I18NInjectIntoIndexPlugin.js +38 -12
  77. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
  78. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
  79. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +77 -46
  80. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +59 -44
  81. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +30 -21
  82. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  83. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  84. package/lib/plugins/I18nSplitPlugin/index.js +80 -70
  85. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
  86. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
  87. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
  88. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +6 -0
  89. package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
  90. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -2
  91. package/lib/plugins/ManifestPlugin.js +17 -0
  92. package/lib/plugins/ModuleStatsPlugin.js +23 -0
  93. package/lib/plugins/OptimizeJSPlugin.js +7 -0
  94. package/lib/plugins/PublicPathCallbackPlugin.js +10 -0
  95. package/lib/plugins/PublicPathChangePlugin.js +36 -4
  96. package/lib/plugins/ReportGeneratePlugin.js +30 -4
  97. package/lib/plugins/RequireVariablePublicPlugin.js +6 -0
  98. package/lib/plugins/ResourceHintsPlugin.js +27 -20
  99. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
  100. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +22 -15
  101. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  102. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
  103. package/lib/plugins/ScriptInstrumentPlugin.js +7 -0
  104. package/lib/plugins/SelectorPlugin.js +97 -0
  105. package/lib/plugins/ServiceWorkerPlugin.js +29 -13
  106. package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
  107. package/lib/plugins/SourceMapHookPlugin.js +9 -0
  108. package/lib/plugins/TPHashMappingPlugin.js +19 -5
  109. package/lib/plugins/UglifyCSSPlugin.js +9 -0
  110. package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
  111. package/lib/plugins/VariableConversionCollector.js +322 -0
  112. package/lib/plugins/composeCommonPlugin.js +30 -0
  113. package/lib/plugins/index.js +19 -0
  114. package/lib/plugins/libraryImpactPlugin.js +32 -0
  115. package/lib/plugins/webpackwatchrunplugin.js +5 -0
  116. package/lib/postcss-plugins/ExcludePlugin.js +4 -0
  117. package/lib/postcss-plugins/RTLSplitPlugin.js +37 -24
  118. package/lib/postcss-plugins/ValueReplacer.js +6 -9
  119. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
  120. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  121. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  122. package/lib/postcss-plugins/hoverActivePlugin.js +69 -33
  123. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +42 -13
  124. package/lib/postcss-plugins/variableModificationPlugin/index.js +216 -141
  125. package/lib/postcss-plugins/variableModifier.js +20 -13
  126. package/lib/schemas/index.js +23 -4
  127. package/lib/servers/clusterHubServer.js +10 -0
  128. package/lib/servers/devBuild.js +24 -13
  129. package/lib/servers/docsServer.js +2 -0
  130. package/lib/servers/docsServerCore.js +21 -0
  131. package/lib/servers/getCliPath.js +9 -0
  132. package/lib/servers/helpServer.js +5 -0
  133. package/lib/servers/httpsOptions.js +4 -0
  134. package/lib/servers/impactServer.js +34 -2
  135. package/lib/servers/mockserver.js +9 -0
  136. package/lib/servers/nowatchserver.js +34 -12
  137. package/lib/servers/scrServer.js +20 -13
  138. package/lib/servers/server.js +35 -7
  139. package/lib/servers/ssServer.js +16 -0
  140. package/lib/sh/pre-commit.sh +34 -34
  141. package/lib/sh/reportPublish.sh +45 -45
  142. package/lib/templates/CoverageScriptTemplate.js +14 -0
  143. package/lib/templates/WMSTemplate.js +12 -6
  144. package/lib/utils/babelPresets.js +2 -0
  145. package/lib/utils/buildstats.html +148 -148
  146. package/lib/utils/clean.js +8 -2
  147. package/lib/utils/copy.js +6 -0
  148. package/lib/utils/copyTimezones.js +8 -0
  149. package/lib/utils/createEventStream.js +4 -0
  150. package/lib/utils/cssClassNameGenerate.js +19 -3
  151. package/lib/utils/cssURLReplacer.js +25 -0
  152. package/lib/utils/dependencyPostPublish.js +9 -0
  153. package/lib/utils/fileUtils.js +26 -0
  154. package/lib/utils/folderIterator.js +10 -0
  155. package/lib/utils/getComponents.js +21 -0
  156. package/lib/utils/getCurrentBranch.js +5 -0
  157. package/lib/utils/getDependenciesImpactList.js +21 -0
  158. package/lib/utils/getHash.js +7 -0
  159. package/lib/utils/getIp.js +2 -0
  160. package/lib/utils/getOptions.js +39 -14
  161. package/lib/utils/getServerURL.js +7 -0
  162. package/lib/utils/index.js +47 -2
  163. package/lib/utils/init.js +1 -0
  164. package/lib/utils/initPreCommitHook.js +29 -6
  165. package/lib/utils/jsonHelper.js +19 -2
  166. package/lib/utils/libraryImpactConfig.js +2 -0
  167. package/lib/utils/lint/addScripts.js +5 -2
  168. package/lib/utils/lint/checkExistingConfig.js +12 -3
  169. package/lib/utils/lint/copyConfigs.js +3 -0
  170. package/lib/utils/lint/index.js +9 -0
  171. package/lib/utils/lint/lintScripts.js +1 -0
  172. package/lib/utils/lint/lintSetup.js +4 -3
  173. package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
  174. package/lib/utils/lint/question.js +7 -0
  175. package/lib/utils/lintReporter.js +20 -0
  176. package/lib/utils/mailSender.js +7 -0
  177. package/lib/utils/pullOrigin.js +4 -0
  178. package/lib/utils/reinstallDependencies.js +28 -0
  179. package/lib/utils/removeAttributes.js +7 -0
  180. package/lib/utils/repoClone.js +27 -2
  181. package/lib/utils/request.js +12 -0
  182. package/lib/utils/resultSchema.json +73 -73
  183. package/lib/utils/rtl.js +16 -4
  184. package/lib/utils/setEnvVariables.js +2 -0
  185. package/lib/utils/ssTestHack.js +10 -0
  186. package/lib/utils/switchBranch.js +4 -0
  187. package/lib/utils/urlConcat.js +4 -0
  188. package/lib/utils/useExitCleanup.js +10 -9
  189. package/npm8.md +9 -9
  190. package/package.json +146 -146
  191. package/postpublish.js +6 -6
  192. package/templates/app/.eslintrc.js +140 -140
  193. package/templates/app/README.md +12 -12
  194. package/templates/app/app/index.html +24 -24
  195. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  196. package/templates/app/app/properties/i18nkeys.json +3 -3
  197. package/templates/app/docs/all.html +69 -69
  198. package/templates/app/mockapi/index.js +18 -18
  199. package/templates/app/package.json +37 -37
  200. package/templates/app/src/actions/SampleActions/index.js +37 -37
  201. package/templates/app/src/actions/index.js +65 -65
  202. package/templates/app/src/appUrls.js +19 -19
  203. package/templates/app/src/components/Alert/Alert.js +134 -134
  204. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  205. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  206. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  207. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  208. package/templates/app/src/components/Sample/SampleList.js +61 -61
  209. package/templates/app/src/components/Slider/Slider.css +41 -41
  210. package/templates/app/src/components/Slider/Slider.js +55 -55
  211. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  212. package/templates/app/src/containers/AppContainer/index.js +96 -96
  213. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  214. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  215. package/templates/app/src/containers/DevTools/index.js +10 -10
  216. package/templates/app/src/containers/Header/index.js +67 -67
  217. package/templates/app/src/containers/Header/index.module.css +43 -43
  218. package/templates/app/src/containers/Redirect/index.js +63 -63
  219. package/templates/app/src/containers/Redirector/index.js +47 -47
  220. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  221. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  222. package/templates/app/src/historyChange.js +5 -5
  223. package/templates/app/src/index.html +10 -10
  224. package/templates/app/src/index.js +24 -24
  225. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  226. package/templates/app/src/reducers/alertData.js +11 -11
  227. package/templates/app/src/reducers/index.js +6 -6
  228. package/templates/app/src/reducers/samples.js +19 -19
  229. package/templates/app/src/store/configureStore.dev.js +51 -51
  230. package/templates/app/src/store/configureStore.js +5 -5
  231. package/templates/app/src/store/configureStore.prod.js +26 -26
  232. package/templates/app/src/util/Common.js +5 -5
  233. package/templates/app/src/util/RequestAPI.js +132 -132
  234. package/templates/docs/all.html +249 -249
  235. package/templates/docs/component.html +178 -178
  236. package/templates/docs/components.html +221 -221
  237. package/templates/docs/css/b.min.css +6 -6
  238. package/templates/docs/css/component.css +42 -42
  239. package/templates/docs/css/componentTest.css +6 -6
  240. package/templates/docs/css/hopscotch.css +585 -585
  241. package/templates/docs/css/style.css +1022 -1022
  242. package/templates/docs/impactReportTemplate.html +154 -154
  243. package/templates/docs/index.html +1501 -1501
  244. package/templates/docs/js/active-line.js +72 -72
  245. package/templates/docs/js/b.min.js +7 -7
  246. package/templates/docs/js/codemirror.js +9680 -9680
  247. package/templates/docs/js/designTokens.js +334 -334
  248. package/templates/docs/js/j.min.js +4 -4
  249. package/templates/docs/js/javascript.js +874 -874
  250. package/templates/docs/js/matchbrackets.js +145 -145
@@ -4,20 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = ShadowDOMSupportPlugin;
7
+
7
8
  var _Template = _interopRequireDefault(require("webpack/lib/Template"));
9
+
8
10
  var _JsonpMainTemplatePlugin = _interopRequireDefault(require("webpack/lib/web/JsonpMainTemplatePlugin"));
11
+
9
12
  var _tapable = require("tapable");
13
+
10
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- /* eslint-disable no-unused-vars */
12
15
 
16
+ /* eslint-disable no-unused-vars */
13
17
  //eslint-disable-next-line
14
18
  function ShadowDOMSupportPlugin() {}
19
+
15
20
  ShadowDOMSupportPlugin.prototype.apply = function () {
16
21
  this.patchJsonpMainTemplatePlugin();
17
22
  };
23
+
18
24
  ShadowDOMSupportPlugin.prototype.patchJsonpMainTemplatePlugin = function () {
19
25
  _JsonpMainTemplatePlugin.default.prototype.apply = this._apply;
20
26
  };
27
+
21
28
  ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
22
29
  const needChunkOnDemandLoadingCode = chunk => {
23
30
  for (const chunkGroup of chunk.groupsIterable) {
@@ -25,38 +32,46 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
25
32
  return true;
26
33
  }
27
34
  }
35
+
28
36
  return false;
29
37
  };
38
+
30
39
  const needChunkLoadingCode = chunk => {
31
40
  for (const chunkGroup of chunk.groupsIterable) {
32
41
  if (chunkGroup.chunks.length > 1) {
33
42
  return true;
34
43
  }
44
+
35
45
  if (chunkGroup.getNumberOfChildren() > 0) {
36
46
  return true;
37
47
  }
38
48
  }
49
+
39
50
  return false;
40
51
  };
52
+
41
53
  const needEntryDeferringCode = chunk => {
42
54
  for (const chunkGroup of chunk.groupsIterable) {
43
55
  if (chunkGroup.chunks.length > 1) {
44
56
  return true;
45
57
  }
46
58
  }
59
+
47
60
  return false;
48
61
  };
62
+
49
63
  const needPrefetchingCode = chunk => {
50
64
  const allPrefetchChunks = chunk.getChildIdsByOrdersMap(true).prefetch;
51
65
  return allPrefetchChunks && Object.keys(allPrefetchChunks).length;
52
- };
66
+ }; // TODO webpack 5, no adding to .hooks, use WeakMap and static methods
67
+
53
68
 
54
- // TODO webpack 5, no adding to .hooks, use WeakMap and static methods
55
69
  ['jsonpScript', 'linkPreload', 'linkPrefetch'].forEach(hook => {
56
70
  if (!mainTemplate.hooks[hook]) {
57
71
  mainTemplate.hooks[hook] = new _tapable.SyncWaterfallHook(['source', 'chunk', 'hash']);
58
72
  }
59
73
  });
74
+
60
75
  const getScriptSrcPath = (hash, chunk, chunkIdExpression) => {
61
76
  const {
62
77
  chunkFilename
@@ -68,15 +83,19 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
68
83
  chunk: {
69
84
  id: `" + ${chunkIdExpression} + "`,
70
85
  hash: `" + ${JSON.stringify(chunkMaps.hash)}[${chunkIdExpression}] + "`,
86
+
71
87
  hashWithLength(length) {
72
88
  const shortChunkHashMap = Object.create(null);
89
+
73
90
  for (const chunkId of Object.keys(chunkMaps.hash)) {
74
91
  if (typeof chunkMaps.hash[chunkId] === 'string') {
75
92
  shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
76
93
  }
77
94
  }
95
+
78
96
  return `" + ${JSON.stringify(shortChunkHashMap)}[${chunkIdExpression}] + "`;
79
97
  },
98
+
80
99
  name: `" + (${JSON.stringify(chunkMaps.name)}[${chunkIdExpression}]||${chunkIdExpression}) + "`,
81
100
  contentHash: {
82
101
  javascript: `" + ${JSON.stringify(chunkMaps.contentHash.javascript)}[${chunkIdExpression}] + "`
@@ -85,11 +104,13 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
85
104
  javascript: length => {
86
105
  const shortContentHashMap = {};
87
106
  const contentHash = chunkMaps.contentHash.javascript;
107
+
88
108
  for (const chunkId of Object.keys(contentHash)) {
89
109
  if (typeof contentHash[chunkId] === 'string') {
90
110
  shortContentHashMap[chunkId] = contentHash[chunkId].substr(0, length);
91
111
  }
92
112
  }
113
+
93
114
  return `" + ${JSON.stringify(shortContentHashMap)}[${chunkIdExpression}] + "`;
94
115
  }
95
116
  }
@@ -97,17 +118,22 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
97
118
  contentHashType: 'javascript'
98
119
  });
99
120
  };
121
+
100
122
  mainTemplate.hooks.localVars.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
101
123
  const extraCode = [];
124
+
102
125
  if (needChunkLoadingCode(chunk)) {
103
126
  extraCode.push('', '// object to store loaded and loading chunks', '// undefined = chunk not loaded, null = chunk preloaded/prefetched', '// Promise = chunk loading, 0 = chunk loaded', 'var installedChunks = {', _Template.default.indent(chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(',\n')), '};', '', needEntryDeferringCode(chunk) ? 'var deferredModules = [];' : '');
104
127
  }
128
+
105
129
  if (needChunkOnDemandLoadingCode(chunk)) {
106
130
  extraCode.push('', '// script path function', 'function jsonpScriptSrc(chunkId) {', _Template.default.indent([`return ${mainTemplate.requireFn}.p + ${getScriptSrcPath(hash, chunk, 'chunkId')}`]), '}');
107
131
  }
132
+
108
133
  if (extraCode.length === 0) {
109
134
  return source;
110
135
  }
136
+
111
137
  return _Template.default.asString([source, ...extraCode]);
112
138
  });
113
139
  mainTemplate.hooks.jsonpScript.tap('JsonpMainTemplatePlugin', (_, chunk, hash) => {
@@ -143,15 +169,18 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
143
169
  stage: 10
144
170
  }, (source, chunk, hash) => {
145
171
  const chunkMap = chunk.getChildIdsByOrdersMap().preload;
172
+
146
173
  if (!chunkMap || Object.keys(chunkMap).length === 0) {
147
174
  return source;
148
175
  }
176
+
149
177
  return _Template.default.asString([source, '', '// chunk preloadng for javascript', '', `var chunkPreloadMap = ${JSON.stringify(chunkMap, null, '\t')};`, '', 'var chunkPreloadData = chunkPreloadMap[chunkId];', 'if(chunkPreloadData) {', _Template.default.indent(['chunkPreloadData.forEach(function(chunkId) {', _Template.default.indent(['if(installedChunks[chunkId] === undefined) {', _Template.default.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(link);']), '}']), '});']), '}']);
150
178
  });
151
179
  mainTemplate.hooks.requireExtensions.tap('JsonpMainTemplatePlugin', (source, chunk) => {
152
180
  if (!needChunkOnDemandLoadingCode(chunk)) {
153
181
  return source;
154
182
  }
183
+
155
184
  return _Template.default.asString([source, '', '// on error function for async loading', `${mainTemplate.requireFn}.oe = function(err) { console.error(err); throw err; };`]);
156
185
  });
157
186
  mainTemplate.hooks.bootstrap.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
@@ -160,6 +189,7 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
160
189
  const withPrefetch = needPrefetchingCode(chunk);
161
190
  return _Template.default.asString([source, '', '// install a JSONP callback for chunk loading', 'function webpackJsonpCallback(data) {', _Template.default.indent(['var chunkIds = data[0];', 'var moreModules = data[1];', withDefer ? 'var executeModules = data[2];' : '', withPrefetch ? 'var prefetchChunks = data[3] || [];' : '', '// add "moreModules" to the modules object,', '// then flag all "chunkIds" as loaded and fire callback', 'var moduleId, chunkId, i = 0, resolves = [];', 'for(;i < chunkIds.length; i++) {', _Template.default.indent(['chunkId = chunkIds[i];', 'if(installedChunks[chunkId]) {', _Template.default.indent('resolves.push(installedChunks[chunkId][0]);'), '}', 'installedChunks[chunkId] = 0;']), '}', 'for(moduleId in moreModules) {', _Template.default.indent(['if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {', _Template.default.indent(mainTemplate.renderAddModule(hash, chunk, 'moduleId', 'moreModules[moduleId]')), '}']), '}', 'if(parentJsonpFunction) parentJsonpFunction(data);', withPrefetch ? _Template.default.asString(['// chunk prefetching for javascript', 'prefetchChunks.forEach(function(chunkId) {', _Template.default.indent(['if(installedChunks[chunkId] === undefined) {', _Template.default.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPrefetch.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(link);']), '}']), '});']) : '', 'while(resolves.length) {', _Template.default.indent('resolves.shift()();'), '}', withDefer ? _Template.default.asString(['', '// add entry modules from loaded chunk to deferred list', 'deferredModules.push.apply(deferredModules, executeModules || []);', '', '// run deferred modules when all chunks ready', 'return checkDeferredModules();']) : '']), '};', withDefer ? _Template.default.asString(['function checkDeferredModules() {', _Template.default.indent(['var result;', 'for(var i = 0; i < deferredModules.length; i++) {', _Template.default.indent(['var deferredModule = deferredModules[i];', 'var fulfilled = true;', 'for(var j = 1; j < deferredModule.length; j++) {', _Template.default.indent(['var depId = deferredModule[j];', 'if(installedChunks[depId] !== 0) fulfilled = false;']), '}', 'if(fulfilled) {', _Template.default.indent(['deferredModules.splice(i--, 1);', `result = ${mainTemplate.requireFn}(${mainTemplate.requireFn}.s = deferredModule[0]);`]), '}']), '}', 'return result;']), '}']) : '']);
162
191
  }
192
+
163
193
  return source;
164
194
  });
165
195
  mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
@@ -172,13 +202,16 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
172
202
  } = mainTemplate.outputOptions;
173
203
  return _Template.default.asString([`var jsonpArray = ${globalObject}[${JSON.stringify(jsonpFunction)}] = ${globalObject}[${JSON.stringify(jsonpFunction)}] || [];`, 'var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);', 'jsonpArray.push = webpackJsonpCallback;', 'jsonpArray = jsonpArray.slice();', 'for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);', 'var parentJsonpFunction = oldJsonpFunction;', '', source]);
174
204
  }
205
+
175
206
  return source;
176
207
  });
177
208
  mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
178
209
  const prefetchChunks = chunk.getChildIdsByOrders().prefetch;
210
+
179
211
  if (needChunkLoadingCode(chunk) && prefetchChunks && prefetchChunks.length) {
180
212
  return _Template.default.asString([source, `webpackJsonpCallback([[], {}, 0, ${JSON.stringify(prefetchChunks)}]);`]);
181
213
  }
214
+
182
215
  return source;
183
216
  });
184
217
  mainTemplate.hooks.startup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
@@ -187,8 +220,10 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
187
220
  const entries = [chunk.entryModule].filter(Boolean).map(m => [m.id].concat(Array.from(chunk.groupsIterable)[0].chunks.filter(c => c !== chunk).map(c => c.id)));
188
221
  return _Template.default.asString(['// add entry module to deferred list', `deferredModules.push(${entries.map(e => JSON.stringify(e)).join(', ')});`, '// run deferred modules when ready', 'return checkDeferredModules();']);
189
222
  }
223
+
190
224
  return _Template.default.asString(['// run deferred modules from other chunks', 'checkDeferredModules();']);
191
225
  }
226
+
192
227
  return source;
193
228
  });
194
229
  mainTemplate.hooks.hotBootstrap.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
@@ -218,7 +253,9 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
218
253
  hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
219
254
  hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`
220
255
  });
256
+
221
257
  const runtimeSource = _Template.default.getFunctionContent(require('./JsonpMainTemplate.runtime')).replace(/\/\/\$semicolon/g, ';').replace(/\$require\$/g, mainTemplate.requireFn).replace(/\$crossOriginLoading\$/g, crossOriginLoading ? JSON.stringify(crossOriginLoading) : 'null').replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename).replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename).replace(/\$hash\$/g, JSON.stringify(hash));
258
+
222
259
  return `${source}
223
260
  function hotDisposeChunk(chunkId) {
224
261
  delete installedChunks[chunkId];
@@ -4,19 +4,26 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _webpackSources = require("webpack-sources");
11
+
9
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
10
14
  class SourceMapHookPlugin {
11
15
  apply(compiler) {
12
16
  compiler.hooks.emit.tap('SourceMapHookPlugin', compilation => {
13
17
  Object.keys(compilation.assets).forEach(filename => {
14
18
  if (/\.js$/g.test(filename) && !/(\.map.|tp\/)/g.test(filename)) {
15
19
  let source = compilation.assets[filename].source();
20
+
16
21
  let {
17
22
  name
18
23
  } = _path.default.parse(filename);
24
+
19
25
  let src = source;
26
+
20
27
  if (!/(i18n-chunk\/)/g.test(filename)) {
21
28
  src = `${source}\n//# sourceMappingURL=../../js/${name}.js.map`;
22
29
  compilation.assets[filename.replace(/js\//g, 'smap/js/')] = new _webpackSources.RawSource(src);
@@ -27,6 +34,8 @@ class SourceMapHookPlugin {
27
34
  });
28
35
  });
29
36
  }
37
+
30
38
  }
39
+
31
40
  var _default = SourceMapHookPlugin;
32
41
  exports.default = _default;
@@ -4,43 +4,55 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _webpack = require("webpack");
9
+
8
10
  var _fs = _interopRequireDefault(require("fs"));
11
+
9
12
  var _path = _interopRequireDefault(require("path"));
13
+
10
14
  var _crypto = _interopRequireDefault(require("crypto"));
15
+
11
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- /**
13
- * Plugin that generates hash for the provided list of third party files
14
- * Map the provided key with the file hash and add it to the list of exisiting global constants.
15
- * Plugin in turn uses the defineplugin to generate global constants.
16
- */
17
17
 
18
+ /**
19
+ * Plugin that generates hash for the provided list of third party files
20
+ * Map the provided key with the file hash and add it to the list of exisiting global constants.
21
+ * Plugin in turn uses the defineplugin to generate global constants.
22
+ */
18
23
  class TPHashMappingPlugin {
19
24
  constructor(options) {
20
25
  this.fileMappings = options.fileMappings;
21
26
  this.tpFolder = options.tpFolder;
22
27
  return new _webpack.DefinePlugin(this.getFiles());
23
28
  }
29
+
24
30
  getHash(content) {
25
31
  let hash = _crypto.default.createHash('md5');
32
+
26
33
  let data = hash.update(content, 'utf-8');
27
34
  let gen_hash = data.digest('hex');
28
35
  return gen_hash;
29
36
  }
37
+
30
38
  getFiles() {
31
39
  let hashMapping = {};
32
40
  this.fileMappings.forEach(fileInfo => {
33
41
  let filePath = `${_path.default.join(this.tpFolder, fileInfo.filePath, fileInfo.fileName)}`;
42
+
34
43
  if (_fs.default.existsSync(filePath)) {
35
44
  let fileContent = _fs.default.readFileSync(filePath, {
36
45
  encoding: 'utf-8'
37
46
  });
47
+
38
48
  let generatedHash = this.getHash(fileContent);
39
49
  let outputFileSplit = fileInfo.fileName.split('.');
40
50
  outputFileSplit.splice(outputFileSplit.length - 1, 0, generatedHash);
41
51
  let outputFileName = outputFileSplit.join('.');
42
52
  let outputFilePath = `${_path.default.join(this.tpFolder, fileInfo.filePath, outputFileName)}`;
53
+
43
54
  _fs.default.writeFileSync(outputFilePath, fileContent);
55
+
44
56
  hashMapping[fileInfo.key] = JSON.stringify(generatedHash);
45
57
  } else {
46
58
  throw new Error(`Third party file ${fileInfo.fileName} does not exist`);
@@ -48,6 +60,8 @@ class TPHashMappingPlugin {
48
60
  });
49
61
  return hashMapping;
50
62
  }
63
+
51
64
  }
65
+
52
66
  var _default = TPHashMappingPlugin;
53
67
  exports.default = _default;
@@ -4,9 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _webpackSources = require("webpack-sources");
9
+
8
10
  var _uglifycss = _interopRequireDefault(require("uglifycss"));
11
+
9
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
10
14
  class UglifyCSSPlugin {
11
15
  apply(compiler) {
12
16
  compiler.hooks.emit.tap('UglifyCSSPlugin', compilation => {
@@ -14,10 +18,13 @@ class UglifyCSSPlugin {
14
18
  if (/\.css$/.test(filename)) {
15
19
  try {
16
20
  let asset = compilation.assets[filename].source();
21
+
17
22
  if (typeof asset !== 'string') {
18
23
  asset = asset.toString();
19
24
  }
25
+
20
26
  const result = _uglifycss.default.processString(asset);
27
+
21
28
  compilation.assets[filename] = new _webpackSources.RawSource(result);
22
29
  } catch (e) {
23
30
  compilation.errors.push(e);
@@ -26,5 +33,7 @@ class UglifyCSSPlugin {
26
33
  });
27
34
  });
28
35
  }
36
+
29
37
  }
38
+
30
39
  exports.default = UglifyCSSPlugin;
@@ -4,22 +4,30 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _fs = _interopRequireDefault(require("fs"));
11
+
9
12
  var _utils = require("../utils");
13
+
10
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
11
16
  let excludeDocsJSON = '{}';
17
+
12
18
  if (_fs.default.existsSync('./__testUtils__/conf/excludeDocs.json')) {
13
19
  excludeDocsJSON = _fs.default.readFileSync('./__testUtils__/conf/excludeDocs.json').toString();
20
+
14
21
  if (excludeDocsJSON.indexOf('\\') !== -1) {
15
22
  excludeDocsJSON = excludeDocsJSON.replace(/\\/g, '\\\\');
16
23
  }
17
24
  }
18
- let excludeDocsArray = JSON.parse(excludeDocsJSON);
19
- // if (Object.keys(excludeDocsArray).length > 0) {
25
+
26
+ let excludeDocsArray = JSON.parse(excludeDocsJSON); // if (Object.keys(excludeDocsArray).length > 0) {
20
27
  // }
21
28
 
22
29
  let getRegex = regexString => regexString.map(str => new RegExp(str));
30
+
23
31
  class UnusedFilesFindPlugin {
24
32
  constructor(options = {}) {
25
33
  this.usedFilesExcludes = getRegex(options.usedFilesExcludes);
@@ -29,28 +37,38 @@ class UnusedFilesFindPlugin {
29
37
  this.sstest = options.ssTest || false;
30
38
  this.outputFileName = options.outputFileName;
31
39
  this.docsFilename = options.docsFilename || 'Undocsfiles.json';
40
+
32
41
  if (!this.origin) {
33
42
  throw new Error('You must provide origin point of the app');
34
43
  }
35
44
  }
45
+
36
46
  isIgnoredUsedFile(file) {
37
47
  let result;
48
+
38
49
  for (let i = 0; i < this.usedFilesExcludes.length; i++) {
39
50
  let exclude = this.usedFilesExcludes[i];
40
51
  result = exclude.test(file);
52
+
41
53
  if (result) {
42
54
  break;
43
55
  }
44
56
  }
57
+
45
58
  return result;
46
59
  }
60
+
47
61
  unDocumentedFiles(outputPath) {
48
62
  let status = _fs.default.existsSync(_path.default.join(outputPath, this.outputFileName));
63
+
49
64
  let unDocsCompObj = {};
65
+
50
66
  if (status) {
51
67
  let data = _fs.default.readFileSync(_path.default.join(outputPath, this.outputFileName)).toString();
68
+
52
69
  let walkSync = (dir, filelist = [], undocList = []) => {
53
70
  let files = _fs.default.readdirSync(dir);
71
+
54
72
  files.forEach(file => {
55
73
  if (_fs.default.statSync(`${dir}/${file}`).isDirectory()) {
56
74
  filelist = walkSync(`${dir}/${file}`, filelist, undocList); //eslint-disable-line
@@ -73,6 +91,7 @@ class UnusedFilesFindPlugin {
73
91
  unDocsCompObj.withoutDocs = undocList;
74
92
  return filelist;
75
93
  };
94
+
76
95
  unDocsCompObj.noEnteredComp = walkSync(_path.default.join(process.cwd(), 'src', 'components'), [], []);
77
96
  (0, _utils.writeFile)(_path.default.join(outputPath, this.docsFilename), JSON.stringify(unDocsCompObj));
78
97
  Object.keys(unDocsCompObj).forEach(key => {
@@ -89,20 +108,27 @@ class UnusedFilesFindPlugin {
89
108
  });
90
109
  }
91
110
  }
111
+
92
112
  isIgnoredAllFile(file) {
93
113
  let result;
114
+
94
115
  for (let i = 0; i < this.appFilesExcludes.length; i++) {
95
116
  let exclude = this.appFilesExcludes[i];
96
117
  result = exclude.test(file);
118
+
97
119
  if (result) {
98
120
  break;
99
121
  }
100
122
  }
123
+
101
124
  return result;
102
125
  }
126
+
103
127
  getAllFiles(rootPath) {
104
128
  let allFiles = [];
129
+
105
130
  let files = _fs.default.readdirSync(rootPath).map(file => _path.default.join(rootPath, file));
131
+
106
132
  files.forEach(file => {
107
133
  if (_fs.default.statSync(file).isDirectory()) {
108
134
  allFiles = allFiles.concat(this.getAllFiles(file));
@@ -114,6 +140,7 @@ class UnusedFilesFindPlugin {
114
140
  });
115
141
  return allFiles;
116
142
  }
143
+
117
144
  apply(compiler) {
118
145
  compiler.hooks.afterEmit.tap('UnusedFilesShowPlugin', compilation => {
119
146
  let {
@@ -123,6 +150,7 @@ class UnusedFilesFindPlugin {
123
150
  if (!this.isIgnoredUsedFile(usedFile)) {
124
151
  files[usedFile] = true;
125
152
  }
153
+
126
154
  return files;
127
155
  }, {});
128
156
  let allFiles = this.getAllFiles(this.origin);
@@ -132,6 +160,7 @@ class UnusedFilesFindPlugin {
132
160
  unusedFiles.push(file);
133
161
  }
134
162
  });
163
+
135
164
  if (!unusedFiles.length) {
136
165
  (0, _utils.log)('There is no unused files');
137
166
  } else {
@@ -145,14 +174,18 @@ class UnusedFilesFindPlugin {
145
174
  });
146
175
  }
147
176
  }
177
+
148
178
  if (this.delete) {
149
179
  unusedFiles.forEach(file => {
150
180
  _fs.default.unlinkSync(file);
181
+
151
182
  (0, _utils.log)(`Deleted - ${file}`);
152
183
  });
153
184
  }
154
185
  });
155
186
  }
187
+
156
188
  }
189
+
157
190
  var _default = UnusedFilesFindPlugin;
158
191
  exports.default = _default;