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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -179
  3. package/.prettierrc +6 -6
  4. package/README.md +1028 -951
  5. package/bin/cli.js +483 -483
  6. package/cert/Tsicsezwild-22-23.crt +37 -37
  7. package/cert/Tsicsezwild-22-23.key +27 -27
  8. package/docs/CustomChunks.md +26 -26
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/TODOS.md +10 -10
  13. package/docs/ValueReplacer.md +60 -60
  14. package/docs/VariableConversion.md +678 -0
  15. package/docs/warnings_while_install.txt +35 -35
  16. package/files/eslintrc.js +62 -62
  17. package/files/prettierrc.js +3 -3
  18. package/lib/babel/cmjs-plugins-presets.js +0 -4
  19. package/lib/babel/es-plugins-presets.js +0 -4
  20. package/lib/common/getEntries.js +0 -10
  21. package/lib/common/getPublicPathConfig.js +0 -6
  22. package/lib/common/index.js +0 -5
  23. package/lib/common/splitChunks.js +2 -13
  24. package/lib/common/sslcertUpdater.js +6 -17
  25. package/lib/common/templateParameters.js +0 -2
  26. package/lib/common/testPattern.js +10 -21
  27. package/lib/common/valueReplacer.js +0 -15
  28. package/lib/configs/jest.config.js +8 -21
  29. package/lib/configs/libAlias.js +11 -2
  30. package/lib/configs/webpack.component.umd.config.js +0 -5
  31. package/lib/configs/webpack.css.umd.config.js +5 -13
  32. package/lib/configs/webpack.dev.config.js +13 -24
  33. package/lib/configs/webpack.docs.config.js +6 -12
  34. package/lib/configs/webpack.impact.config.js +6 -10
  35. package/lib/configs/webpack.prod.config.js +15 -26
  36. package/lib/hooks/docsProptypeHook.js +3 -7
  37. package/lib/jest/commitedFilesResult.js +3 -45
  38. package/lib/jest/coverageCollector.js +0 -11
  39. package/lib/jest/jsonMaker.js +0 -6
  40. package/lib/jest/preProcessors/cssPreprocessor.js +14 -13
  41. package/lib/jest/preProcessors/jsPreprocessor.js +0 -2
  42. package/lib/jest/preProcessors/otherFilesPreprocessor.js +0 -3
  43. package/lib/jest/result.js +0 -22
  44. package/lib/jest/run.js +6 -17
  45. package/lib/jest/setup.js +5 -57
  46. package/lib/loaderUtils/configsAssetsLoaders.js +34 -44
  47. package/lib/loaderUtils/getCSSLoaders.js +41 -28
  48. package/lib/loaderUtils/getDevJsLoaders.js +0 -8
  49. package/lib/loaderUtils/index.js +0 -3
  50. package/lib/loaders/docsLoader.js +0 -7
  51. package/lib/loaders/docsPropsLoader.js +3 -7
  52. package/lib/loaders/fileBountryLoader.js +0 -2
  53. package/lib/loaders/fileLoader.js +11 -22
  54. package/lib/loaders/scriptInstrumentLoader.js +5 -13
  55. package/lib/loaders/selectorMappingLoader.js +7 -25
  56. package/lib/loaders/workerLoader.js +13 -29
  57. package/lib/middlewares/HMRMiddleware.js +13 -26
  58. package/lib/middlewares/SSTMiddleware.js +0 -3
  59. package/lib/pluginUtils/configHtmlWebpackPlugins.js +53 -0
  60. package/lib/pluginUtils/getDevPlugins.js +20 -64
  61. package/lib/pluginUtils/getDocsPlugins.js +1 -10
  62. package/lib/pluginUtils/getLibraryImactPlugins.js +4 -5
  63. package/lib/pluginUtils/getLibraryPlugins.js +0 -5
  64. package/lib/pluginUtils/getProdPlugins.js +32 -78
  65. package/lib/pluginUtils/getServerPlugins.js +0 -5
  66. package/lib/pluginUtils/getUMDCSSPlugins.js +0 -7
  67. package/lib/pluginUtils/getUMDComponentPlugins.js +0 -7
  68. package/lib/pluginUtils/index.js +0 -8
  69. package/lib/plugins/CdnChangePlugin.js +0 -14
  70. package/lib/plugins/CleanupStatsPlugin.js +0 -5
  71. package/lib/plugins/EFCPlugin.js +23 -34
  72. package/lib/plugins/EFCPlugin.md +6 -6
  73. package/lib/plugins/EFCTemplatePlugin.js +23 -32
  74. package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -38
  75. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +12 -17
  76. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
  77. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +46 -77
  78. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +44 -59
  79. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +21 -30
  80. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  81. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  82. package/lib/plugins/I18nSplitPlugin/index.js +70 -80
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
  85. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
  86. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +0 -6
  87. package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
  88. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +2 -20
  89. package/lib/plugins/ManifestPlugin.js +0 -17
  90. package/lib/plugins/ModuleStatsPlugin.js +0 -23
  91. package/lib/plugins/OptimizeJSPlugin.js +0 -7
  92. package/lib/plugins/PublicPathCallbackPlugin.js +0 -10
  93. package/lib/plugins/PublicPathChangePlugin.js +4 -36
  94. package/lib/plugins/ReportGeneratePlugin.js +4 -30
  95. package/lib/plugins/RequireVariablePublicPlugin.js +0 -6
  96. package/lib/plugins/ResourceHintsPlugin.js +20 -27
  97. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
  98. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +23 -38
  99. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  100. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
  101. package/lib/plugins/ScriptInstrumentPlugin.js +0 -7
  102. package/lib/plugins/ServiceWorkerPlugin.js +13 -29
  103. package/lib/plugins/ShadowDOMSupportPlugin.js +3 -40
  104. package/lib/plugins/SourceMapHookPlugin.js +0 -9
  105. package/lib/plugins/TPHashMappingPlugin.js +5 -19
  106. package/lib/plugins/UglifyCSSPlugin.js +0 -9
  107. package/lib/plugins/UnusedFilesFindPlugin.js +2 -35
  108. package/lib/plugins/index.js +0 -19
  109. package/lib/plugins/libraryImpactPlugin.js +0 -32
  110. package/lib/plugins/webpackwatchrunplugin.js +0 -5
  111. package/lib/postcss-plugins/ExcludePlugin.js +0 -4
  112. package/lib/postcss-plugins/RTLSplitPlugin.js +24 -37
  113. package/lib/postcss-plugins/ValueReplacer.js +9 -6
  114. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
  115. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  116. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  117. package/lib/postcss-plugins/hoverActivePlugin.js +80 -92
  118. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +31 -0
  119. package/lib/postcss-plugins/variableModificationPlugin/index.js +232 -0
  120. package/lib/postcss-plugins/variableModifier.js +14 -20
  121. package/lib/schemas/index.js +28 -13
  122. package/lib/servers/clusterHubServer.js +0 -10
  123. package/lib/servers/devBuild.js +13 -24
  124. package/lib/servers/docsServer.js +0 -2
  125. package/lib/servers/docsServerCore.js +0 -21
  126. package/lib/servers/getCliPath.js +1 -10
  127. package/lib/servers/helpServer.js +0 -5
  128. package/lib/servers/httpsOptions.js +0 -4
  129. package/lib/servers/impactServer.js +2 -34
  130. package/lib/servers/mockserver.js +0 -9
  131. package/lib/servers/nowatchserver.js +12 -34
  132. package/lib/servers/scrServer.js +13 -20
  133. package/lib/servers/server.js +7 -35
  134. package/lib/servers/ssServer.js +0 -16
  135. package/lib/sh/pre-commit.sh +34 -34
  136. package/lib/sh/reportPublish.sh +45 -45
  137. package/lib/templates/CoverageScriptTemplate.js +0 -14
  138. package/lib/templates/WMSTemplate.js +6 -12
  139. package/lib/utils/babelPresets.js +0 -2
  140. package/lib/utils/buildstats.html +148 -148
  141. package/lib/utils/clean.js +2 -8
  142. package/lib/utils/copy.js +0 -6
  143. package/lib/utils/copyTimezones.js +0 -8
  144. package/lib/utils/createEventStream.js +0 -4
  145. package/lib/utils/cssClassNameGenerate.js +3 -19
  146. package/lib/utils/cssURLReplacer.js +0 -25
  147. package/lib/utils/dependencyPostPublish.js +0 -9
  148. package/lib/utils/fileUtils.js +0 -26
  149. package/lib/utils/folderIterator.js +0 -10
  150. package/lib/utils/getComponents.js +0 -21
  151. package/lib/utils/getCurrentBranch.js +0 -5
  152. package/lib/utils/getDependenciesImpactList.js +0 -21
  153. package/lib/utils/getHash.js +0 -7
  154. package/lib/utils/getIp.js +0 -2
  155. package/lib/utils/getOptions.js +38 -35
  156. package/lib/utils/getServerURL.js +0 -7
  157. package/lib/utils/index.js +2 -47
  158. package/lib/utils/init.js +0 -1
  159. package/lib/utils/initPreCommitHook.js +6 -29
  160. package/lib/utils/jsonHelper.js +2 -19
  161. package/lib/utils/libraryImpactConfig.js +0 -2
  162. package/lib/utils/lint/addScripts.js +2 -5
  163. package/lib/utils/lint/checkExistingConfig.js +3 -12
  164. package/lib/utils/lint/copyConfigs.js +0 -3
  165. package/lib/utils/lint/index.js +0 -9
  166. package/lib/utils/lint/lintScripts.js +0 -1
  167. package/lib/utils/lint/lintSetup.js +3 -4
  168. package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
  169. package/lib/utils/lint/question.js +0 -7
  170. package/lib/utils/lintReporter.js +0 -20
  171. package/lib/utils/mailSender.js +0 -7
  172. package/lib/utils/pullOrigin.js +0 -4
  173. package/lib/utils/reinstallDependencies.js +0 -28
  174. package/lib/utils/removeAttributes.js +0 -7
  175. package/lib/utils/repoClone.js +2 -27
  176. package/lib/utils/request.js +0 -12
  177. package/lib/utils/resultSchema.json +73 -73
  178. package/lib/utils/rtl.js +4 -16
  179. package/lib/utils/setEnvVariables.js +0 -2
  180. package/lib/utils/ssTestHack.js +0 -10
  181. package/lib/utils/switchBranch.js +0 -4
  182. package/lib/utils/urlConcat.js +0 -4
  183. package/lib/utils/useExitCleanup.js +9 -10
  184. package/npm8.md +9 -9
  185. package/package.json +146 -148
  186. package/postpublish.js +6 -6
  187. package/templates/app/.eslintrc.js +140 -140
  188. package/templates/app/README.md +12 -12
  189. package/templates/app/app/index.html +24 -24
  190. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  191. package/templates/app/app/properties/i18nkeys.json +3 -3
  192. package/templates/app/docs/all.html +69 -69
  193. package/templates/app/mockapi/index.js +18 -18
  194. package/templates/app/package.json +37 -37
  195. package/templates/app/src/actions/SampleActions/index.js +37 -37
  196. package/templates/app/src/actions/index.js +65 -65
  197. package/templates/app/src/appUrls.js +19 -19
  198. package/templates/app/src/components/Alert/Alert.js +134 -134
  199. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  200. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  201. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  202. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  203. package/templates/app/src/components/Sample/SampleList.js +61 -61
  204. package/templates/app/src/components/Slider/Slider.css +41 -41
  205. package/templates/app/src/components/Slider/Slider.js +55 -55
  206. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  207. package/templates/app/src/containers/AppContainer/index.js +96 -96
  208. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  209. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  210. package/templates/app/src/containers/DevTools/index.js +10 -10
  211. package/templates/app/src/containers/Header/index.js +67 -67
  212. package/templates/app/src/containers/Header/index.module.css +43 -43
  213. package/templates/app/src/containers/Redirect/index.js +63 -63
  214. package/templates/app/src/containers/Redirector/index.js +47 -47
  215. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  216. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  217. package/templates/app/src/historyChange.js +5 -5
  218. package/templates/app/src/index.html +10 -10
  219. package/templates/app/src/index.js +24 -24
  220. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  221. package/templates/app/src/reducers/alertData.js +11 -11
  222. package/templates/app/src/reducers/index.js +6 -6
  223. package/templates/app/src/reducers/samples.js +19 -19
  224. package/templates/app/src/store/configureStore.dev.js +51 -51
  225. package/templates/app/src/store/configureStore.js +5 -5
  226. package/templates/app/src/store/configureStore.prod.js +26 -26
  227. package/templates/app/src/util/Common.js +5 -5
  228. package/templates/app/src/util/RequestAPI.js +132 -132
  229. package/templates/docs/all.html +249 -249
  230. package/templates/docs/component.html +178 -178
  231. package/templates/docs/components.html +221 -221
  232. package/templates/docs/css/b.min.css +6 -6
  233. package/templates/docs/css/component.css +42 -42
  234. package/templates/docs/css/componentTest.css +6 -6
  235. package/templates/docs/css/hopscotch.css +585 -585
  236. package/templates/docs/css/style.css +1022 -1022
  237. package/templates/docs/impactReportTemplate.html +154 -154
  238. package/templates/docs/index.html +1501 -1493
  239. package/templates/docs/js/active-line.js +72 -72
  240. package/templates/docs/js/b.min.js +7 -7
  241. package/templates/docs/js/codemirror.js +9680 -9680
  242. package/templates/docs/js/designTokens.js +334 -334
  243. package/templates/docs/js/j.min.js +4 -4
  244. package/templates/docs/js/javascript.js +874 -874
  245. package/templates/docs/js/matchbrackets.js +145 -145
