@zohodesk/client_build_tool 0.0.11-exp.16.0 → 0.0.11-exp.17.0

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 (220) hide show
  1. package/README.md +102 -0
  2. package/README_backup.md +102 -0
  3. package/lib/allCommandsConfigs.js +7 -2
  4. package/lib/commands/build/commandExecutor.js +5 -1
  5. package/lib/commands/build/config.js +3 -2
  6. package/lib/commands/build/optionsProcessor.js +5 -2
  7. package/lib/commands/build/preProcessor.js +2 -0
  8. package/lib/commands/buildEs/commandExecutor.js +5 -0
  9. package/lib/commands/buildEs/config.js +3 -2
  10. package/lib/commands/buildEs/preProcessor.js +2 -0
  11. package/lib/commands/buildLib/commandExecutor.js +5 -0
  12. package/lib/commands/buildLib/config.js +3 -2
  13. package/lib/commands/buildLib/preProcessor.js +2 -0
  14. package/lib/commands/mockserver/commandExecutor.js +9 -2
  15. package/lib/commands/mockserver/config.js +3 -2
  16. package/lib/commands/pre_process/commandExecutor.js +2 -0
  17. package/lib/commands/pre_process/config.js +3 -2
  18. package/lib/commands/start/commandExecutor.js +2 -0
  19. package/lib/commands/start/config.js +3 -2
  20. package/lib/commands/start/optionsProcessor.js +4 -2
  21. package/lib/commands/start/preProcessor.js +2 -0
  22. package/lib/commands/template/commandExecutor.js +7 -0
  23. package/lib/commands/template/config.js +3 -2
  24. package/lib/commands/version/commandExecutor.js +3 -0
  25. package/lib/commands/version/config.js +3 -2
  26. package/lib/commandsRouter.js +21 -5
  27. package/lib/index.js +2 -0
  28. package/lib/logger.js +5 -0
  29. package/lib/schemas/applyValuesToSchema/index.js +8 -0
  30. package/lib/schemas/applyValuesToSchema/isObject.js +1 -0
  31. package/lib/schemas/applyValuesToSchema/isValid.js +2 -0
  32. package/lib/schemas/cliArgsToObject.js +6 -2
  33. package/lib/schemas/defaultConfigValues.js +17 -4
  34. package/lib/schemas/defaultConfigValuesOnly.js +33 -4
  35. package/lib/schemas/deprecatedOptionsHandler.js +16 -7
  36. package/lib/schemas/getNpmVersion.js +5 -0
  37. package/lib/schemas/giveDefaultValue.js +3 -0
  38. package/lib/schemas/npmConfigToObject.js +5 -2
  39. package/lib/schemas/readOptions.js +30 -10
  40. package/lib/schemas/readOptionsForConfigFile.js +12 -2
  41. package/lib/shared/babel/addDefaultPlugins.js +2 -0
  42. package/lib/shared/babel/babelWebConfig.js +10 -1
  43. package/lib/shared/babel/babel_plugins/removeAttributesPlugin.js +4 -0
  44. package/lib/shared/babel/getBabelPlugin.js +7 -2
  45. package/lib/shared/babel/runBabelForJSFile.js +4 -1
  46. package/lib/shared/babel/runBabelForTsFile.js +5 -1
  47. package/lib/shared/bundler/webpack/common/decidePublicPath.js +5 -0
  48. package/lib/shared/bundler/webpack/common/libAlias.js +3 -3
  49. package/lib/shared/bundler/webpack/common/modeUtils.js +5 -0
  50. package/lib/shared/bundler/webpack/common/nameTemplates.js +18 -11
  51. package/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +3 -2
  52. package/lib/shared/bundler/webpack/configCustomLoaders.js +1 -0
  53. package/lib/shared/bundler/webpack/cssLoaders.js +2 -0
  54. package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +20 -1
  55. package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +25 -20
  56. package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +9 -4
  57. package/lib/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +23 -3
  58. package/lib/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +19 -8
  59. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js +61 -37
  60. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +33 -15
  61. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +108 -60
  62. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +26 -20
  63. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +26 -5
  64. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +16 -13
  65. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +53 -19
  66. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +17 -2
  67. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +13 -0
  68. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +21 -11
  69. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +4 -0
  70. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +14 -4
  71. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +13 -3
  72. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +12 -3
  73. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +7 -2
  74. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +2 -0
  75. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +3 -2
  76. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +4 -2
  77. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +13 -8
  78. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +14 -2
  79. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +1 -0
  80. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +3 -1
  81. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +4 -0
  82. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +25 -5
  83. package/lib/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +10 -3
  84. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +6 -1
  85. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +6 -1
  86. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +6 -0
  87. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +1 -0
  88. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +7 -0
  89. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +1 -0
  90. package/lib/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +17 -13
  91. package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +15 -6
  92. package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +13 -4
  93. package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +6 -4
  94. package/lib/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +10 -0
  95. package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +3 -0
  96. package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +20 -4
  97. package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +12 -10
  98. package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +3 -2
  99. package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +20 -7
  100. package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +1 -0
  101. package/lib/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +10 -7
  102. package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +6 -1
  103. package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +16 -1
  104. package/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +11 -4
  105. package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +10 -3
  106. package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +62 -27
  107. package/lib/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +15 -3
  108. package/lib/shared/bundler/webpack/custom_plugins/emitAsset.js +1 -0
  109. package/lib/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +12 -2
  110. package/lib/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +7 -2
  111. package/lib/shared/bundler/webpack/defaultVendorPatternList.js +6 -2
  112. package/lib/shared/bundler/webpack/devtoolConfig.js +1 -0
  113. package/lib/shared/bundler/webpack/entryConfig.js +4 -0
  114. package/lib/shared/bundler/webpack/externals.js +1 -0
  115. package/lib/shared/bundler/webpack/getCSSLoaders.js +6 -1
  116. package/lib/shared/bundler/webpack/getFilenameFromModule.js +5 -1
  117. package/lib/shared/bundler/webpack/jsLoaders.js +10 -6
  118. package/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +2 -0
  119. package/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +3 -2
  120. package/lib/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +12 -3
  121. package/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +1 -0
  122. package/lib/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +10 -2
  123. package/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +2 -0
  124. package/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +12 -0
  125. package/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +15 -1
  126. package/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +4 -1
  127. package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +16 -8
  128. package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +29 -22
  129. package/lib/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +2 -2
  130. package/lib/shared/bundler/webpack/loaders/workerLoader.js +19 -8
  131. package/lib/shared/bundler/webpack/optimizationConfig.js +13 -5
  132. package/lib/shared/bundler/webpack/outputConfig.js +9 -1
  133. package/lib/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +9 -5
  134. package/lib/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +5 -0
  135. package/lib/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +9 -4
  136. package/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +8 -3
  137. package/lib/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +16 -1
  138. package/lib/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +4 -0
  139. package/lib/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +16 -0
  140. package/lib/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +5 -0
  141. package/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +5 -0
  142. package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +8 -2
  143. package/lib/shared/bundler/webpack/pluginConfigs/configI18nIndexingPlugin.js +9 -5
  144. package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericHtmlInjector.js +25 -19
  145. package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +26 -12
  146. package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +9 -3
  147. package/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +2 -0
  148. package/lib/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +7 -0
  149. package/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +7 -3
  150. package/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +5 -1
  151. package/lib/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +4 -1
  152. package/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +4 -0
  153. package/lib/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +8 -3
  154. package/lib/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +6 -1
  155. package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +8 -3
  156. package/lib/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +4 -0
  157. package/lib/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +8 -1
  158. package/lib/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +6 -1
  159. package/lib/shared/bundler/webpack/plugins.js +24 -1
  160. package/lib/shared/bundler/webpack/resolvers.js +17 -3
  161. package/lib/shared/bundler/webpack/splitChunksConfig.js +15 -2
  162. package/lib/shared/bundler/webpack/statsConfig.js +5 -2
  163. package/lib/shared/bundler/webpack/tsLoaders.js +4 -2
  164. package/lib/shared/bundler/webpack/utils/index.js +12 -1
  165. package/lib/shared/bundler/webpack/utils/object-manipulation.js +16 -2
  166. package/lib/shared/bundler/webpack/utils/updateArrayWithDefault.js +7 -0
  167. package/lib/shared/bundler/webpack/webpackBuild.js +8 -1
  168. package/lib/shared/bundler/webpack/webpackConfig.js +17 -0
  169. package/lib/shared/commands-utils/doBasicRequirementCheck.js +3 -0
  170. package/lib/shared/commands-utils/getCliPath.js +9 -5
  171. package/lib/shared/commands-utils/index.js +3 -0
  172. package/lib/shared/commands-utils/log.js +2 -0
  173. package/lib/shared/commands-utils/readArgsFormCommandLine.js +1 -0
  174. package/lib/shared/commands-utils/readOptionFormCommandLine.js +1 -0
  175. package/lib/shared/commands-utils/spawnSyncIO.js +13 -5
  176. package/lib/shared/constants.js +29 -9
  177. package/lib/shared/fileUtils/copyFile.js +8 -1
  178. package/lib/shared/fileUtils/directoryIterator.js +4 -0
  179. package/lib/shared/fileUtils/watchRun.js +24 -3
  180. package/lib/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +6 -1
  181. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +3 -2
  182. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +13 -6
  183. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +26 -6
  184. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +9 -6
  185. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +3 -0
  186. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +7 -2
  187. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +2 -0
  188. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +9 -4
  189. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +10 -0
  190. package/lib/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +29 -16
  191. package/lib/shared/postcss/custom_postcss_plugins/SelectorReplace.js +17 -0
  192. package/lib/shared/postcss/custom_postcss_plugins/ValueReplacer.js +9 -4
  193. package/lib/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +63 -27
  194. package/lib/shared/postcss/filterPluginsAllowedForSpecficFile.js +13 -5
  195. package/lib/shared/postcss/getAllowedPostCssPlugins.js +3 -0
  196. package/lib/shared/postcss/getSpecificPostCssPlugin.js +17 -7
  197. package/lib/shared/postcss/runPostCssForCssFile.js +9 -1
  198. package/lib/shared/pre_process/runPreProcess.js +11 -0
  199. package/lib/shared/server/configWebpackDevMiddleware.js +8 -1
  200. package/lib/shared/server/corsHandling.js +6 -2
  201. package/lib/shared/server/getIp.js +7 -1
  202. package/lib/shared/server/getServerURL.js +6 -0
  203. package/lib/shared/server/httpsOptions.js +11 -0
  204. package/lib/shared/server/initExpressApp.js +4 -1
  205. package/lib/shared/server/initialHTMLHandling.js +16 -7
  206. package/lib/shared/server/mockApiHandler.js +16 -8
  207. package/lib/shared/server/mockServer.js +7 -0
  208. package/lib/shared/server/serveContextFiles.js +5 -1
  209. package/lib/shared/server/serverBywebpackDevMiddleware.js +9 -4
  210. package/lib/shared/server/startHttpServer.js +3 -0
  211. package/lib/shared/server/startHttpsServer.js +9 -1
  212. package/lib/shared/server/unwanted/addHttp2Server.js +7 -2
  213. package/lib/shared/server/unwanted/configWebpackDevMiddleware.js +8 -1
  214. package/lib/shared/server/unwanted/mockApiSupport.js +2 -0
  215. package/lib/shared/server/unwanted/websocketMockSetup.js +7 -1
  216. package/lib/shared/server/urlConcat.js +8 -3
  217. package/lib/shared/utils/requireLocalOrGlobal.js +25 -10
  218. package/lib/shared/utils/versionPrint.js +6 -1
  219. package/npm-shrinkwrap.json +2 -2
  220. package/package.json +1 -1
