@zohodesk/react-cli 1.1.29-exp.1 → 1.1.29-exp.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 (221) hide show
  1. package/lib/babel/babel-option-utils/babel-preset-react-option.js +0 -3
  2. package/lib/babel/cmjs-plugins-presets.js +1 -8
  3. package/lib/babel/es-plugins-presets.js +1 -8
  4. package/lib/common/buildEs.js +1 -0
  5. package/lib/common/getEntries.js +2 -13
  6. package/lib/common/getPublicPathConfig.js +0 -6
  7. package/lib/common/index.js +1 -6
  8. package/lib/common/runPreProcess.js +6 -15
  9. package/lib/common/splitChunks.js +2 -21
  10. package/lib/common/sslcertUpdater.js +7 -18
  11. package/lib/common/templateParameters.js +0 -2
  12. package/lib/common/testPattern.js +10 -21
  13. package/lib/common/valueReplacer.js +1 -16
  14. package/lib/configs/jest.config.js +1 -10
  15. package/lib/configs/libAlias.js +8 -14
  16. package/lib/configs/resolvers.js +4 -14
  17. package/lib/configs/webpack.component.umd.config.js +1 -6
  18. package/lib/configs/webpack.css.umd.config.js +6 -14
  19. package/lib/configs/webpack.dev.config.js +1 -14
  20. package/lib/configs/webpack.docs.config.js +1 -9
  21. package/lib/configs/webpack.impact.config.js +1 -8
  22. package/lib/configs/webpack.prod.config.js +4 -17
  23. package/lib/constants.js +9 -18
  24. package/lib/deprecationLogger.js +0 -7
  25. package/lib/hooks/docsProptypeHook.js +4 -8
  26. package/lib/jest/commitedFilesResult.js +4 -46
  27. package/lib/jest/coverageCollector.js +1 -12
  28. package/lib/jest/jsonMaker.js +0 -6
  29. package/lib/jest/preProcessors/cssPreprocessor.js +1 -9
  30. package/lib/jest/preProcessors/jsPreprocessor.js +1 -6
  31. package/lib/jest/preProcessors/otherFilesPreprocessor.js +1 -4
  32. package/lib/jest/result.js +1 -23
  33. package/lib/jest/run.js +7 -18
  34. package/lib/jest/setup.js +8 -60
  35. package/lib/loaderUtils/configsAssetsLoaders.js +2 -12
  36. package/lib/loaderUtils/getCSSLoaders.js +10 -22
  37. package/lib/loaderUtils/getDevJsLoaders.js +4 -13
  38. package/lib/loaderUtils/index.js +1 -4
  39. package/lib/loaderUtils/tests/windowsModification.test.js +0 -1
  40. package/lib/loaderUtils/windowsModification.js +2 -3
  41. package/lib/loaders/__test__/markdownLoader.spec.js +0 -1
  42. package/lib/loaders/composeLoader.js +13 -37
  43. package/lib/loaders/docsLoader.js +1 -12
  44. package/lib/loaders/docsPropsLoader.js +4 -8
  45. package/lib/loaders/enhancedReactLiveConverter.js +2 -23
  46. package/lib/loaders/fileBountryLoader.js +1 -3
  47. package/lib/loaders/fileLoader.js +12 -23
  48. package/lib/loaders/markdownLoader.js +14 -19
  49. package/lib/loaders/reactLiveConvertor.js +5 -15
  50. package/lib/loaders/scriptInstrumentLoader.js +7 -16
  51. package/lib/loaders/selectorMappingLoader.js +7 -26
  52. package/lib/loaders/workerLoader.js +9 -24
  53. package/lib/logger.js +0 -4
  54. package/lib/middlewares/HMRMiddleware.js +13 -27
  55. package/lib/middlewares/SSTMiddleware.js +1 -5
  56. package/lib/pluginUtils/configHtmlWebpackPlugins.js +1 -24
  57. package/lib/pluginUtils/getDevPlugins.js +9 -42
  58. package/lib/pluginUtils/getDocsPlugins.js +3 -13
  59. package/lib/pluginUtils/getLibraryImactPlugins.js +5 -6
  60. package/lib/pluginUtils/getLibraryPlugins.js +2 -8
  61. package/lib/pluginUtils/getProdPlugins.js +8 -47
  62. package/lib/pluginUtils/getServerPlugins.js +2 -8
  63. package/lib/pluginUtils/getUMDCSSPlugins.js +2 -10
  64. package/lib/pluginUtils/getUMDComponentPlugins.js +2 -10
  65. package/lib/pluginUtils/index.js +1 -9
  66. package/lib/plugins/CdnChangePlugin.js +2 -18
  67. package/lib/plugins/CleanupStatsPlugin.js +0 -5
  68. package/lib/plugins/CssOrderControlPlugin.js +3 -6
  69. package/lib/plugins/CustomAttributePlugin.js +14 -19
  70. package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +3 -23
  71. package/lib/plugins/EFCPlugin.js +20 -34
  72. package/lib/plugins/EFCTemplatePlugin.js +19 -30
  73. package/lib/plugins/EfcResourceCleanupPlugin.js +0 -3
  74. package/lib/plugins/EventsHandlingPlugin.js +2 -4
  75. package/lib/plugins/I18NInjectIntoIndexPlugin.js +11 -37
  76. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +10 -15
  77. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
  78. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +12 -25
  79. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +55 -133
  80. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +12 -23
  81. package/lib/plugins/I18nSplitPlugin/index.js +13 -24
  82. package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +64 -58
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
  84. package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +10 -29
  85. package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +8 -19
  86. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
  87. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
  88. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +1 -8
  89. package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
  90. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -20
  91. package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +0 -1
  92. package/lib/plugins/ManifestPlugin.js +1 -18
  93. package/lib/plugins/MinifyPlugin.js +1 -10
  94. package/lib/plugins/ModuleStatsPlugin.js +1 -24
  95. package/lib/plugins/OptimizeJSPlugin.js +2 -10
  96. package/lib/plugins/PublicPathCallbackPlugin.js +1 -12
  97. package/lib/plugins/PublicPathChangePlugin.js +6 -39
  98. package/lib/plugins/ReportGeneratePlugin.js +5 -32
  99. package/lib/plugins/RequireVariablePublicPlugin.js +1 -8
  100. package/lib/plugins/ResourceHintsPlugin.js +4 -13
  101. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
  102. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +10 -17
  103. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
  104. package/lib/plugins/ScriptInstrumentPlugin.js +1 -8
  105. package/lib/plugins/SelectorPlugin.js +6 -32
  106. package/lib/plugins/ServiceWorkerPlugin.js +5 -22
  107. package/lib/plugins/ShadowDOMSupportPlugin.js +4 -41
  108. package/lib/plugins/SourceMapHookPlugin.js +2 -12
  109. package/lib/plugins/StatsPlugin.js +0 -14
  110. package/lib/plugins/TPHashMappingPlugin.js +3 -18
  111. package/lib/plugins/UnusedFilesFindPlugin.js +4 -39
  112. package/lib/plugins/VariableConversionCollector.js +15 -42
  113. package/lib/plugins/index.js +1 -20
  114. package/lib/plugins/libraryImpactPlugin.js +1 -33
  115. package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +306 -0
  116. package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +363 -0
  117. package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +694 -0
  118. package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +1258 -0
  119. package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +542 -0
  120. package/lib/plugins/newi18nsplitplugin/18nplugin.js +974 -0
  121. package/lib/plugins/newi18nsplitplugin/ChunkManager.js +131 -0
  122. package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +59 -0
  123. package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +262 -0
  124. package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +166 -0
  125. package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +111 -0
  126. package/lib/plugins/newi18nsplitplugin/KeyCollector.js +163 -0
  127. package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +88 -0
  128. package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +101 -0
  129. package/lib/plugins/newi18nsplitplugin/constants.js +162 -0
  130. package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +78 -0
  131. package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +22 -0
  132. package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +18 -0
  133. package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +580 -0
  134. package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +54 -0
  135. package/lib/plugins/utils/classHandling.js +0 -6
  136. package/lib/plugins/utils/fileHandling.js +6 -15
  137. package/lib/plugins/utils/tests/fileHandling.test.js +0 -4
  138. package/lib/plugins/variableConvertorUtils.js +14 -29
  139. package/lib/plugins/webpackwatchrunplugin.js +0 -5
  140. package/lib/postcss-plugins/EmptyPlugin.js +3 -4
  141. package/lib/postcss-plugins/ExcludePlugin.js +1 -5
  142. package/lib/postcss-plugins/IncludePlugin.js +1 -5
  143. package/lib/postcss-plugins/RTLSplitPlugin.js +14 -27
  144. package/lib/postcss-plugins/SelectorReplace.js +1 -16
  145. package/lib/postcss-plugins/ValueReplacer.js +7 -6
  146. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
  147. package/lib/postcss-plugins/__test__/selectorReplace.test.js +6 -3
  148. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +2 -5
  149. package/lib/postcss-plugins/hoverActivePlugin.js +31 -67
  150. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -7
  151. package/lib/postcss-plugins/variableModificationPlugin/index.js +28 -49
  152. package/lib/schemas/index.js +3 -9
  153. package/lib/servers/clusterHubServer.js +1 -11
  154. package/lib/servers/devBuild.js +14 -26
  155. package/lib/servers/docsServer.js +1 -3
  156. package/lib/servers/docsServerCore.js +1 -22
  157. package/lib/servers/getCliPath.js +0 -9
  158. package/lib/servers/helpServer.js +1 -6
  159. package/lib/servers/httpsOptions.js +2 -8
  160. package/lib/servers/impactServer.js +3 -35
  161. package/lib/servers/mockserver.js +1 -10
  162. package/lib/servers/nowatchserver.js +12 -37
  163. package/lib/servers/requireLocalOrGlobal.js +6 -17
  164. package/lib/servers/scrServer.js +14 -21
  165. package/lib/servers/server.js +6 -36
  166. package/lib/servers/ssServer.js +1 -17
  167. package/lib/templates/CoverageScriptTemplate.js +0 -14
  168. package/lib/templates/WMSTemplate.js +7 -13
  169. package/lib/templates/linterConstant.js +2 -4
  170. package/lib/utils/babelPresets.js +3 -7
  171. package/lib/utils/clean.js +3 -9
  172. package/lib/utils/copy.js +1 -7
  173. package/lib/utils/copyTimezones.js +1 -9
  174. package/lib/utils/createEventStream.js +1 -6
  175. package/lib/utils/cssClassNameGenerate.js +10 -30
  176. package/lib/utils/cssURLReplacer.js +1 -22
  177. package/lib/utils/dependencyPostPublish.js +1 -10
  178. package/lib/utils/deprecationSupport.js +7 -32
  179. package/lib/utils/fileUtils.js +1 -28
  180. package/lib/utils/folderIterator.js +2 -13
  181. package/lib/utils/getComponents.js +0 -21
  182. package/lib/utils/getCurrentBranch.js +0 -5
  183. package/lib/utils/getDependenciesImpactList.js +1 -22
  184. package/lib/utils/getFileType.js +2 -10
  185. package/lib/utils/getHash.js +1 -8
  186. package/lib/utils/getIp.js +0 -2
  187. package/lib/utils/getOptions.js +16 -53
  188. package/lib/utils/getServerURL.js +1 -10
  189. package/lib/utils/index.js +4 -51
  190. package/lib/utils/init.js +0 -1
  191. package/lib/utils/initPreCommitHook.js +7 -30
  192. package/lib/utils/jsonHelper.js +3 -22
  193. package/lib/utils/libraryImpactConfig.js +2 -5
  194. package/lib/utils/lint/addScripts.js +2 -5
  195. package/lib/utils/lint/checkExistingConfig.js +3 -12
  196. package/lib/utils/lint/copyConfigs.js +0 -3
  197. package/lib/utils/lint/index.js +0 -9
  198. package/lib/utils/lint/lintScripts.js +0 -1
  199. package/lib/utils/lint/lintSetup.js +3 -4
  200. package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
  201. package/lib/utils/lint/question.js +0 -7
  202. package/lib/utils/lintReporter.js +0 -20
  203. package/lib/utils/log.js +0 -1
  204. package/lib/utils/mailSender.js +1 -8
  205. package/lib/utils/object-manipulation.js +1 -17
  206. package/lib/utils/pullOrigin.js +0 -4
  207. package/lib/utils/reinstallDependencies.js +1 -29
  208. package/lib/utils/removeAttributes.js +1 -8
  209. package/lib/utils/repoClone.js +3 -28
  210. package/lib/utils/request.js +0 -12
  211. package/lib/utils/rtl.js +5 -17
  212. package/lib/utils/selectorReplacer.js +10 -16
  213. package/lib/utils/setEnvVariables.js +0 -2
  214. package/lib/utils/ssTestHack.js +1 -11
  215. package/lib/utils/switchBranch.js +0 -5
  216. package/lib/utils/typeCheck.js +0 -1
  217. package/lib/utils/urlConcat.js +0 -4
  218. package/lib/utils/useExitCleanup.js +9 -10
  219. package/lib/utils/variableConverter.js +22 -31
  220. package/{npm-shrinkwrap.json → package-lock.json} +2098 -1999
  221. package/package.json +1 -1
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.CustomAttributePlugin = void 0;
7
-
8
7
  var _Template = _interopRequireDefault(require("webpack/lib/Template"));