@@ -1,30 +1,30 @@
1
- # RTL Split
2
-
3
- we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
4
- It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
5
- Here is problem mostly no one need rtl and ltr related css at the same time in browser,
6
- we are try to split them by [dir] and load which type of css is needed.
7
- For this purpose we created RTL Split Plugin
8
-
9
-
10
- # To Try it out rtl-ltr split
11
- ### how to use this feature?
12
-
13
- to use this feature use have give the below oprtions
14
- `package.json`
15
- ```json
16
- {
17
- /// ...some things
18
- "react-cli": {
19
- // ...some things
20
- "css": {
21
- "enableRTLSplit": true,
22
- "templateLabel": "{{--dir}}",// this is for html template css file path dir template
23
- "disableMiniFiySelector": false,
24
- "dirVarName": "document.dir" // this will be used for download css based on dir
25
- },
26
- // ...some things
27
- }
28
- }
29
- ```
30
-
1
+ # RTL Split
2
+
3
+ we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
4
+ It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
5
+ Here is problem mostly no one need rtl and ltr related css at the same time in browser,
6
+ we are try to split them by [dir] and load which type of css is needed.
7
+ For this purpose we created RTL Split Plugin
8
+
9
+
10
+ # To Try it out rtl-ltr split
11
+ ### how to use this feature?
12
+
13
+ to use this feature use have give the below oprtions
14
+ `package.json`
15
+ ```json
16
+ {
17
+ /// ...some things
18
+ "react-cli": {
19
+ // ...some things
20
+ "css": {
21
+ "enableRTLSplit": true,
22
+ "templateLabel": "{{--dir}}",// this is for html template css file path dir template
23
+ "disableMiniFiySelector": false,
24
+ "dirVarName": "document.dir" // this will be used for download css based on dir
25
+ },
26
+ // ...some things
27
+ }
28
+ }
29
+ ```
30
+
@@ -6,21 +6,18 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.replaceCssDirTemplate = replaceCssDirTemplate;
7
7
  exports.replaceCssDirTemplateMapper = replaceCssDirTemplateMapper;