@@ -4,14 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.EFCTemplatePlugin = void 0;
7
+
7
8
  var _fs = require("fs");
9
+
8
10
  var _logger = require("../../../../logger");
11
+
9
12
  var _LocaleChunkAssetsStore = require("./I18nSplitPlugin/LocaleChunkAssetsStore");
13
+
10
14
  var _constants = require("../../../constants");
15
+
11
16
  var _getInitialAssetsFuncTemplate = require("./getInitialAssetsFuncTemplate");
17
+
12
18
  const INITIAL_ASSETS_TEMPLATE = '// <--getInitialAssets-->';
13
19
  const PUBLIC_PATH_TEMPLATE = '"<--publicPath-->"';
14
20
  const pluginName = 'EFCTemplatePlugin';
21
+
15
22
  class EFCTemplatePlugin {
16
23
  constructor(options = {}) {
17
24
  const {
@@ -25,18 +32,15 @@ class EFCTemplatePlugin {
25
32
  this.options = options;
26
33
  this.templateFilePath = (0, _constants.joinWithAppPath)(templateFilePath);
27
34
  this.i18nFileNameTemplate = i18nFileNameTemplate;
28
- this.publicPath = publicPath;
29
-
30
- // NOTE: this logic may be needed for i18n splitted file name with contenthash cases
35
+ this.publicPath = publicPath; // NOTE: this logic may be needed for i18n splitted file name with contenthash cases
31
36
  // this.i18nManifestFileName = options.i18nManifestFileName;
32
37
  // IMPORTANT: here we merging options from package.json and options via constructor
33
38
  // So when debugging consider this as well
34
39
  // this.options = Object.assign({}, efcOptions, options);
40
+
35
41
  this.entryPointName = entryPointName || 'efc';
36
42
  this.outputFile = outputFile.replace('[version]', version);
37
- }
38
-
39
- // NOTE: this logic may be needed for i18n splitted file name with contenthash cases
43
+ } // NOTE: this logic may be needed for i18n splitted file name with contenthash cases
40
44
  // getI18nManifest(compilation) {
41
45
  // const i18nManifestFile =
42
46
  // compilation.assets[this.options.i18nManifestFileName];
@@ -48,11 +52,12 @@ class EFCTemplatePlugin {
48
52
  // }
49
53
  // eslint-disable-next-line class-methods-use-this
50
54
 
55
+
51
56
  templateReplacer(entryPoint, compilation) {
52
57
  const {
53
58
  enableRTLSplit
54
- } = this.options;
55
- // const i18nManifest = this.getI18nManifest(compilation);
59
+ } = this.options; // const i18nManifest = this.getI18nManifest(compilation);
60
+
56
61
  const initialAssetsFuncTemplate = (0, _getInitialAssetsFuncTemplate.getInitialAssetsFuncTemplate)({
57
62
  entryPoint,
58
63
  compilation,
@@ -65,6 +70,7 @@ class EFCTemplatePlugin {
65
70
  const templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
66
71
  return templateStr.replace(INITIAL_ASSETS_TEMPLATE, initialAssetsFuncTemplate).replace(PUBLIC_PATH_TEMPLATE, this.publicPath);
67
72
  }
73
+
68
74
  apply(compiler) {
69
75
  const {
70
76
  RawSource
@@ -83,13 +89,16 @@ class EFCTemplatePlugin {
83
89
  outputFile
84
90
  } = this;
85
91
  const entryPoint = compilation.entrypoints.get(entryPointName);
92
+
86
93
  if (!entryPoint) {
87
94
  return;
88
95
  }
96
+
89
97
  if (!(0, _fs.existsSync)(this.templateFilePath)) {
90
98
  (0, _logger.errorLogger)(`EFC Template file not exists ${this.templateFilePath}`);
91
99
  return;
92
100
  }
101
+
93
102
  const source = new RawSource(this.templateReplacer(entryPoint, compilation));
94
103
  compilation.emitAsset(outputFile, source);
95
104
  (0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
@@ -97,5 +106,7 @@ class EFCTemplatePlugin {
97
106
  });
98
107
  });
99
108
  }
109
+
100
110
  }
111
+
101
112
  exports.EFCTemplatePlugin = EFCTemplatePlugin;
@@ -4,20 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.I18nGroupRuntimeModule = void 0;
7
+
7
8
  var _webpack = require("webpack");
9
+
8
10
  class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
9
11
  constructor(options) {
10
12
  super('i18n-group-loader');
11
13
  this.options = options;
12
14
  }
15
+
13
16
  generate() {
14
17
  const {
15
18
  customGroups,
16
19
  localeVarName,
17
20
  jsonpFunc
18
- } = this.options;
21
+ } = this.options; // Build chunk-to-group mapping from config
19
22
 
20
- // Build chunk-to-group mapping from config
21
23
  const chunkToGroup = {};
22
24
  Object.entries(customGroups || {}).forEach(([groupName, config]) => {
23
25
  (config.chunks || []).forEach(chunkName => {
@@ -27,53 +29,73 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
27
29
  return `
28
30
  // I18n Group Loading Runtime
29
31
  (function() {
32
+ console.log('[I18n Runtime] Initializing i18n group loader with groups:', ${JSON.stringify(chunkToGroup)});
30
33
  var loadedGroups = {};
31
34
  var chunkToGroup = ${JSON.stringify(chunkToGroup)};
32
35
 
36
+ // Function to load i18n group
37
+ function loadI18nGroup(groupName) {
38
+ if (loadedGroups[groupName]) {
39
+ return Promise.resolve();
40
+ }
41
+
42
+ var locale = ${localeVarName} || 'en_US';
43
+ var groupConfig = ${JSON.stringify(customGroups)};
44
+ var config = groupConfig[groupName];
45
+
46
+ if (!config) {
47
+ return Promise.resolve();
48
+ }
49
+
50
+ return new Promise(function(resolve, reject) {
51
+ var i18nUrl = config.filenameTemplate
52
+ .replace('[locale]', locale)
53
+ .replace('i18n-chunk/', __webpack_require__.p + 'i18n-chunk/');
54
+
55
+ console.log('[I18n Runtime] Loading i18n group:', groupName, 'from:', i18nUrl);
56
+
57
+ var script = document.createElement('script');
58
+ script.src = i18nUrl;
59
+ script.async = true;
60
+
61
+ script.onload = function() {
62
+ loadedGroups[groupName] = true;
63
+ console.log('[I18n Runtime] Successfully loaded i18n group:', groupName);
64
+ resolve();
65
+ };
66
+
67
+ script.onerror = function() {
68
+ console.error('[I18n Runtime] Failed to load i18n group:', groupName);
69
+ reject(new Error('Failed to load i18n group: ' + groupName));
70
+ };
71
+
72
+ document.head.appendChild(script);
73
+ });
74
+ }
75
+
33
76
  // Store original webpack chunk loading function
34
77
  var originalEnsureChunk = __webpack_require__.e;
35
78
 
36
- // Override webpack's chunk loading
37
- __webpack_require__.e = function(chunkId) {
38
- var promise = originalEnsureChunk.apply(this, arguments);
79
+ // Override webpack's chunk loading if it exists
80
+ if (originalEnsureChunk) {
81
+ __webpack_require__.e = function(chunkId) {
82
+ var promise = originalEnsureChunk.apply(this, arguments);
39
83
 
40
84
  // Check if this chunk needs an i18n group
41
85
  var groupName = chunkToGroup[chunkId];
42
86
  if (groupName && !loadedGroups[groupName]) {
43
- // Load the i18n group
44
- var locale = ${localeVarName} || 'en_US';
45
- var groupConfig = ${JSON.stringify(customGroups)};
46
- var config = groupConfig[groupName];
47
-
48
- if (config) {
49
- var i18nUrl = config.filenameTemplate
50
- .replace('[locale]', locale)
51
- .replace('i18n-chunk/', __webpack_require__.p + 'i18n-chunk/');
52
-
53
- // Create script tag to load i18n chunk
54
- var script = document.createElement('script');
55
- script.src = i18nUrl;
56
- script.async = true;
57
-
58
- // Mark as loaded when script loads
59
- script.onload = function() {
60
- loadedGroups[groupName] = true;
61
- };
62
-
63
- document.head.appendChild(script);
64
-
65
- // If prefetch is enabled, prefetch other locales
66
- if (config.prefetch && !config.preload) {
67
- var link = document.createElement('link');
68
- link.rel = 'prefetch';
69
- link.href = i18nUrl;
70
- document.head.appendChild(link);
71
- }
72
- }
87
+ console.log('[I18n Runtime] Chunk', chunkId, 'requires i18n group:', groupName);
88
+ // Load the i18n group before the chunk
89
+ var i18nPromise = loadI18nGroup(groupName);
90
+ // Chain the promises so i18n loads first
91
+ promise = Promise.all([promise, i18nPromise]).then(function(results) {
92
+ return results[0]; // Return the original chunk promise result
93
+ });
73
94
  }
74
95
 
75
- return promise;
76
- };
96
+ return promise;
97
+ };
98
+ }
77
99
 
78
100
  // Also check for webpackI18nGroup comments in dynamic imports
79
101
  if (typeof __webpack_require__.l !== 'undefined') {
@@ -116,5 +138,7 @@ class I18nGroupRuntimeModule extends _webpack.RuntimeModule {
116
138
  })();
117
139
  `;
118
140
  }
141
+
119
142
  }
143
+
120
144
  exports.I18nGroupRuntimeModule = I18nGroupRuntimeModule;
@@ -1,15 +1,28 @@
1
1
  "use strict";
2
2
 
3
3
  const HtmlWebpackPlugin = require('html-webpack-plugin');
4
+
4
5
  const path = require('path');
6
+
5
7
  const pluginName = 'I18nNumericIndexHtmlInjectorPlugin';
8
+
6
9
  class I18nNumericIndexHtmlInjectorPlugin {
7
10
  constructor(options) {
8
- this.options = options;
11
+ this.options = { ...options,
12
+ injectI18nUrlInIndex: options.injectI18nUrlInIndex !== undefined ? options.injectI18nUrlInIndex : true // Default to true
13
+
14
+ };
9
15
  }
16
+
10
17
  apply(compiler) {
11
18
  compiler.hooks.thisCompilation.tap(pluginName, compilation => {
12
19
  HtmlWebpackPlugin.getHooks(compilation).beforeAssetTagGeneration.tapAsync(pluginName, (hookData, cb) => {
20
+ // Skip HTML injection if injectI18nUrlInIndex is false
21
+ if (!this.options.injectI18nUrlInIndex) {
22
+ console.log('[I18nNumericIndexHtmlInjectorPlugin] Skipping HTML injection (injectI18nUrlInIndex is false)');
23
+ return cb(null, hookData);
24
+ }
25
+
13
26
  const {
14
27
  assets
15
28
  } = hookData;
@@ -22,60 +35,65 @@ class I18nNumericIndexHtmlInjectorPlugin {
22
35
  singleFile,
23
36
  i18nAssetsPublicPathPrefix = ''
24
37
  } = this.options;
25
- const newI18nAssetUrlsToAdd = [];
38
+ const newI18nAssetUrlsToAdd = []; // Construct full paths using outputFolder
26
39
 
27
- // Construct full paths using outputFolder
28
40
  const constructFullPath = (template, isSingleFile = false) => {
29
- if (!template) return null;
30
-
31
- // Replace locale placeholder
32
- let filePath = template.replace(/\[locale\]/g, htmlTemplateLabel);
41
+ if (!template) return null; // Replace locale placeholder
33
42
 
34
- // Remove [contenthash] placeholder for HTML injection
43
+ let filePath = template.replace(/\[locale\]/g, htmlTemplateLabel); // Remove [contenthash] placeholder for HTML injection
35
44
  // The actual hash will be determined at build time
36
- filePath = filePath.replace(/\.\[contenthash\]/g, '');
37
45
 
38
- // If template already contains outputFolder or starts with a path separator, use as-is
46
+ filePath = filePath.replace(/\.\[contenthash\]/g, ''); // If template already contains outputFolder or starts with a path separator, use as-is
47
+
39
48
  if (filePath.includes(outputFolder) || filePath.startsWith('/')) {
40
49
  return filePath.replace(/\\/g, '/');
41
- }
42
-
43
- // For single-file mode with a simple template like '[locale].js',
50
+ } // For single-file mode with a simple template like '[locale].js',
44
51
  // put it directly in outputFolder without subdirectories
52
+
53
+
45
54
  if (isSingleFile && !filePath.includes('/')) {
46
55
  return path.join(outputFolder || 'i18n-chunk', filePath).replace(/\\/g, '/');
47
- }
56
+ } // For other cases, preserve subdirectories
57
+
48
58
 
49
- // For other cases, preserve subdirectories
50
59
  return path.join(outputFolder || 'i18n-chunk', filePath).replace(/\\/g, '/');
51
60
  };
61
+
52
62
  if (singleFile) {
53
63
  // In single file mode, use singleFileTemplate
54
64
  const singleTemplate = singleFileTemplate || '[locale].js';
55
65
  const combinedFilename = constructFullPath(singleTemplate, true);
66
+
56
67
  if (combinedFilename) {
57
68
  newI18nAssetUrlsToAdd.push(combinedFilename);
58
69
  }
59
70
  } else {
60
71
  // Add both numeric and dynamic files
61
72
  const numericFilename = constructFullPath(numericFilenameTemplate);
73
+
62
74
  if (numericFilename) {
63
75
  newI18nAssetUrlsToAdd.push(numericFilename);
64
76
  }
77
+
65
78
  const dynamicFilename = constructFullPath(dynamicFilenameTemplate);
79
+
66
80
  if (dynamicFilename) {
67
81
  newI18nAssetUrlsToAdd.push(dynamicFilename);
68
82
  }
69
83
  }
84
+
70
85
  if (newI18nAssetUrlsToAdd.length > 0) {
71
86
  // Add i18n assets to the beginning of JS assets for early loading
72
87
  assets.js = [...newI18nAssetUrlsToAdd, ...assets.js];
73
88
  }
89
+
74
90
  cb(null, hookData);
75
91
  });
76
92
  });
77
93
  }
94
+
78
95
  }
96
+
79
97
  module.exports = {
80
98
  I18nNumericIndexHtmlInjectorPlugin
81
99
  };