9
-
10
8
  var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
10
  /* eslint-disable no-use-before-define */
11
+
15
12
  class CustomAttributePlugin {
16
13
  constructor(options) {
17
14
  this.options = {
@@ -22,34 +19,35 @@ class CustomAttributePlugin {
22
19
  i18nAttributes: options.i18nAttributes || options.attributes || {}
23
20
  };
24
21
  }
25
-
26
22
  addCustomAttributeToDynamicScriptTags(mainTemplate) {
27
23
  const {
28
24
  jsAttributes,
29
25
  cssAttributes,
30
26
  i18nAttributes
31
- } = this.options; // NOTE: To add custom Attributes to js Script tags
27
+ } = this.options;
32
28
 
29
+ // NOTE: To add custom Attributes to js Script tags
33
30
  mainTemplate.hooks.jsonpScript.tap('CustomAttributePlugin', source => {
34
31
  const str = attributeSetTemplate(jsAttributes, 'script');
35
32
  return _Template.default.asString([source, ...str]);
36
- }); // NOTE: To add custom Attributes to css link tags
33
+ });
37
34
 
35
+ // NOTE: To add custom Attributes to css link tags
38
36
  mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
39
37
  const str = attributeSetTemplate(cssAttributes, 'linkTag');
40
- const replacedStr = source.replace('head.appendChild(linkTag);', `${str.join('')}head.appendChild(linkTag);`); // console.log({ s: source, r: replacedStr });
41
-
38
+ const replacedStr = source.replace('head.appendChild(linkTag);', `${str.join('')}head.appendChild(linkTag);`);
39
+ // console.log({ s: source, r: replacedStr });
42
40
  return replacedStr;