8
8
  exports.strFunctionTempalteToReplaceCssDir = void 0;
9
-
10
9
  function replaceCssDirTemplate(filePath, cssDirTemplate) {
11
- return filePath.endsWith('.ltr.css') ? // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
10
+ return filePath.endsWith('.ltr.css') ?
11
+ // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
12
12
  filePath.replace('.ltr.css', `.${cssDirTemplate}.css`) : filePath;
13
13
  }
14
-
15
14
  function replaceCssDirTemplateMapper(assets, cssDirTemplate) {
16
15
  return assets.map(filePath => replaceCssDirTemplate(filePath, cssDirTemplate));
17
16
  }
18
-
19
17
  const strFunctionTempalteToReplaceCssDir = cssDirTemplate => `function replaceCssDirTemplate(filePath, cssDirTemplate) {
20
18
  return filePath.endsWith(".ltr.css")
21
19
  ? // ? cssPath.replace('.ltr.css', '.{{--dir}}.css')
22
20
  filePath.replace(".ltr.css", ".${cssDirTemplate}.css")
23
21
  : filePath;
24
22
  }`;
25
-
26
23
  exports.strFunctionTempalteToReplaceCssDir = strFunctionTempalteToReplaceCssDir;
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _fs = _interopRequireDefault(require("fs"));
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  let coverageScript = _fs.default.readFileSync(_path.default.resolve(__dirname, '..', 'templates', 'CoverageScriptTemplate.js')).toString();
15
-
16
11
  class ScriptInstrumentPlugin {
17
12
  apply(compiler) {
18
13
  compiler.hooks.emit.tapAsync('ScriptInstrumentPlugin', (compilation, callback) => {
@@ -30,7 +25,5 @@ class ScriptInstrumentPlugin {
30
25
  callback();
31
26
  });
32
27
  }
33
-
34
28
  }
35
-
36
29
  exports.default = ScriptInstrumentPlugin;
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _fs = _interopRequireDefault(require("fs"));
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
-
12
9
  var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
13
-
14
10
  var _utils = require("../utils");
15
-
16
11
  var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
17
-
18
12
  var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
14
  const {
23
15
  css: {
24
16
  enableRTLSplit
@@ -27,36 +19,35 @@ const {
27
19
  chunkSplitEnable
28
20
  }
29
21
  } = (0, _utils.getOptions)();
30
-
31
22
  class ServiceWorkerPlugin {
32
23
  constructor(options) {
33
24
  this.i18nFileNameTemplate = options.i18nFileNameTemplate;
34
25
  this.fileName = options.fileName;
35
26
  this.serviceWorkerPath = options.filePath;
36
27
  this.writePath = options.exitPath;
37
- this.replaceText = options.replaceText; // this.publicPaths = options.publicPaths;
28
+ this.replaceText = options.replaceText;
29
+ // this.publicPaths = options.publicPaths;
38
30
  }
39
31
 
40
32
  isInitialChunk(chunk) {
41
33
  if ('canBeInitial' in chunk) {
42
34
  return chunk.canBeInitial();
43
35
  }
44
-
45
36
  return chunk.isInitial();
46
37
  }
47
-
48
38
  apply(compiler) {
49
39
  compiler.hooks.emit.tap('ServiceWorkerPlugin', compilation => {
50
40
  _fs.default.readFile(this.serviceWorkerPath, 'utf-8', (err, data) => {
51
41
  if (err) {
52
42
  throw new Error(err);
53
43
  } else {
54
- /* const extractedChunks = compilation.chunks.filter(chunk => {
55
- if ('canBeInitial' in chunk) {
56
- return chunk.canBeInitial();
57
- }
58
- return chunk.isInitial();
44
+ /* const extractedChunks = compilation.chunks.filter(chunk => {
45
+ if ('canBeInitial' in chunk) {
46
+ return chunk.canBeInitial();
47
+ }
48
+ return chunk.isInitial();
59
49
  }); */
50
+
60
51
  // let [js, css, , , i18nPublicPath] = this.publicPaths;
61
52
  // let initialChunkUrls = [];
62
53
  let allChunkUrls = [];
@@ -64,44 +55,37 @@ class ServiceWorkerPlugin {
64
55
  let entrypoint = compilation.entrypoints.get('main');
65
56
  let initialChunkUrls = entrypoint.getFiles();
66
57
  const cssDirTemplate = '@dir@';
67
- /**
68
- * NOTE:
69
- * if chunkSplitEnable is false means,
70
- * serviceWorker will get i18n files path for html
58
+ /**
59
+ * NOTE:
60
+ * if chunkSplitEnable is false means,
61
+ * serviceWorker will get i18n files path for html
71
62
  */
72
-
73
63
  let initalI18nAssets = chunkSplitEnable ? entrypoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')) : [];
74
64
  chunkSplitEnable && compilation.chunks.filter(c => !this.isInitialChunk(c)).filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).forEach(chunk => {
75
65
  // let isInitial = this.isInitialChunk(chunk);
76
66
  allChunkUrls = allChunkUrls.concat(chunk.files);
77
67
  allI18nAssets.push((0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
78
68
  });
79
- /** Removing source map files from getting added */
80
69
 
70
+ /** Removing source map files from getting added */
81
71
  initialChunkUrls = initialChunkUrls.filter(fileName => !fileName.endsWith('.map'));
82
72
  allChunkUrls = allChunkUrls.filter(fileName => !fileName.endsWith('.map'));
83
-
84
73
  if (enableRTLSplit) {
85
74
  initialChunkUrls = (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(initialChunkUrls, cssDirTemplate);
86
75
  allChunkUrls = (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(allChunkUrls, cssDirTemplate);
87
76
  }
88
-
89
77
  let mod = data.replace(this.replaceText, `
90
78
  self.assets = ${JSON.stringify(initialChunkUrls.concat(initalI18nAssets))};
91
79
  self.allChunks = ${JSON.stringify(allChunkUrls.concat(allI18nAssets))};`);
92
-
93
80
  if (!_fs.default.existsSync(this.writePath)) {
94
81
  _fs.default.mkdirSync(this.writePath, {
95
82
  recursive: true
96
83
  });
97
84
  }
98
-
99
85
  _fs.default.writeFileSync(_path.default.join(this.writePath, this.fileName), mod);
100
86
  }
101
87
  });
102
88
  });
103
89
  }
104
-
105
90
  }
106
-
107
91
  exports.default = ServiceWorkerPlugin;
@@ -4,27 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = ShadowDOMSupportPlugin;
7
-
8
7
  var _Template = _interopRequireDefault(require("webpack/lib/Template"));
9
-
10
8
  var _JsonpMainTemplatePlugin = _interopRequireDefault(require("webpack/lib/web/JsonpMainTemplatePlugin"));
11
-
12
9
  var _tapable = require("tapable");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  /* eslint-disable no-unused-vars */
12
+
17
13
  //eslint-disable-next-line
18
14
  function ShadowDOMSupportPlugin() {}
19
-
20
15
  ShadowDOMSupportPlugin.prototype.apply = function () {
21
16
  this.patchJsonpMainTemplatePlugin();
22
17
  };
23
-
24
18
  ShadowDOMSupportPlugin.prototype.patchJsonpMainTemplatePlugin = function () {
25
19
  _JsonpMainTemplatePlugin.default.prototype.apply = this._apply;
26
20
  };
27
-
28
21
  ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
29
22
  const needChunkOnDemandLoadingCode = chunk => {
30
23
  for (const chunkGroup of chunk.groupsIterable) {
@@ -32,46 +25,38 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
32
25
  return true;
33
26
  }
34
27
  }
35
-
36
28
  return false;
37
29
  };
38
-
39
30
  const needChunkLoadingCode = chunk => {
40
31
  for (const chunkGroup of chunk.groupsIterable) {
41
32
  if (chunkGroup.chunks.length > 1) {
42
33
  return true;
43
34
  }
44
-
45
35
  if (chunkGroup.getNumberOfChildren() > 0) {
46
36
  return true;
47
37
  }
48
38
  }
49
-
50
39
  return false;
51
40
  };
52
-
53
41
  const needEntryDeferringCode = chunk => {
54
42
  for (const chunkGroup of chunk.groupsIterable) {
55
43
  if (chunkGroup.chunks.length > 1) {
56
44
  return true;
57
45
  }
58
46
  }
59
-
60
47
  return false;
61
48
  };
62
-
63
49
  const needPrefetchingCode = chunk => {
64
50
  const allPrefetchChunks = chunk.getChildIdsByOrdersMap(true).prefetch;
65
51
  return allPrefetchChunks && Object.keys(allPrefetchChunks).length;
66
- }; // TODO webpack 5, no adding to .hooks, use WeakMap and static methods
67
-
52
+ };
68
53
 
54
+ // TODO webpack 5, no adding to .hooks, use WeakMap and static methods
69
55
  ['jsonpScript', 'linkPreload', 'linkPrefetch'].forEach(hook => {
70
56
  if (!mainTemplate.hooks[hook]) {
71
57
  mainTemplate.hooks[hook] = new _tapable.SyncWaterfallHook(['source', 'chunk', 'hash']);
72
58
  }
73
59
  });
74
-
75
60
  const getScriptSrcPath = (hash, chunk, chunkIdExpression) => {
76
61
  const {
77
62
  chunkFilename
@@ -83,19 +68,15 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
83
68
  chunk: {
84
69
  id: `" + ${chunkIdExpression} + "`,
85
70
  hash: `" + ${JSON.stringify(chunkMaps.hash)}[${chunkIdExpression}] + "`,
86
-
87
71
  hashWithLength(length) {
88
72
  const shortChunkHashMap = Object.create(null);
89
-
90
73
  for (const chunkId of Object.keys(chunkMaps.hash)) {
91
74
  if (typeof chunkMaps.hash[chunkId] === 'string') {
92
75
  shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
93
76
  }
94
77
  }
95
-
96
78
  return `" + ${JSON.stringify(shortChunkHashMap)}[${chunkIdExpression}] + "`;
97
79
  },
98
-
99
80
  name: `" + (${JSON.stringify(chunkMaps.name)}[${chunkIdExpression}]||${chunkIdExpression}) + "`,
100
81
  contentHash: {
101
82
  javascript: `" + ${JSON.stringify(chunkMaps.contentHash.javascript)}[${chunkIdExpression}] + "`
@@ -104,13 +85,11 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
104
85
  javascript: length => {
105
86
  const shortContentHashMap = {};
106
87
  const contentHash = chunkMaps.contentHash.javascript;
107
-
108
88
  for (const chunkId of Object.keys(contentHash)) {
109
89
  if (typeof contentHash[chunkId] === 'string') {
110
90
  shortContentHashMap[chunkId] = contentHash[chunkId].substr(0, length);
111
91
  }
112
92
  }
113
-
114
93
  return `" + ${JSON.stringify(shortContentHashMap)}[${chunkIdExpression}] + "`;
115
94
  }
116
95
  }
@@ -118,22 +97,17 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
118
97
  contentHashType: 'javascript'
119
98
  });
120
99
  };
121
-
122
100
  mainTemplate.hooks.localVars.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
123
101
  const extraCode = [];
124
-
125
102
  if (needChunkLoadingCode(chunk)) {
126
103
  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 = [];' : '');
127
104
  }
128
-
129
105
  if (needChunkOnDemandLoadingCode(chunk)) {
130
106
  extraCode.push('', '// script path function', 'function jsonpScriptSrc(chunkId) {', _Template.default.indent([`return ${mainTemplate.requireFn}.p + ${getScriptSrcPath(hash, chunk, 'chunkId')}`]), '}');
131
107
  }
132
-
133
108
  if (extraCode.length === 0) {
134
109
  return source;
135
110
  }
136
-
137
111
  return _Template.default.asString([source, ...extraCode]);
138
112
  });
139
113
  mainTemplate.hooks.jsonpScript.tap('JsonpMainTemplatePlugin', (_, chunk, hash) => {
@@ -169,18 +143,15 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
169
143
  stage: 10
170
144
  }, (source, chunk, hash) => {
171
145
  const chunkMap = chunk.getChildIdsByOrdersMap().preload;
172
-
173
146
  if (!chunkMap || Object.keys(chunkMap).length === 0) {
174
147
  return source;
175
148
  }
176
-
177
149
  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);']), '}']), '});']), '}']);
