@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,16 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  class CssOrderControlPlugin {
8
9
  constructor(options) {
9
10
  this.options = {
10
11
  className: options.className
11
12
  };
12
13
  }
14
+
13
15
  apply(compiler) {
14
16
  // NOTE: we not using this, Reason currently this option is only need for EFC,
15
17
  // So it do not needed.
16
-
17
18
  const className = this.options.className;
18
19
  compiler.hooks.thisCompilation.tap({
19
20
  name: 'CssOrderControlPlugin',
@@ -22,12 +23,14 @@ class CssOrderControlPlugin {
22
23
  compilation.mainTemplate.hooks.requireEnsure.tap('CssOrderControlPlugin', source => {
23
24
  // const str = attributeSetTemplate(cssAttributes, 'linkTag');
24
25
  const replacedStr = source.replace('head.appendChild(linkTag);', `var referenceTag = document.getElementById('${className}');
25
- head.insertBefore(linkTag, referenceTag);`);
26
- // console.log({ s: source, r: replacedStr });
26
+ head.insertBefore(linkTag, referenceTag);`); // console.log({ s: source, r: replacedStr });
27
+
27
28
  return replacedStr;
28
29
  });
29
30
  }
30
31
  });
31
32
  }
33
+
32
34
  }
35
+
33
36
  exports.default = CssOrderControlPlugin;
@@ -4,11 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.CustomAttributePlugin = void 0;
7
+
7
8
  var _Template = _interopRequireDefault(require("webpack/lib/Template"));
9
+
8
10
  var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- /* eslint-disable no-use-before-define */
11
11
 
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ /* eslint-disable no-use-before-define */
12
15
  class CustomAttributePlugin {
13
16
  constructor(options) {
14
17
  this.options = {
@@ -19,35 +22,34 @@ class CustomAttributePlugin {
19
22
  i18nAttributes: options.i18nAttributes || options.attributes || {}
20
23
  };
21
24
  }
25
+
22
26
  addCustomAttributeToDynamicScriptTags(mainTemplate) {
23
27
  const {
24
28
  jsAttributes,
25
29
  cssAttributes,
26
30
  i18nAttributes
27
- } = this.options;
31
+ } = this.options; // NOTE: To add custom Attributes to js Script tags
28
32
 
29
- // NOTE: To add custom Attributes to js Script tags
30
33
  mainTemplate.hooks.jsonpScript.tap('CustomAttributePlugin', source => {
31
34
  const str = attributeSetTemplate(jsAttributes, 'script');
32
35
  return _Template.default.asString([source, ...str]);
33
- });
36
+ }); // NOTE: To add custom Attributes to css link tags
34
37
 
35
- // NOTE: To add custom Attributes to css link tags
36
38
  mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
37
39
  const str = attributeSetTemplate(cssAttributes, 'linkTag');
38
- const replacedStr = source.replace('head.appendChild(linkTag);', `${str.join('')}head.appendChild(linkTag);`);
39
- // console.log({ s: source, r: replacedStr });
40
+ const replacedStr = source.replace('head.appendChild(linkTag);', `${str.join('')}head.appendChild(linkTag);`); // console.log({ s: source, r: replacedStr });
41
+
40
42
  return replacedStr;
41
- });
43
+ }); // NOTE: To add custom Attributes to i18n split js Script tags
42
44
 
43
- // NOTE: To add custom Attributes to i18n split js Script tags
44
45
  mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
45
46
  const str = attributeSetTemplate(i18nAttributes, 'scriptTag');
46
- const replacedStr = source.replace('document.body.appendChild(scriptTag);', `${str.join('')}document.body.appendChild(scriptTag);`);
47
- // console.log({ s: source, r: replacedStr });
47
+ const replacedStr = source.replace('document.body.appendChild(scriptTag);', `${str.join('')}document.body.appendChild(scriptTag);`); // console.log({ s: source, r: replacedStr });
48
+
48
49
  return replacedStr;
49
50
  });
50
51
  }
52
+
51
53
  apply(compiler) {
52
54
  // NOTE: we not using this, Reason currently this option is only need for EFC,
53
55
  // So it do not needed.
@@ -64,14 +66,17 @@ class CustomAttributePlugin {
64
66
  }
65
67
  });
66
68
  }
69
+
67
70
  }
71
+
68
72
  exports.CustomAttributePlugin = CustomAttributePlugin;
73
+
69
74
  function attributeSetTemplate(jsAttributes, variableName) {
70
75
  let str = [];
71
76
  Object.keys(jsAttributes).forEach(key => {
72
77
  const val = jsAttributes[key];
73
78
  str.push(`${variableName}.setAttribute(${JSON.stringify(key)}, ${JSON.stringify(val)});`);
74
- });
75
- // console.log({ str });
79
+ }); // console.log({ str });
80
+
76
81
  return str;
77
82
  }
@@ -4,9 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
9
12
  const pluginName = 'CustomScriptLoadingStrategyPlugin';
13
+
10
14
  class CustomScriptLoadingStrategyPlugin {
11
15
  constructor({
12
16
  scriptLoadingStategey
@@ -14,57 +18,69 @@ class CustomScriptLoadingStrategyPlugin {
14
18
  this.scriptLoadingStrategy = scriptLoadingStategey;
15
19
  this.tagNamesToMatch = ['script'];
16
20
  }
21
+
17
22
  getFileNameFromTagSrc(src) {
18
23
  const fileNameArr = src.split('/');
19
24
  return fileNameArr[fileNameArr.length - 1];
20
25
  }
26
+
21
27
  addAttributestToTag(tag, attributes) {
22
28
  tag.attributes = Object.assign({}, tag.attributes, attributes);
23
29
  }
30
+
24
31
  matchFileName(tag, fileName) {
25
32
  return fileName.test(this.getFileNameFromTagSrc(tag.attributes.src));
26
33
  }
34
+
27
35
  blockingStrategy(tag) {
28
36
  delete tag.attributes.defer;
29
37
  delete tag.attributes.async;
30
38
  }
39
+
31
40
  deferStrategy(tag) {
32
41
  delete tag.attributes.async;
33
42
  }
43
+
34
44
  asyncStrategy(tag) {
35
45
  delete tag.attributes.defer;
36
46
  }
47
+
37
48
  moduleStrategy(tag) {
38
49
  this.deferStrategy(tag);
39
50
  }
51
+
40
52
  matchStrategy(scriptLoadingStrategy, tag) {
41
53
  if (scriptLoadingStrategy === 'blocking') {
42
54
  this.blockingStrategy(tag);
43
55
  }
56
+
44
57
  if (scriptLoadingStrategy === 'defer') {
45
58
  this.deferStrategy(tag);
46
59
  }
60
+
47
61
  if (scriptLoadingStrategy === 'async') {
48
62
  this.asyncStrategy(tag);
49
63
  }
64
+
50
65
  if (scriptLoadingStrategy === 'module') {
51
66
  this.moduleStrategy(tag);
52
67
  }
53
68
  }
69
+
54
70
  matchAndApplyCustomLoadingStrategyToScripts(tags) {
55
71
  Object.keys(this.scriptLoadingStrategy).forEach(scriptLoadingStrategy => {
56
72
  const filesToMatch = this.scriptLoadingStrategy[scriptLoadingStrategy];
57
73
  tags.forEach(tag => {
58
74
  if (this.tagNamesToMatch.includes(tag.tagName) && tag.attributes.src) {
59
75
  const isFileMatch = filesToMatch.some(fileName => this.matchFileName(tag, fileName));
76
+
60
77
  if (isFileMatch) {
61
78
  this.matchStrategy(scriptLoadingStrategy, tag);
62
79
  this.addAttributestToTag(tag, {
63
80
  [scriptLoadingStrategy]: true
64
81
  });
65
82
  }
66
- }
67
- // filesToMatch.forEach(fileName => {
83
+ } // filesToMatch.forEach(fileName => {
68
84
  // if (!this.matchFileName(tag, fileName)) {
69
85
  // return;
70
86
  // }
@@ -73,9 +89,11 @@ class CustomScriptLoadingStrategyPlugin {
73
89
  // [scriptLoadingStrategy]: true
74
90
  // });
75
91
  // });
92
+
76
93
  });
77
94
  });
78
95
  }
96
+
79
97
  apply(compiler) {
80
98
  compiler.hooks.compilation.tap(pluginName, compilation => {
81
99
  _htmlWebpackPlugin.default.getHooks(compilation).alterAssetTagGroups.tapAsync(pluginName, (data, callback) => {
@@ -85,5 +103,7 @@ class CustomScriptLoadingStrategyPlugin {
85
103
  });
86
104
  });
87
105
  }
106
+
88
107
  }
108
+
89
109
  exports.default = CustomScriptLoadingStrategyPlugin;
@@ -4,17 +4,26 @@ 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 _utils = require("../utils");
11
+
9
12
  var _path = _interopRequireDefault(require("path"));
13
+
10
14
  var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
15
+
11
16
  var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
17
+
12
18
  var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
19
+
13
20
  var _EFCTemplatePlugin = _interopRequireDefault(require("./EFCTemplatePlugin"));
21
+
14
22
  var _logger = require("../logger");
15
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
- // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
17
23
 
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
26
+ // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
18
27
  const cliOptions = (0, _utils.getOptions)();
19
28
  const {
20
29
  app: {
@@ -32,18 +41,17 @@ const {
32
41
  createSDkFile,
33
42
  cdnStatement
34
43
  } = efcOptios;
44
+
35
45
  class EFCPlugin {
36
46
  constructor(options = {}) {
37
47
  this.isDevelopment = options.isDevelopment;
38
48
  this.templateFilePath = options.templateFilePath;
39
49
  this.serverUrl = options.serverUrl;
40
- this.i18nFileNameTemplate = options.i18nFileNameTemplate;
41
-
42
- // NOTE: this logic may be needed for i18n splited file name with contenthash cases
50
+ this.i18nFileNameTemplate = options.i18nFileNameTemplate; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
43
51
  // this.i18nManifestFileName = options.i18nManifestFileName;
44
-
45
52
  // IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
46
53
  // So when debugging consider this as well
54
+
47
55
  this.options = Object.assign({}, efcOptios, options);
48
56
  this.options.entryPointName = options.entryPointName || 'efc';
49
57
  this.options.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
@@ -52,8 +60,7 @@ class EFCPlugin {
52
60
  const cssDirAttr = this.options.cssDirAttr || 'data-efc-dir';
53
61
  const localeDefaultValue = this.options.localeDefaultValue || 'en_US';
54
62
  const cssDirDefaultValue = this.options.cssDirDefaultValue || 'ltr';
55
- this.options.localeStatement = options.localeStatement ||
56
- // Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
63
+ this.options.localeStatement = options.localeStatement || // Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
57
64
  // Statment 2: return langEle ? langEle.getAttribute('${localeAttr}') : 'en_US';
58
65
  // We are using statement1 not statment2,
59
66
  // Because even that attribute doesn't have value, We need default value
@@ -65,9 +72,7 @@ class EFCPlugin {
65
72
  let dirEle = document.querySelector('[${cssDirAttr}]');
66
73
  return dirEle && dirEle.getAttribute('${cssDirAttr}') || '${cssDirDefaultValue}';
67
74
  })();`;
68
- }
69
-
70
- // NOTE: this logic may be needed for i18n splited file name with contenthash cases
75
+ } // NOTE: this logic may be needed for i18n splited file name with contenthash cases
71
76
  // getI18nManifest(compilation) {
72
77
  // const i18nManifestFile =
73
78
  // compilation.assets[this.options.i18nManifestFileName];
@@ -78,11 +83,12 @@ class EFCPlugin {
78
83
  // return {};
79
84
  // }
80
85
 
86
+
81
87
  getI18nAssetsStr(entryPoint, compilation) {
82
88
  if (!chunkSplitEnable) {
83
89
  let i18nAsstes = {};
84
- const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
85
- //hook for i18n url contains i18n/ may cause problem
90
+ const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
91
+
86
92
  i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
87
93
  const fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
88
94
  const splittedFileName = fileName.split('.');
@@ -91,9 +97,11 @@ class EFCPlugin {
91
97
  }, {});
92
98
  return `[${JSON.stringify(i18nAsstes)}[lang]]`;
93
99
  }
100
+
94
101
  const initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
95
102
  return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
96
103
  }
104
+
97
105
  createFileContent(compilation) {
98
106
  const {
99
107
  entryPointName,
@@ -105,19 +113,18 @@ class EFCPlugin {
105
113
  const {
106
114
  serverUrl
107
115
  } = this;
108
- const cssDirTemplate = '@dir@';
109
- // const i18nManifest = this.getI18nManifest(compilation);
110
- const entryPoint = compilation.entrypoints.get(entryPointName);
111
- // const chunk = compilation.namedChunks.get(entryPointName);
116
+ const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
117
+
118
+ const entryPoint = compilation.entrypoints.get(entryPointName); // const chunk = compilation.namedChunks.get(entryPointName);
119
+
112
120
  const [jsPath, cssPath,,, i18nJsPath] = !this.isDevelopment ? publicPaths : [];
113
121
  const initialFiles = entryPoint.getFiles();
114
- const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
115
-
116
- // const i18nAssets = getShortI18nAssets(
122
+ const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file)); // const i18nAssets = getShortI18nAssets(
117
123
  // entryPoint.chunks,
118
124
  // i18nManifest,
119
125
  // i18nJsPath
120
126
  // );
127
+
121
128
  const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, i18nJsPath);
122
129
  return `(() => {
123
130
  const lang = ${localeStatement};
@@ -196,10 +203,12 @@ class EFCPlugin {
196
203
  })();
197
204
  `;
198
205
  }
206
+
199
207
  apply(compiler) {
200
208
  if (!createSDkFile) {
201
209
  return;
202
210
  }
211
+
203
212
  if (this.templateFilePath) {
204
213
  new _EFCTemplatePlugin.default({
205
214
  templateFilePath: this.templateFilePath,
@@ -209,19 +218,24 @@ class EFCPlugin {
209
218
  }).apply(compiler);
210
219
  return;
211
220
  }
221
+
212
222
  compiler.hooks.emit.tap('EFCPlugin', compilation => {
213
223
  const {
214
224
  entryPointName,
215
225
  outputFile
216
226
  } = this.options;
217
227
  const entryPoint = compilation.entrypoints.get(entryPointName);
228
+
218
229
  if (!entryPoint) {
219
230
  return;
220
231
  }
232
+
221
233
  const source = new _webpackSources.RawSource(this.createFileContent(compilation));
222
234
  compilation.assets[outputFile] = source;
223
235
  (0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
224
236
  });
225
237
  }
238
+
226
239
  }
240
+
227
241
  exports.default = EFCPlugin;
@@ -4,17 +4,26 @@ 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 _utils = require("../utils");
11
+
9
12
  var _path = _interopRequireDefault(require("path"));
13
+
10
14
  var _fs = require("fs");
15
+
11
16
  var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
17
+
12
18
  var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
19
+
13
20
  var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
21
+
14
22
  var _logger = require("../logger");
15
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
- // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
17
23
 
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
26
+ // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
18
27
  const cliOptions = (0, _utils.getOptions)();
19
28
  const {
20
29
  i18n: {
@@ -27,9 +36,7 @@ const {
27
36
  } = cliOptions;
28
37
  const {
29
38
  createSDkFile
30
- } = efcOptios;
31
-
32
- // for smap relate changes
39
+ } = efcOptios; // for smap relate changes
33
40
  // CdnChangePlugin
34
41
  // SourceMapHookPlugin
35
42
 
@@ -37,20 +44,15 @@ class EFCTemplatePlugin {
37
44
  constructor(options = {}) {
38
45
  this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath);
39
46
  this.i18nFileNameTemplate = options.i18nFileNameTemplate;
40
- this.publicPath = options.publicPath;
41
-
42
- // NOTE: this logic may be needed for i18n splited file name with contenthash cases
47
+ this.publicPath = options.publicPath; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
43
48
  // this.i18nManifestFileName = options.i18nManifestFileName;
44
-
45
49
  // IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
46
50
  // So when debugging consider this as well
47
51
  // this.options = Object.assign({}, efcOptios, options);
48
52
 
49
53
  this.entryPointName = options.entryPointName || 'efc';
50
54
  this.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
51
- }
52
-
53
- // NOTE: this logic may be needed for i18n splited file name with contenthash cases
55
+ } // NOTE: this logic may be needed for i18n splited file name with contenthash cases
54
56
  // getI18nManifest(compilation) {
55
57
  // const i18nManifestFile =
56
58
  // compilation.assets[this.options.i18nManifestFileName];
@@ -61,12 +63,13 @@ class EFCTemplatePlugin {
61
63
  // return {};
62
64
  // }
63
65
 
66
+
64
67
  getI18nAssetsStr(entryPoint, compilation) {
65
68
  // NOTE: we have used lang variable inside
66
69
  if (!chunkSplitEnable) {
67
70
  let i18nAsstes = {};
68
- const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
69
- //hook for i18n url contains i18n/ may cause problem
71
+ const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
72
+
70
73
  i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
71
74
  const fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
72
75
  const splittedFileName = fileName.split('.');
@@ -75,27 +78,28 @@ class EFCTemplatePlugin {
75
78
  }, {});
76
79
  return `[${JSON.stringify(i18nAsstes)}[lang]]`;
77
80
  }
81
+
78
82
  const initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
79
83
  return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
80
84
  }
85
+
81
86
  templateReplacer(entryPoint, compilation) {
82
- const cssDirTemplate = '@dir@';
83
- // const i18nManifest = this.getI18nManifest(compilation);
87
+ const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
84
88
 
85
89
  const initialFiles = entryPoint.getFiles();
86
90
  const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
87
91
  const initialJsFiles = filteredInitialFiles.filter(file => /\.js$/.test(file));
88
92
  let initialCssFiles = filteredInitialFiles.filter(file => /\.css$/.test(file));
93
+
89
94
  if (enableRTLSplit) {
90
95
  initialCssFiles = initialCssFiles.map(filePath => (0, _replaceCssDirTemplate.replaceCssDirTemplate)(filePath, cssDirTemplate));
91
- }
92
-
93
- // const i18nAssets = getShortI18nAssets(
96
+ } // const i18nAssets = getShortI18nAssets(
94
97
  // entryPoint.chunks,
95
98
  // i18nManifest,
96
99
  // '' // i18nJsPath
97
100
  // );
98
101
 
102
+
99
103
  const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, '' // i18nJsPath
100
104
  );
101
105
  const templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
@@ -112,27 +116,34 @@ class EFCTemplatePlugin {
112
116
  return [];
113
117
  }`).replace('((\'@dir@\'))', '\'@dir@\'').replace('((\'publicPath\'))', this.publicPath).replace('((\'@locale@\'))', '\'@locale@\'');
114
118
  }
119
+
115
120
  apply(compiler) {
116
121
  if (!createSDkFile) {
117
122
  return;
118
123
  }
124
+
119
125
  compiler.hooks.emit.tap('EFCTemplatePlugin', compilation => {
120
126
  const {
121
127
  entryPointName,
122
128
  outputFile
123
129
  } = this;
124
130
  const entryPoint = compilation.entrypoints.get(entryPointName);
131
+
125
132
  if (!entryPoint) {
126
133
  return;
127
134
  }
135
+
128
136
  if (!(0, _fs.existsSync)(this.templateFilePath)) {
129
137
  console.error(`EFC Template file not exists ${this.templateFilePath}`);
130
138
  return;
131
139
  }
140
+
132
141
  const source = new _webpackSources.RawSource(this.templateReplacer(entryPoint, compilation));
133
142
  compilation.assets[outputFile] = source;
134
143
  (0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
135
144
  });
136
145
  }
146
+
137
147
  }
148
+
138
149
  exports.default = EFCTemplatePlugin;
@@ -3,11 +3,13 @@
3
3
  const {
4
4
  Template
5
5
  } = require('webpack');
6
+
6
7
  const plugInName = 'EFCResourceCleanup';
7
8
  module.exports = class EfcResouceCleanupPlugin {
8
9
  constructor(options) {
9
10
  this.options = options;
10
11
  }
12
+
11
13
  apply(compiler) {
12
14
  compiler.hooks.thisCompilation.tap(plugInName, ({
13
15
  mainTemplate
@@ -37,4 +39,5 @@ module.exports = class EfcResouceCleanupPlugin {
37
39
  });
38
40
  });
39
41
  }
42
+
40
43
  };
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.EventsHandlingPlugin = void 0;
7
- /* eslint-disable no-use-before-define */
8
7
 
8
+ /* eslint-disable no-use-before-define */
9
9
  class EventsHandlingPlugin {
10
10
  constructor(options) {}
11
+
11
12
  apply(compiler) {
12
13
  // NOTE: we not using this, Reason currently this option is only need for EFC,
13
14
  // So it do not needed.
14
-
15
15
  compiler.hooks.thisCompilation.tap({
16
16
  name: 'CustomAttributePlugin',
17
17
  stage: 1,
@@ -28,5 +28,7 @@ class EventsHandlingPlugin {
28
28
  }
29
29
  });
30
30
  }
31
+
31
32
  }
33
+
32
34
  exports.EventsHandlingPlugin = EventsHandlingPlugin;