43
- }); // NOTE: To add custom Attributes to i18n split js Script tags
41
+ });
44
42
 
43
+ // NOTE: To add custom Attributes to i18n split js Script tags
45
44
  mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
46
45
  const str = attributeSetTemplate(i18nAttributes, 'scriptTag');
47
- const replacedStr = source.replace('document.body.appendChild(scriptTag);', `${str.join('')}document.body.appendChild(scriptTag);`); // console.log({ s: source, r: replacedStr });
48
-
46
+ const replacedStr = source.replace('document.body.appendChild(scriptTag);', `${str.join('')}document.body.appendChild(scriptTag);`);
47
+ // console.log({ s: source, r: replacedStr });
49
48
  return replacedStr;
50
49
  });
51
50
  }
52
-
53
51
  apply(compiler) {
54
52
  // NOTE: we not using this, Reason currently this option is only need for EFC,
55
53
  // So it do not needed.
@@ -66,17 +64,14 @@ class CustomAttributePlugin {
66
64
  }
67
65
  });
68
66
  }
69
-
70
67
  }
71
-
72
68
  exports.CustomAttributePlugin = CustomAttributePlugin;
73
-
74
69
  function attributeSetTemplate(jsAttributes, variableName) {
75
70
  let str = [];
76
71
  Object.keys(jsAttributes).forEach(key => {
77
72
  const val = jsAttributes[key];
78
73
  str.push(`${variableName}.setAttribute(${JSON.stringify(key)}, ${JSON.stringify(val)});`);
79
- }); // console.log({ str });
80
-
74
+ });
75
+ // console.log({ str });
81
76
  return str;