178
150
  });
179
151
  mainTemplate.hooks.requireExtensions.tap('JsonpMainTemplatePlugin', (source, chunk) => {
180
152
  if (!needChunkOnDemandLoadingCode(chunk)) {
181
153
  return source;
182
154
  }
183
-
184
155
  return _Template.default.asString([source, '', '// on error function for async loading', `${mainTemplate.requireFn}.oe = function(err) { console.error(err); throw err; };`]);
185
156
  });
186
157
  mainTemplate.hooks.bootstrap.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
@@ -189,7 +160,6 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
189
160
  const withPrefetch = needPrefetchingCode(chunk);
190
161
  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;']), '}']) : '']);
191
162
  }
192
-
193
163
  return source;
194
164
  });
195
165
  mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
@@ -202,16 +172,13 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
202
172
  } = mainTemplate.outputOptions;
203
173
  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]);
204
174
  }
205
-
206
175
  return source;
207
176
  });
208
177
  mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
209
178
  const prefetchChunks = chunk.getChildIdsByOrders().prefetch;
210
-
211
179
  if (needChunkLoadingCode(chunk) && prefetchChunks && prefetchChunks.length) {
212
180
  return _Template.default.asString([source, `webpackJsonpCallback([[], {}, 0, ${JSON.stringify(prefetchChunks)}]);`]);
213
181
  }
214
-
215
182
  return source;
216
183
  });
217
184
  mainTemplate.hooks.startup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
@@ -220,10 +187,8 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
220
187
  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)));
221
188
  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();']);
222
189
  }
223
-
224
190
  return _Template.default.asString(['// run deferred modules from other chunks', 'checkDeferredModules();']);
225
191
  }
226
-
227
192
  return source;
228
193
  });
229
194
  mainTemplate.hooks.hotBootstrap.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
@@ -253,9 +218,7 @@ ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
253
218
  hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
254
219
  hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`
255
220
  });
256
-
257
221
  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
-
259
222
  return `${source}
260
223
  function hotDisposeChunk(chunkId) {
261
224
  delete installedChunks[chunkId];
@@ -4,26 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _webpackSources = require("webpack-sources");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  class SourceMapHookPlugin {
15
11
  apply(compiler) {
16
12
  compiler.hooks.emit.tap('SourceMapHookPlugin', compilation => {
17
13
  Object.keys(compilation.assets).forEach(filename => {
18
14
  if (/\.js$/g.test(filename) && !/(\.map.|tp\/)/g.test(filename)) {
19
15
  let source = compilation.assets[filename].source();
20
-
21
16
  let {
22
17
  name
23
18
  } = _path.default.parse(filename);
24
-
25
19
  let src = source;
26
-
27
20
  if (!/(i18n-chunk\/)/g.test(filename)) {
28
21
  src = `${source}\n//# sourceMappingURL=../../js/${name}.js.map`;
29
22
  compilation.assets[filename.replace(/js\//g, 'smap/js/')] = new _webpackSources.RawSource(src);
@@ -34,8 +27,6 @@ class SourceMapHookPlugin {
34
27
  });
35
28
  });
36
29
  }
37
-
38
30
  }
39
-
40
31
  var _default = SourceMapHookPlugin;
41
32
  exports.default = _default;
@@ -4,55 +4,43 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _webpack = require("webpack");
9
-
10
8
  var _fs = _interopRequireDefault(require("fs"));
11
-
12
9
  var _path = _interopRequireDefault(require("path"));
13
-
14
10
  var _crypto = _interopRequireDefault(require("crypto"));
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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.
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.
22
16
  */
17
+
23
18
  class TPHashMappingPlugin {
24
19
  constructor(options) {
25
20
  this.fileMappings = options.fileMappings;
26
21
  this.tpFolder = options.tpFolder;
27
22
  return new _webpack.DefinePlugin(this.getFiles());
28
23
  }
29
-
30
24
  getHash(content) {
31
25
  let hash = _crypto.default.createHash('md5');
32
-
33
26
  let data = hash.update(content, 'utf-8');
34
27
  let gen_hash = data.digest('hex');
35
28
  return gen_hash;
36
29
  }
37
-
38
30
  getFiles() {
39
31
  let hashMapping = {};
40
32
  this.fileMappings.forEach(fileInfo => {
41
33
  let filePath = `${_path.default.join(this.tpFolder, fileInfo.filePath, fileInfo.fileName)}`;
42
-
43
34
  if (_fs.default.existsSync(filePath)) {
44
35
  let fileContent = _fs.default.readFileSync(filePath, {
45
36
  encoding: 'utf-8'
46
37
  });
47
-
48
38
  let generatedHash = this.getHash(fileContent);
49
39
  let outputFileSplit = fileInfo.fileName.split('.');
50
40
  outputFileSplit.splice(outputFileSplit.length - 1, 0, generatedHash);
51
41
  let outputFileName = outputFileSplit.join('.');
52
42
  let outputFilePath = `${_path.default.join(this.tpFolder, fileInfo.filePath, outputFileName)}`;
53
-
54
43
  _fs.default.writeFileSync(outputFilePath, fileContent);
55
-
56
44
  hashMapping[fileInfo.key] = JSON.stringify(generatedHash);
57
45
  } else {
58
46
  throw new Error(`Third party file ${fileInfo.fileName} does not exist`);
@@ -60,8 +48,6 @@ class TPHashMappingPlugin {
60
48
  });
61
49
  return hashMapping;
62
50
  }
63
-
64
51
  }
65
-
66
52
  var _default = TPHashMappingPlugin;
67
53
  exports.default = _default;
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _webpackSources = require("webpack-sources");
9
-
10
8
  var _uglifycss = _interopRequireDefault(require("uglifycss"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  class UglifyCSSPlugin {
15
11
  apply(compiler) {
16
12
  compiler.hooks.emit.tap('UglifyCSSPlugin', compilation => {
@@ -18,13 +14,10 @@ class UglifyCSSPlugin {
18
14
  if (/\.css$/.test(filename)) {
19
15
  try {
20
16
  let asset = compilation.assets[filename].source();
21
-
22
17
  if (typeof asset !== 'string') {
23
18
  asset = asset.toString();
24
19
  }
25
-
26
20
  const result = _uglifycss.default.processString(asset);
27
-
28
21
  compilation.assets[filename] = new _webpackSources.RawSource(result);
29
22
  } catch (e) {
30
23
  compilation.errors.push(e);
@@ -33,7 +26,5 @@ class UglifyCSSPlugin {
33
26
  });
34
27
  });
35
28
  }
36
-
37
29
  }
38
-
39
30
  exports.default = UglifyCSSPlugin;