82
77
  }
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
9
  const pluginName = 'CustomScriptLoadingStrategyPlugin';
13
-
14
10
  class CustomScriptLoadingStrategyPlugin {
15
11
  constructor({
16
12
  scriptLoadingStategey
@@ -18,69 +14,57 @@ class CustomScriptLoadingStrategyPlugin {
18
14
  this.scriptLoadingStrategy = scriptLoadingStategey;
19
15
  this.tagNamesToMatch = ['script'];
20
16
  }
21
-
22
17
  getFileNameFromTagSrc(src) {
23
18
  const fileNameArr = src.split('/');
24
19
  return fileNameArr[fileNameArr.length - 1];
25
20
  }
26
-
27
21
  addAttributestToTag(tag, attributes) {
28
22
  tag.attributes = Object.assign({}, tag.attributes, attributes);
29
23
  }
30
-
31
24
  matchFileName(tag, fileName) {
32
25
  return fileName.test(this.getFileNameFromTagSrc(tag.attributes.src));
33
26
  }
34
-
35
27
  blockingStrategy(tag) {
36
28
  delete tag.attributes.defer;
37
29
  delete tag.attributes.async;
38
30
  }
39
-
40
31
  deferStrategy(tag) {
41
32
  delete tag.attributes.async;
42
33
  }
43
-
44
34
  asyncStrategy(tag) {
45
35
  delete tag.attributes.defer;
46
36
  }
47
-
48
37
  moduleStrategy(tag) {
49
38
  this.deferStrategy(tag);
50
39
  }
51
-
52
40
  matchStrategy(scriptLoadingStrategy, tag) {
53
41
  if (scriptLoadingStrategy === 'blocking') {
54
42
  this.blockingStrategy(tag);
55
43
  }
56
-
57
44
  if (scriptLoadingStrategy === 'defer') {
58
45
  this.deferStrategy(tag);
59
46
  }
60
-
61
47
  if (scriptLoadingStrategy === 'async') {
62
48
  this.asyncStrategy(tag);
63
49
  }
64
-
65
50
  if (scriptLoadingStrategy === 'module') {
66
51
  this.moduleStrategy(tag);
67
52
  }
68
53
  }
69
-
70
54
  matchAndApplyCustomLoadingStrategyToScripts(tags) {
71
55
  Object.keys(this.scriptLoadingStrategy).forEach(scriptLoadingStrategy => {
72
56
  const filesToMatch = this.scriptLoadingStrategy[scriptLoadingStrategy];
73
57
  tags.forEach(tag => {
74
58
  if (this.tagNamesToMatch.includes(tag.tagName) && tag.attributes.src) {
75
59
  const isFileMatch = filesToMatch.some(fileName => this.matchFileName(tag, fileName));
76
-
77
60
  if (isFileMatch) {
78
61
  this.matchStrategy(scriptLoadingStrategy, tag);
79
62
  this.addAttributestToTag(tag, {
80
63
  [scriptLoadingStrategy]: true
81
64
  });
82
65
  }
83
- } // filesToMatch.forEach(fileName => {
66
+ }
67
+ // filesToMatch.forEach(fileName => {
84
68
  // if (!this.matchFileName(tag, fileName)) {
85
69
  // return;
86
70
  // }
@@ -89,11 +73,9 @@ class CustomScriptLoadingStrategyPlugin {
89
73
  // [scriptLoadingStrategy]: true
90
74
  // });
91
75
  // });
92
-
93
76
  });
94
77
  });
95
78
  }
96
-
97
79
  apply(compiler) {
98
80
  compiler.hooks.compilation.tap(pluginName, compilation => {
99
81
  _htmlWebpackPlugin.default.getHooks(compilation).alterAssetTagGroups.tapAsync(pluginName, (data, callback) => {
@@ -103,7 +85,5 @@ class CustomScriptLoadingStrategyPlugin {
103
85
  });
104
86
  });
105
87
  }
106
-
107
88
  }
108
-
109
89
  exports.default = CustomScriptLoadingStrategyPlugin;
@@ -4,26 +4,17 @@ 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 _utils = require("../utils");
11
-
12
9
  var _path = _interopRequireDefault(require("path"));
13
-
14
10
  var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
15
-
16
11
  var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
17
-
18
12
  var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
19
-
20
13
  var _EFCTemplatePlugin = _interopRequireDefault(require("./EFCTemplatePlugin"));
21
-
22
14
  var _logger = require("../logger");
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26
16
  // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
17
+
27
18
  const cliOptions = (0, _utils.getOptions)();
28
19
  const {
29
20
  app: {
@@ -41,17 +32,18 @@ const {
41
32
  createSDkFile,
42
33
  cdnStatement
43
34
  } = efcOptios;
44
-
45
35
  class EFCPlugin {
46
36
  constructor(options = {}) {
47
37
  this.isDevelopment = options.isDevelopment;
48
38
  this.templateFilePath = options.templateFilePath;
49
39
  this.serverUrl = options.serverUrl;
50
- this.i18nFileNameTemplate = options.i18nFileNameTemplate; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
40
+ this.i18nFileNameTemplate = options.i18nFileNameTemplate;
41
+
42
+ // NOTE: this logic may be needed for i18n splited file name with contenthash cases
51
43
  // this.i18nManifestFileName = options.i18nManifestFileName;
44
+
52
45
  // IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
53
46
  // So when debugging consider this as well
54
-
55
47
  this.options = Object.assign({}, efcOptios, options);
56
48
  this.options.entryPointName = options.entryPointName || 'efc';
57
49
  this.options.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
@@ -60,7 +52,8 @@ class EFCPlugin {
60
52
  const cssDirAttr = this.options.cssDirAttr || 'data-efc-dir';
61
53
  const localeDefaultValue = this.options.localeDefaultValue || 'en_US';
62
54
  const cssDirDefaultValue = this.options.cssDirDefaultValue || 'ltr';
63
- this.options.localeStatement = options.localeStatement || // Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
55
+ this.options.localeStatement = options.localeStatement ||
56
+ // Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
64
57
  // Statment 2: return langEle ? langEle.getAttribute('${localeAttr}') : 'en_US';
65
58
  // We are using statement1 not statment2,
66
59
  // Because even that attribute doesn't have value, We need default value
@@ -72,7 +65,9 @@ class EFCPlugin {
72
65
  let dirEle = document.querySelector('[${cssDirAttr}]');
73
66
  return dirEle && dirEle.getAttribute('${cssDirAttr}') || '${cssDirDefaultValue}';
74
67
  })();`;
75
- } // NOTE: this logic may be needed for i18n splited file name with contenthash cases
68
+ }
69
+
70
+ // NOTE: this logic may be needed for i18n splited file name with contenthash cases
76
71
  // getI18nManifest(compilation) {
77
72
  // const i18nManifestFile =
78
73
  // compilation.assets[this.options.i18nManifestFileName];
@@ -83,12 +78,11 @@ class EFCPlugin {
83
78
  // return {};
84
79
  // }
85
80
 
86
-
87
81
  getI18nAssetsStr(entryPoint, compilation) {
88
82
  if (!chunkSplitEnable) {
89
83
  let i18nAsstes = {};
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
-
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
92
86
  i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
93
87
  const fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
94
88
  const splittedFileName = fileName.split('.');
@@ -97,11 +91,9 @@ class EFCPlugin {
97
91
  }, {});
98
92
  return `[${JSON.stringify(i18nAsstes)}[lang]]`;
99
93
  }
100
-
101
94
  const initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
102
95
  return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
103
96
  }
104
-
105
97
  createFileContent(compilation) {
106
98
  const {
107
99
  entryPointName,
@@ -113,18 +105,19 @@ class EFCPlugin {
113
105
  const {
114
106
  serverUrl
115
107
  } = this;
116
- const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
117
-
118
- const entryPoint = compilation.entrypoints.get(entryPointName); // const chunk = compilation.namedChunks.get(entryPointName);
119
-
108
+ const cssDirTemplate = '@dir@';
109
+ // const i18nManifest = this.getI18nManifest(compilation);
110
+ const entryPoint = compilation.entrypoints.get(entryPointName);
111
+ // const chunk = compilation.namedChunks.get(entryPointName);
120
112
  const [jsPath, cssPath,,, i18nJsPath] = !this.isDevelopment ? publicPaths : [];
121
113
  const initialFiles = entryPoint.getFiles();
122
- const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file)); // const i18nAssets = getShortI18nAssets(
114
+ const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
115
+
116
+ // const i18nAssets = getShortI18nAssets(
123
117
  // entryPoint.chunks,
124
118
  // i18nManifest,
125
119
  // i18nJsPath
126
120
  // );
127
-
128
121
  const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, i18nJsPath);
129
122
  return `(() => {
130
123
  const lang = ${localeStatement};
@@ -203,12 +196,10 @@ class EFCPlugin {
203
196
  })();
204
197
  `;
205
198
  }
206
-
207
199
  apply(compiler) {
208
200
  if (!createSDkFile) {
209
201
  return;
210
202
  }
211
-
212
203
  if (this.templateFilePath) {
213
204
  new _EFCTemplatePlugin.default({
214
205
  templateFilePath: this.templateFilePath,
@@ -218,24 +209,19 @@ class EFCPlugin {
218
209
  }).apply(compiler);
219
210
  return;
220
211
  }
221
-
222
212
  compiler.hooks.emit.tap('EFCPlugin', compilation => {
223
213
  const {
224
214
  entryPointName,
225
215
  outputFile
226
216
  } = this.options;
227
217
  const entryPoint = compilation.entrypoints.get(entryPointName);
228
-
229
218
  if (!entryPoint) {
230
219
  return;
231
220
  }
232
-
233
221
  const source = new _webpackSources.RawSource(this.createFileContent(compilation));
234
222
  compilation.assets[outputFile] = source;
235
223
  (0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
236
224
  });
237
225
  }
238
-
239
226
  }
240
-
241
227
  exports.default = EFCPlugin;
@@ -4,26 +4,17 @@ 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 _utils = require("../utils");
11
-
12
9
  var _path = _interopRequireDefault(require("path"));
13
-
14
10
  var _fs = require("fs");
15
-
16
11
  var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
17
-
18
12
  var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
19
-
20
13
  var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
21
-
22
14
  var _logger = require("../logger");
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26
16
  // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
17
+
27
18
  const cliOptions = (0, _utils.getOptions)();
28
19
  const {
29
20
  i18n: {
@@ -36,7 +27,9 @@ const {
36
27
  } = cliOptions;
37
28
  const {
38
29
  createSDkFile
39
- } = efcOptios; // for smap relate changes
30
+ } = efcOptios;
31
+
32
+ // for smap relate changes
40
33
  // CdnChangePlugin
41
34
  // SourceMapHookPlugin
42
35
 
@@ -44,15 +37,20 @@ class EFCTemplatePlugin {
44
37
  constructor(options = {}) {
45
38
  this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath);
46
39
  this.i18nFileNameTemplate = options.i18nFileNameTemplate;
47
- this.publicPath = options.publicPath; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
40
+ this.publicPath = options.publicPath;
41
+
42
+ // NOTE: this logic may be needed for i18n splited file name with contenthash cases
48
43
  // this.i18nManifestFileName = options.i18nManifestFileName;
44
+
49
45
  // IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
50
46
  // So when debugging consider this as well
51
47
  // this.options = Object.assign({}, efcOptios, options);
52
48
 
53
49
  this.entryPointName = options.entryPointName || 'efc';
54
50
  this.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
55
- } // NOTE: this logic may be needed for i18n splited file name with contenthash cases
51
+ }
52
+
53
+ // NOTE: this logic may be needed for i18n splited file name with contenthash cases
56
54
  // getI18nManifest(compilation) {
57
55
  // const i18nManifestFile =
58
56
  // compilation.assets[this.options.i18nManifestFileName];
@@ -63,13 +61,12 @@ class EFCTemplatePlugin {
63
61
  // return {};
64
62
  // }
65
63
 
66
-
67
64
  getI18nAssetsStr(entryPoint, compilation) {
68
65
  // NOTE: we have used lang variable inside
69
66
  if (!chunkSplitEnable) {
70
67
  let i18nAsstes = {};
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
-
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
73
70
  i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
74
71
  const fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
75
72
  const splittedFileName = fileName.split('.');
@@ -78,28 +75,27 @@ class EFCTemplatePlugin {
78
75
  }, {});
79
76
  return `[${JSON.stringify(i18nAsstes)}[lang]]`;
80
77
  }
81
-
82
78
  const initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
83
79
  return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
84
80
  }
85
-
86
81
  templateReplacer(entryPoint, compilation) {
87
- const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
82
+ const cssDirTemplate = '@dir@';
83
+ // const i18nManifest = this.getI18nManifest(compilation);
88
84
 
89
85
  const initialFiles = entryPoint.getFiles();
90
86
  const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
91
87
  const initialJsFiles = filteredInitialFiles.filter(file => /\.js$/.test(file));
92
88
  let initialCssFiles = filteredInitialFiles.filter(file => /\.css$/.test(file));
93
-
94
89
  if (enableRTLSplit) {
95
90
  initialCssFiles = initialCssFiles.map(filePath => (0, _replaceCssDirTemplate.replaceCssDirTemplate)(filePath, cssDirTemplate));
96
- } // const i18nAssets = getShortI18nAssets(
91
+ }
92
+
93
+ // const i18nAssets = getShortI18nAssets(
97
94
  // entryPoint.chunks,
98
95
  // i18nManifest,
99
96
  // '' // i18nJsPath
100
97
  // );
101
98
 
102
-
103
99
  const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, '' // i18nJsPath
104
100
  );
105
101
  const templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
@@ -116,34 +112,27 @@ class EFCTemplatePlugin {
116
112
  return [];
117
113
  }`).replace('((\'@dir@\'))', '\'@dir@\'').replace('((\'publicPath\'))', this.publicPath).replace('((\'@locale@\'))', '\'@locale@\'');
118
114
  }
119
-
120
115
  apply(compiler) {
121
116
  if (!createSDkFile) {
122
117
  return;
123
118
  }
124
-
125
119
  compiler.hooks.emit.tap('EFCTemplatePlugin', compilation => {
126
120
  const {
127
121
  entryPointName,
128
122
  outputFile
129
123
  } = this;
130
124
  const entryPoint = compilation.entrypoints.get(entryPointName);
131
-
132
125
  if (!entryPoint) {
133
126
  return;
134
127
  }
135
-
136
128
  if (!(0, _fs.existsSync)(this.templateFilePath)) {
137
129
  console.error(`EFC Template file not exists ${this.templateFilePath}`);
138
130
  return;
139
131
  }
140
-
141
132
  const source = new _webpackSources.RawSource(this.templateReplacer(entryPoint, compilation));
142
133
  compilation.assets[outputFile] = source;
143
134
  (0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
144
135
  });
145
136
  }
146
-
147
137
  }
148
-
149
138
  exports.default = EFCTemplatePlugin;
@@ -3,13 +3,11 @@
3
3
  const {
4
4
  Template
5
5
  } = require('webpack');
6
-
7
6
  const plugInName = 'EFCResourceCleanup';
8
7
  module.exports = class EfcResouceCleanupPlugin {
9
8
  constructor(options) {
10
9
  this.options = options;
11
10
  }
12
-
13
11
  apply(compiler) {
14
12
  compiler.hooks.thisCompilation.tap(plugInName, ({
15
13
  mainTemplate
@@ -39,5 +37,4 @@ module.exports = class EfcResouceCleanupPlugin {
39
37
  });
40
38
  });
41
39
  }
42
-
43
40
  };
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.EventsHandlingPlugin = void 0;
7
-
8
7
  /* eslint-disable no-use-before-define */
8
+
9
9
  class EventsHandlingPlugin {
10
10
  constructor(options) {}
11
-
12
11
  apply(compiler) {
13
12
  // NOTE: we not using this, Reason currently this option is only need for EFC,
14
13
  // So it do not needed.
14
+
15
15
  compiler.hooks.thisCompilation.tap({
16
16
  name: 'CustomAttributePlugin',
17
17
  stage: 1,
@@ -28,7 +28,5 @@ class EventsHandlingPlugin {
28
28
  }
29
29
  });
30
30
  }
31
-
32
31
  }
33
-
34
32
  exports.EventsHandlingPlugin = EventsHandlingPlugin;
@@ -4,34 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
9
-
10
8
  var _utils = require("../utils");
11
-
12
9
  var _urlConcat = require("../utils/urlConcat");
13
-
14
10
  var _path = _interopRequireDefault(require("path"));
15
-
16
11
  var _webpackSources = require("webpack-sources");
17
-
18
12
  var _hashUtils = require("./I18nSplitPlugin/utils/hashUtils");
19
-
20
13
  var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
15
  let i18nObj = null;
25
16
  const options = (0, _utils.getOptions)();
26
-
27
17
  function newAssign(target, data) {
28
18
  return Object.assign({}, target, data);
29
19
  }
30
-
31
20
  const {
32
21
  i18n
33
22
  } = options;
34
-
35
23
  class I18NInjectIntoIndexPlugin {
36
24
  constructor(options) {
37
25
  this.isDevelopment = options.isDevelopment;
@@ -41,38 +29,33 @@ class I18NInjectIntoIndexPlugin {
41
29
  this.i18nManifestFileName = options.i18nManifestFileName;
42
30
  this.entryPointName = options.mainChunkName;
43
31
  }
44
-
45
32
  getI18nFileUrlPath(chunk, compilation) {
46
33
  const urlpath = (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, this.templateLabel);
47
34
  return (0, _urlConcat.urlConcat)(this.publicPath, urlpath);
48
35
  }
49
-
50
36
  getI18nManifest(compilation) {
51
37
  const i18nManifestFile = compilation.assets[this.i18nManifestFileName];
52
-
53
38
  if (!i18nManifestFile) {
54
39
  return {};
55
40
  }
56
-
57
41
  const manifest = JSON.parse(i18nManifestFile.source());
58
42
  return manifest;
59
43
  }
60
-
61
44
  injectI18nURLsToHTML(compilation) {
62
45
  _htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tapAsync('I18NInjectIntoIndexPlugin', (data, cb) => {
63
46
  const {
64
47
  assets
65
- } = data; // Manipulate the content
48
+ } = data;
49
+ // Manipulate the content
66
50
  // const i18nManifest = this.getI18nManifest(compilation);
67
51
  // const entryPoint = compilation.entrypoints.get(this.entryPointName);
68
-
69
52
  const i18nScriptURLs = [];
70
- i18nScriptURLs.push("desk-i18n-manifest.js");
71
- i18nScriptURLs.push("master.i18n.js");
72
- i18nScriptURLs.push("masterchunk.i18n.js"); // .map(url => getI18nScriptTagObj(url));
53
+ i18nScriptURLs.push("i18n-chunk/desk-i18n-manifest.js");
54
+ i18nScriptURLs.push(`i18n-chunk/${this.templateLabel}/master.i18n.js`);
55
+
56
+ // .map(url => getI18nScriptTagObj(url));
73
57
  // .join('');
74
58
  // Tell webpack to move on
75
-
76
59
  cb(null, newAssign(data, {
77
60
  assets: newAssign(assets, {
78
61
  js: i18nScriptURLs.concat(assets.js)
@@ -80,7 +63,6 @@ class I18NInjectIntoIndexPlugin {
80
63
  }));
81
64
  });
82
65
  }
83
-
84
66
  withI18nSpitHandling(compiler) {
85
67
  compiler.hooks.make.tap('I18NInjectIntoIndexPlugin', compilation => {
86
68
  // let cdns = Object.keys(this.publicPaths);
@@ -88,19 +70,17 @@ class I18NInjectIntoIndexPlugin {
88
70
  this.injectI18nURLsToHTML(compilation);
89
71
  return;
90
72
  }
91
-
92
73
  _htmlWebpackPlugin.default.getHooks(compilation).beforeEmit.tapAsync('I18NInjectIntoIndexPlugin', (data, cb) => {
93
74
  // Manipulate the content
94
75
  const i18nManifest = this.getI18nManifest(compilation);
95
76
  const entryPoint = compilation.entrypoints.get(this.entryPointName);
96
77
  const i18nAssets = (0, _hashUtils.getShortI18nAssets)(entryPoint.chunks, i18nManifest, this.publicPath);
97
- data.html = data.html.replace(new RegExp('<!--I18nInfoToServer(.*?)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nAssets))); // Tell webpack to move on
98
-
78
+ data.html = data.html.replace(new RegExp('<!--I18nInfoToServer(.*?)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nAssets)));
79
+ // Tell webpack to move on
99
80
  cb(null, data);
100
81
  });
101
82
  });
102
83
  }
103
-
104
84
  apply(compiler) {
105
85
  if (i18n.chunkSplitEnable) {
106
86
  this.withI18nSpitHandling(compiler);
@@ -108,13 +88,12 @@ class I18NInjectIntoIndexPlugin {
108
88
  this.withoutI18nSpitHandling(compiler);
109
89
  }
110
90
  }
111
-
112
91
  withoutI18nSpitHandling(compiler) {
113
92
  compiler.hooks.emit.tap('I18NInjectIntoIndexPlugin', compilation => {
114
93
  // let cdns = Object.keys(this.publicPaths);
115
94
  if (i18nObj === null) {
116
- const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
117
-
95
+ const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
96
+ //hook for i18n url contains i18n/ may cause problem
118
97
  i18nObj = i18nFiles.reduce((res, next) => {
119
98
  const fileName = next.replace(`i18n${_path.default.sep}`, '');
120
99
  const splittedFileName = fileName.split('.');
@@ -123,21 +102,16 @@ class I18NInjectIntoIndexPlugin {
123
102
  } else {
124
103
  res[splittedFileName[0]] = fileName;
125
104
  } */
126
-
127
105
  res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
128
106
  return res;
129
107
  }, {});
130
108
  }
131
-
132
109
  const [indexFile] = Object.keys(compilation.assets).filter(filename => /\.html$/g.test(filename));
133
-
134
110
  if (indexFile) {
135
111
  const source = compilation.assets[indexFile].source();
136
112
  compilation.assets[indexFile] = new _webpackSources.RawSource(source.replace(new RegExp('<!--I18nInfoToServer(.*)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nObj))));
137
113
  }
138
114
  });
139
115
  }
140
-
141
116
  }
142
-
143
117
  exports.default = I18NInjectIntoIndexPlugin;