@zohodesk/client_build_tool 0.0.11-exp.15.4 → 0.0.11-exp.16.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 (224) hide show
  1. package/README.md +102 -0
  2. package/README_backup.md +100 -0
  3. package/docs/DYNAMIC_TEMPLATE_EXAMPLE.md +129 -0
  4. package/docs/I18N_SINGLE_FILE_MODE.md +126 -0
  5. package/example-single-file-config.js +59 -0
  6. package/lib/allCommandsConfigs.js +2 -7
  7. package/lib/commands/build/commandExecutor.js +1 -5
  8. package/lib/commands/build/config.js +2 -3
  9. package/lib/commands/build/optionsProcessor.js +2 -5
  10. package/lib/commands/build/preProcessor.js +0 -2
  11. package/lib/commands/buildEs/commandExecutor.js +0 -5
  12. package/lib/commands/buildEs/config.js +2 -3
  13. package/lib/commands/buildEs/preProcessor.js +0 -2
  14. package/lib/commands/buildLib/commandExecutor.js +0 -5
  15. package/lib/commands/buildLib/config.js +2 -3
  16. package/lib/commands/buildLib/preProcessor.js +0 -2
  17. package/lib/commands/mockserver/commandExecutor.js +2 -9
  18. package/lib/commands/mockserver/config.js +2 -3
  19. package/lib/commands/pre_process/commandExecutor.js +0 -2
  20. package/lib/commands/pre_process/config.js +2 -3
  21. package/lib/commands/start/commandExecutor.js +0 -2
  22. package/lib/commands/start/config.js +2 -3
  23. package/lib/commands/start/optionsProcessor.js +2 -4
  24. package/lib/commands/start/preProcessor.js +0 -2
  25. package/lib/commands/template/commandExecutor.js +0 -7
  26. package/lib/commands/template/config.js +2 -3
  27. package/lib/commands/version/commandExecutor.js +0 -3
  28. package/lib/commands/version/config.js +2 -3
  29. package/lib/commandsRouter.js +5 -21
  30. package/lib/index.js +0 -2
  31. package/lib/logger.js +0 -5
  32. package/lib/schemas/applyValuesToSchema/index.js +0 -8
  33. package/lib/schemas/applyValuesToSchema/isObject.js +0 -1
  34. package/lib/schemas/applyValuesToSchema/isValid.js +0 -2
  35. package/lib/schemas/cliArgsToObject.js +2 -6
  36. package/lib/schemas/defaultConfigValues.js +21 -12
  37. package/lib/schemas/defaultConfigValuesOnly.js +4 -7
  38. package/lib/schemas/deprecatedOptionsHandler.js +7 -16
  39. package/lib/schemas/getNpmVersion.js +0 -5
  40. package/lib/schemas/giveDefaultValue.js +0 -3
  41. package/lib/schemas/npmConfigToObject.js +2 -5
  42. package/lib/schemas/readOptions.js +10 -30
  43. package/lib/schemas/readOptionsForConfigFile.js +2 -12
  44. package/lib/shared/babel/addDefaultPlugins.js +0 -2
  45. package/lib/shared/babel/babelWebConfig.js +1 -10
  46. package/lib/shared/babel/babel_plugins/removeAttributesPlugin.js +0 -4
  47. package/lib/shared/babel/getBabelPlugin.js +2 -7
  48. package/lib/shared/babel/runBabelForJSFile.js +1 -4
  49. package/lib/shared/babel/runBabelForTsFile.js +1 -5
  50. package/lib/shared/bundler/webpack/common/decidePublicPath.js +0 -5
  51. package/lib/shared/bundler/webpack/common/libAlias.js +3 -3
  52. package/lib/shared/bundler/webpack/common/modeUtils.js +0 -5
  53. package/lib/shared/bundler/webpack/common/nameTemplates.js +11 -18
  54. package/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +2 -3
  55. package/lib/shared/bundler/webpack/configCustomLoaders.js +0 -1
  56. package/lib/shared/bundler/webpack/cssLoaders.js +0 -2
  57. package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +1 -20
  58. package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +20 -25
  59. package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +4 -9
  60. package/lib/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +3 -23
  61. package/lib/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +8 -19
  62. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js +2 -6
  63. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +81 -0
  64. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +135 -60
  65. package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +20 -26
  66. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +5 -26
  67. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +13 -16
  68. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +19 -53
  69. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +2 -17
  70. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +0 -13
  71. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +11 -21
  72. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -4
  73. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +4 -14
  74. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +3 -13
  75. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +3 -12
  76. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +2 -7
  77. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -2
  78. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +2 -3
  79. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +2 -4
  80. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +8 -13
  81. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -14
  82. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +0 -1
  83. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +1 -3
  84. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -4
  85. package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +5 -25
  86. package/lib/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +3 -10
  87. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +1 -6
  88. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +1 -6
  89. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +0 -6
  90. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +0 -1
  91. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +0 -7
  92. package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +0 -1
  93. package/lib/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +13 -17
  94. package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +6 -15
  95. package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +4 -13
  96. package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +4 -6
  97. package/lib/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +0 -10
  98. package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +0 -3
  99. package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +4 -20
  100. package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +10 -12
  101. package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +2 -3
  102. package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +7 -20
  103. package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +0 -1
  104. package/lib/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +7 -10
  105. package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +1 -6
  106. package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +1 -16
  107. package/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +4 -11
  108. package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +3 -10
  109. package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +27 -62
  110. package/lib/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +3 -15
  111. package/lib/shared/bundler/webpack/custom_plugins/emitAsset.js +0 -1
  112. package/lib/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +2 -12
  113. package/lib/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +2 -7
  114. package/lib/shared/bundler/webpack/defaultVendorPatternList.js +2 -6
  115. package/lib/shared/bundler/webpack/devtoolConfig.js +0 -1
  116. package/lib/shared/bundler/webpack/entryConfig.js +0 -4
  117. package/lib/shared/bundler/webpack/externals.js +0 -1
  118. package/lib/shared/bundler/webpack/getCSSLoaders.js +1 -6
  119. package/lib/shared/bundler/webpack/getFilenameFromModule.js +1 -5
  120. package/lib/shared/bundler/webpack/jsLoaders.js +6 -10
  121. package/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -2
  122. package/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +2 -3
  123. package/lib/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +3 -12
  124. package/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -1
  125. package/lib/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +2 -10
  126. package/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -2
  127. package/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -12
  128. package/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +1 -15
  129. package/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +1 -4
  130. package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +8 -16
  131. package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +22 -29
  132. package/lib/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +2 -2
  133. package/lib/shared/bundler/webpack/loaders/workerLoader.js +8 -19
  134. package/lib/shared/bundler/webpack/optimizationConfig.js +5 -13
  135. package/lib/shared/bundler/webpack/outputConfig.js +1 -9
  136. package/lib/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +5 -9
  137. package/lib/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +0 -5
  138. package/lib/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +4 -9
  139. package/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +3 -8
  140. package/lib/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +1 -16
  141. package/lib/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +0 -4
  142. package/lib/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +0 -16
  143. package/lib/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +0 -5
  144. package/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -5
  145. package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +2 -8
  146. package/lib/shared/bundler/webpack/pluginConfigs/configI18nIndexingPlugin.js +5 -9
  147. package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericHtmlInjector.js +19 -25
  148. package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +92 -0
  149. package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +3 -9
  150. package/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -2
  151. package/lib/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +0 -7
  152. package/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +3 -7
  153. package/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +1 -5
  154. package/lib/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +1 -4
  155. package/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -4
  156. package/lib/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +3 -8
  157. package/lib/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +1 -6
  158. package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +3 -8
  159. package/lib/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +0 -4
  160. package/lib/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +1 -8
  161. package/lib/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +1 -6
  162. package/lib/shared/bundler/webpack/plugins.js +3 -30
  163. package/lib/shared/bundler/webpack/resolvers.js +3 -17
  164. package/lib/shared/bundler/webpack/splitChunksConfig.js +2 -15
  165. package/lib/shared/bundler/webpack/statsConfig.js +2 -5
  166. package/lib/shared/bundler/webpack/tsLoaders.js +2 -4
  167. package/lib/shared/bundler/webpack/utils/index.js +1 -12
  168. package/lib/shared/bundler/webpack/utils/object-manipulation.js +2 -16
  169. package/lib/shared/bundler/webpack/utils/updateArrayWithDefault.js +0 -7
  170. package/lib/shared/bundler/webpack/webpackBuild.js +1 -8
  171. package/lib/shared/bundler/webpack/webpackConfig.js +0 -17
  172. package/lib/shared/commands-utils/doBasicRequirementCheck.js +0 -3
  173. package/lib/shared/commands-utils/getCliPath.js +5 -9
  174. package/lib/shared/commands-utils/index.js +0 -3
  175. package/lib/shared/commands-utils/log.js +0 -2
  176. package/lib/shared/commands-utils/readArgsFormCommandLine.js +0 -1
  177. package/lib/shared/commands-utils/readOptionFormCommandLine.js +0 -1
  178. package/lib/shared/commands-utils/spawnSyncIO.js +5 -13
  179. package/lib/shared/constants.js +9 -29
  180. package/lib/shared/fileUtils/copyFile.js +1 -8
  181. package/lib/shared/fileUtils/directoryIterator.js +0 -4
  182. package/lib/shared/fileUtils/watchRun.js +3 -24
  183. package/lib/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +1 -6
  184. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +2 -3
  185. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +6 -13
  186. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +6 -26
  187. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +6 -9
  188. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +0 -3
  189. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +2 -7
  190. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +0 -2
  191. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +4 -9
  192. package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +0 -10
  193. package/lib/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +16 -29
  194. package/lib/shared/postcss/custom_postcss_plugins/SelectorReplace.js +0 -17
  195. package/lib/shared/postcss/custom_postcss_plugins/ValueReplacer.js +4 -9
  196. package/lib/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +27 -63
  197. package/lib/shared/postcss/filterPluginsAllowedForSpecficFile.js +5 -13
  198. package/lib/shared/postcss/getAllowedPostCssPlugins.js +0 -3
  199. package/lib/shared/postcss/getSpecificPostCssPlugin.js +7 -17
  200. package/lib/shared/postcss/runPostCssForCssFile.js +1 -9
  201. package/lib/shared/pre_process/runPreProcess.js +0 -11
  202. package/lib/shared/server/configWebpackDevMiddleware.js +1 -8
  203. package/lib/shared/server/corsHandling.js +2 -6
  204. package/lib/shared/server/getIp.js +1 -7
  205. package/lib/shared/server/getServerURL.js +0 -6
  206. package/lib/shared/server/httpsOptions.js +0 -11
  207. package/lib/shared/server/initExpressApp.js +1 -4
  208. package/lib/shared/server/initialHTMLHandling.js +7 -16
  209. package/lib/shared/server/mockApiHandler.js +8 -16
  210. package/lib/shared/server/mockServer.js +0 -7
  211. package/lib/shared/server/serveContextFiles.js +1 -5
  212. package/lib/shared/server/serverBywebpackDevMiddleware.js +4 -9
  213. package/lib/shared/server/startHttpServer.js +0 -3
  214. package/lib/shared/server/startHttpsServer.js +1 -9
  215. package/lib/shared/server/unwanted/addHttp2Server.js +2 -7
  216. package/lib/shared/server/unwanted/configWebpackDevMiddleware.js +1 -8
  217. package/lib/shared/server/unwanted/mockApiSupport.js +0 -2
  218. package/lib/shared/server/unwanted/websocketMockSetup.js +1 -7
  219. package/lib/shared/server/urlConcat.js +3 -8
  220. package/lib/shared/utils/requireLocalOrGlobal.js +10 -25
  221. package/lib/shared/utils/versionPrint.js +1 -6
  222. package/npm-shrinkwrap.json +2 -2
  223. package/package.json +1 -1
  224. package/packages/client_build_tool/test-i18n-config.js +22 -0
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.optionsHandler = optionsHandler;
7
-
8
7
  var _constants = require("./constants");
9
-
10
8
  var _readI18nValues = require("./readI18nValues");
11
-
12
9
  /* eslint-disable no-use-before-define */
10
+
13
11
  function optionsHandler(options) {
14
12
  const {
15
13
  disableDefault,
@@ -41,6 +39,7 @@ function optionsHandler(options) {
41
39
  allI18nObject,
42
40
  locales,
43
41
  // template: (object, locale) => `window.loadI18n(${JSON.stringify(object)}, ${JSON.stringify(locale)})`,
42
+
44
43
  runtime: true,
45
44
  runtimeOptions: {
46
45
  insert: options.insert,
@@ -49,20 +48,16 @@ function optionsHandler(options) {
49
48
  }
50
49
  };
51
50
  }
52
-
53
51
  function chunkNameDecider(filename) {
54
52
  if (typeof filename !== 'function') {
55
53
  const hasName = filename.includes('[name]');
56
54
  const hasId = filename.includes('[id]');
57
55
  const hasChunkHash = filename.includes('[chunkhash]');
58
56
  const hasContentHash = filename.includes('[contenthash]');
59
-
60
57
  if (hasChunkHash || hasContentHash || hasName || hasId) {
61
58
  return filename;
62
59
  }
63
-
64
60
  return filename.replace(/(^|\/)([^/]*(?:\?|$))/, '$1[id].$2');
65
61
  }
66
-
67
62
  return _constants.DEFAULT_CHUNK_FILENAME;
68
63
  }
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.pathCreator = pathCreator;
7
-
8
7
  var _constants = require("./constants");
9
-
10
8
  function pathCreator(filenameTemplate, compilation, data) {
11
9
  return compilation.getAssetPath(filenameTemplate.replace(/\[locale\]/gi, data.locale), {
12
10
  hash: data.hash,
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.readI18nValues = readI18nValues;
7
-
8
7
  var _propertiesUtils = require("./utils/propertiesUtils");
9
-
10
8
  // gethere i18n keys and values
11
9
  function readI18nValues({
12
10
  jsResource,
@@ -18,8 +16,9 @@ function readI18nValues({
18
16
  folderPath: propertiesFolder,
19
17
  disableDefault,
20
18
  jsResourceI18nKeys
21
- }); // initialize base data's and plugis
19
+ });
22
20
 
21
+ // initialize base data's and plugis
23
22
  const locales = Object.keys(allI18nObject);
24
23
  return {
25
24
  jsResourceI18nKeys,
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.templateFileName = templateFileName;
7
-
8
7
  var _webpack = require("webpack");
9
-
10
8
  var _templateHashHelpers = require("./templateHashHelpers");
11
-
12
9
  function templateFileName({
13
10
  compilation,
14
11
  dynamicFilename,
@@ -20,8 +17,9 @@ function templateFileName({
20
17
  const {
21
18
  mapExpr,
22
19
  mapExprWithLength
23
- } = (0, _templateHashHelpers.templateHashHelpers)(chunks); // "i18n-chunk/[locale]/[name].[chunkhash].js"
20
+ } = (0, _templateHashHelpers.templateHashHelpers)(chunks);
24
21
 
22
+ // "i18n-chunk/[locale]/[name].[chunkhash].js"
25
23
  const i18nURLPathTemplate = compilation.getPath(JSON.stringify(dynamicFilename).replace(/\[locale\]/gi, '"+ locale +"'), {
26
24
  hash: `" + ${_webpack.RuntimeGlobals.getFullHash}() + "`,
27
25
  hashWithLength: length => `" + ${_webpack.RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.templateHashHelpers = templateHashHelpers;
7
-
8
7
  /**
9
8
  * this function will be used for chunk name, chunk hash, contentHash
10
9
  * in these, sometime chunk name and chunk id same for some chunkss so below logic has little towek
11
10
  * @param {Chunk} chunks
12
11
  * @returns { mapExpr, mapExprWithLength }
13
12
  */
13
+
14
14
  function templateHashHelpers(chunks) {
15
15
  /**
16
16
  * @param {function(Chunk): string | number} fn function from chunk to value
@@ -20,11 +20,10 @@ function templateHashHelpers(chunks) {
20
20
  const obj = {};
21
21
  let useId = false;
22
22
  let lastKey;
23
- let entries = 0; // eslint-disable-next-line no-restricted-syntax
24
-
23
+ let entries = 0;
24
+ // eslint-disable-next-line no-restricted-syntax
25
25
  for (const c of chunks) {
26
26
  const value = fn(c);
27
-
28
27
  if (value === c.id) {
29
28
  useId = true;
30
29
  } else {
@@ -33,38 +32,34 @@ function templateHashHelpers(chunks) {
33
32
  entries++;
34
33
  }
35
34
  }
36
-
37
35
  if (entries === 0) {
38
36
  return 'chunkId';
39
37
  }
40
-
41
38
  if (entries === 1) {
42
39
  return useId ? `(chunkId === ${JSON.stringify(lastKey)} ? ${JSON.stringify(obj[lastKey])} : chunkId)` : JSON.stringify(obj[lastKey]);
43
40
  }
44
-
45
41
  return useId ? `(${JSON.stringify(obj)}[chunkId] || chunkId)` : `${JSON.stringify(obj)}[chunkId]`;
46
42
  };
43
+
47
44
  /**
48
45
  * @param {function(Chunk): string | number} fn function from chunk to value
49
46
  * @returns {string} code with static mapping of results of fn for including in quoted string
50
47
  */
51
-
52
-
53
48
  const mapExpr = fn => `" + ${createMap(fn)} + "`;
49
+
54
50
  /**
55
51
  * @param {function(Chunk): string | number} fn function from chunk to value
56
52
  * @returns {function(number): string} function which generates code with static mapping of results of fn for including in quoted string for specific length
57
53
  */
58
-
59
-
60
- const mapExprWithLength = fn => length => // console.log('called with lentch', length),
54
+ const mapExprWithLength = fn => length =>
55
+ // console.log('called with lentch', length),
61
56
  `" + ${createMap(c => `${fn(c)}`.slice(0, length))} + "`;
62
-
63
57
  return {
64
58
  mapExpr,
65
59
  mapExprWithLength
66
60
  };
67
61
  }
62
+
68
63
  /**
69
64
  function mapExpr(fn) {
70
65
  const obj = {};
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.collectI18nKeysfromAST = collectI18nKeysfromAST;
7
7
  exports.collectI18nKeysfromComments = collectI18nKeysfromComments;
8
-
9
8
  var _estreeWalker = require("estree-walker");
10
-
11
9
  function collectI18nKeysfromAST(ast, allI18n) {
12
10
  const i18nKeys = {};
13
11
  (0, _estreeWalker.walk)(ast, {
@@ -18,41 +16,33 @@ function collectI18nKeysfromAST(ast, allI18n) {
18
16
  }
19
17
  }
20
18
  }
21
-
22
19
  });
23
20
  return Object.keys(i18nKeys);
24
21
  }
25
-
26
22
  const prefixI18nComment = 'I18N';
27
23
  const prefixI18nComment1 = 'dynamic-i18n-key';
28
-
29
24
  function getI18nKeysFromComment(comment) {
30
25
  const commentString = comment.value.trim();
31
26
  let i18nKeyStr;
32
-
33
27
  if (commentString.startsWith(prefixI18nComment)) {
34
28
  i18nKeyStr = commentString.slice(prefixI18nComment.length).trim();
35
29
  } else if (commentString.startsWith(prefixI18nComment1)) {
36
30
  i18nKeyStr = commentString.slice(prefixI18nComment1.length).trim();
37
31
  }
38
-
39
32
  if (!i18nKeyStr) {
40
33
  return [];
41
34
  }
42
-
43
35
  const i18nKeys = i18nKeyStr.split(',');
44
36
  return i18nKeys;
45
- } // export function fromComments(comments, allI18n) {
46
-
37
+ }
47
38
 
39
+ // export function fromComments(comments, allI18n) {
48
40
  function collectI18nKeysfromComments(comments, allI18n) {
49
41
  // TODO: need to implement
50
42
  const i18nKeys = {};
51
43
  /* eslint-disable no-restricted-syntax */
52
-
53
44
  for (const comment of comments) {
54
45
  const keys = getI18nKeysFromComment(comment);
55
-
56
46
  for (const key of keys) {
57
47
  if (key && allI18n[key]) {
58
48
  i18nKeys[key] = allI18n[key];
@@ -60,7 +50,5 @@ function collectI18nKeysfromComments(comments, allI18n) {
60
50
  }
61
51
  }
62
52
  /* eslint-enable no-restricted-syntax */
63
-
64
-
65
53
  return Object.keys(i18nKeys);
66
54
  }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getChunkModules = getChunkModules;
7
-
8
7
  function getChunkModules(chunk, compilation) {
9
8
  const {
10
9
  chunkGraph
@@ -10,9 +10,7 @@ exports.hasContentHash = hasContentHash;
10
10
  // export const REGEXP_NAME = /\[name\]/gi;
11
11
  // export const REGEXP_PLACEHOLDERS = /\[(name|id|chunkhash)\]/gi;
12
12
  // TODO: want to choose file type for i18n load
13
- const REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/gi;
14
- exports.REGEXP_CONTENTHASH = REGEXP_CONTENTHASH;
15
-
13
+ const REGEXP_CONTENTHASH = exports.REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/gi;
16
14
  function hasContentHash(filenameTemplate) {
17
15
  REGEXP_CONTENTHASH.lastIndex = 0;
18
16
  return REGEXP_CONTENTHASH.test(filenameTemplate);
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _collectI18nKeys = require("./collectI18nKeys");
8
-
9
7
  Object.keys(_collectI18nKeys).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _collectI18nKeys[key]) return;
@@ -16,9 +14,7 @@ Object.keys(_collectI18nKeys).forEach(function (key) {
16
14
  }
17
15
  });
18
16
  });
19
-
20
17
  var _propertiesUtils = require("./propertiesUtils");
21
-
22
18
  Object.keys(_propertiesUtils).forEach(function (key) {
23
19
  if (key === "default" || key === "__esModule") return;
24
20
  if (key in exports && exports[key] === _propertiesUtils[key]) return;
@@ -7,32 +7,25 @@ exports.decodeUnicodeEscapes = decodeUnicodeEscapes;
7
7
  exports.getAllI18n = getAllI18n;
8
8
  exports.getPropertiesAsJSON = getPropertiesAsJSON;
9
9
  exports.jsonToString = jsonToString;
10
-
11
10
  var _fs = require("fs");
12
-
13
11
  var _path = require("path");
14
-
15
12
  var _constants = require("../../../../../constants");
16
-
17
13
  function isComment(line) {
18
14
  return line[0] === '#';
19
15
  }
16
+
20
17
  /**
21
18
  * Decode Unicode escape sequences in a string
22
19
  * Converts \uXXXX to the actual character
23
20
  */
24
-
25
-
26
21
  function decodeUnicodeEscapes(str) {
27
22
  if (typeof str !== 'string') {
28
23
  return str;
29
24
  }
30
-
31
25
  return str.replace(/\\u([0-9a-fA-F]{4})/g, (match, hex) => {
32
26
  return String.fromCharCode(parseInt(hex, 16));
33
27
  });
34
28
  }
35
-
36
29
  function getPropertiesAsJSON(filePath) {
37
30
  try {
38
31
  const data = (0, _fs.readFileSync)(filePath);
@@ -40,15 +33,12 @@ function getPropertiesAsJSON(filePath) {
40
33
  const i18nObj = {};
41
34
  source.split(/\r?\n\r?/).forEach(fline => {
42
35
  const line = fline.trim();
43
-
44
36
  if (!line || isComment(line)) {
45
37
  return;
46
38
  }
47
-
48
39
  const ind = line.indexOf('=');
49
40
  const key = line.slice(0, ind).replace(/\\ /g, ' ');
50
41
  let value = line.slice(ind + 1);
51
-
52
42
  if (key && value) {
53
43
  // Decode Unicode escapes in the value
54
44
  value = decodeUnicodeEscapes(value);
@@ -59,21 +49,18 @@ function getPropertiesAsJSON(filePath) {
59
49
  } catch (err) {
60
50
  return {};
61
51
  }
62
- } // TODO: need to make it as custom option and dynamic
63
-
52
+ }
64
53
 
54
+ // TODO: need to make it as custom option and dynamic
65
55
  function getLang(file) {
66
56
  const underScoreIndex = file.indexOf('_');
67
57
  let language = 'en_US';
68
-
69
58
  if (underScoreIndex !== -1) {
70
59
  language = file.substring(underScoreIndex + 1);
71
60
  language = language.slice(0, language.indexOf('.'));
72
61
  }
73
-
74
62
  return language;
75
63
  }
76
-
77
64
  function getAllI18n({
78
65
  folderPath,
79
66
  disableDefault,
@@ -87,13 +74,12 @@ function getAllI18n({
87
74
  const context = (0, _constants.joinWithAppPath)(folderPath);
88
75
  files.forEach(file => {
89
76
  const filePath = (0, _path.join)(context, file);
90
-
91
77
  if (exclude.test(filePath) || !include.test(filePath)) {
92
78
  return;
93
79
  }
94
-
95
80
  const i18n = getPropertiesAsJSON(filePath);
96
- allLangI18n[getLang(file)] = disableDefault ? i18n : { ...jsResourceI18nKeys,
81
+ allLangI18n[getLang(file)] = disableDefault ? i18n : {
82
+ ...jsResourceI18nKeys,
97
83
  ...i18n
98
84
  };
99
85
  });
@@ -103,29 +89,23 @@ function getAllI18n({
103
89
  return {};
104
90
  }
105
91
  }
106
-
107
92
  function jsonToString(json, keySeperator) {
108
93
  let str = '{';
109
94
  const keys = Object.keys(json);
110
95
  keys.forEach((key, i) => {
111
96
  const value = json[key];
112
-
113
97
  if (!value) {
114
98
  return;
115
99
  }
116
-
117
100
  str += `"${keySeperator ? key.replace(/(\.|\\(\s+))/g, keySeperator) : key}":"${value.replace(/.?"/g, match => {
118
101
  if (match[0] === '\\') {
119
102
  return match;
120
103
  }
121
-
122
104
  if (match.length === 2) {
123
105
  return `${match[0]}\\${match[1]}`;
124
106
  }
125
-
126
107
  return `\\${match}`;
127
108
  }).replace(/(\r\n|\n|\r)/g, '')}"`;
128
-
129
109
  if (i !== keys.length - 1) {
130
110
  str += ',';
131
111
  }
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.InitialHtmlPlugin = 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 = 'InitialHtmlPlugin';
13
-
14
10
  class InitialHtmlPlugin {
15
11
  constructor(options) {
16
12
  this.options = options;
17
13
  }
18
-
19
14
  apply(compiler) {
20
15
  const {
21
16
  filename,
@@ -40,21 +35,19 @@ class InitialHtmlPlugin {
40
35
  Object.assign(tag.attributes, {
41
36
  nonce: '{{--CSP-nonce}}'
42
37
  });
43
-
44
38
  if (tag.tagName === 'link') {
45
39
  headTags.push(tag);
46
40
  } else {
47
41
  bodyTags.push(tag);
48
42
  }
49
43
  });
50
- cb(null, { ...data,
44
+ cb(null, {
45
+ ...data,
51
46
  headTags,
52
47
  bodyTags
53
48
  });
54
49
  });
55
50
  });
56
51
  }
57
-
58
52
  }
59
-
60
53
  exports.InitialHtmlPlugin = InitialHtmlPlugin;
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.addFilesNamesToManifestJson = addFilesNamesToManifestJson;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _removeHashFromFileName = require("./removeHashFromFileName");
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
  function addFilesNamesToManifestJson({
15
11
  manifestJson,
16
12
  option,
@@ -20,7 +16,6 @@ function addFilesNamesToManifestJson({
20
16
  const json = manifestJson;
21
17
  Object.keys(assets).forEach(filename => {
22
18
  const fileName = _path.default.parse(filename).base;
23
-
24
19
  if (option.test(filename)) {
25
20
  const filenameNameWithoutHash = (0, _removeHashFromFileName.removeHashFromFileName)(fileName, hashDigestLength);
26
21
  json[filenameNameWithoutHash] = fileName;
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createInitialEntriesForManifestJson = createInitialEntriesForManifestJson;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _removeHashFromFileName = require("./removeHashFromFileName");
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
  function createInitialEntriesForManifestJson(initialFileNames, hashLength) {
15
11
  const initialEntries = {};
16
12
  initialFileNames.forEach(filename => {
17
13
  const fileName = _path.default.parse(filename).base;
18
-
19
14
  const filenameNameWithoutHash = (0, _removeHashFromFileName.removeHashFromFileName)(fileName, hashLength);
20
15
  initialEntries[filenameNameWithoutHash] = fileName;
21
16
  });
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createManifestJson = createManifestJson;
7
-
8
7
  var _findInitialFileNames = require("./findInitialFileNames");
9
-
10
8
  var _addFilesNamesToManifestJson = require("./addFilesNamesToManifestJson");
11
-
12
9
  var _createInitialEntries = require("./createInitialEntries");
13
-
14
10
  function createManifestJson({
15
11
  option,
16
12
  hashDigestLength,
@@ -18,13 +14,11 @@ function createManifestJson({
18
14
  assets
19
15
  }) {
20
16
  const manifestJson = {};
21
-
22
17
  if (option.needInitialEntries) {
23
18
  const initialFileNames = (0, _findInitialFileNames.findInitialFileNames)(compilation);
24
19
  const initialEntries = (0, _createInitialEntries.createInitialEntriesForManifestJson)(initialFileNames, hashDigestLength);
25
20
  manifestJson.entryFiles = initialEntries;
26
21
  }
27
-
28
22
  const outputJson = (0, _addFilesNamesToManifestJson.addFilesNamesToManifestJson)({
29
23
  manifestJson,
30
24
  option,
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.findInitialFileNames = findInitialFileNames;
7
-
8
7
  function findInitialFileNames(compilation) {
9
8
  const initialEntries = [];
10
9
  compilation.entrypoints.forEach(element => {
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.AddFileToManifestJson = void 0;
7
-
8
7
  var _webpack = require("webpack");
9
-
10
8
  var _createManifestJson = require("./createManifestJson");
11
-
12
9
  const pluginName = 'AddFileToManifestJson';
13
-
14
10
  class AddFileToManifestJson {
15
11
  constructor(options) {
16
12
  this.options = options;
17
13
  }
18
-
19
14
  apply(compiler) {
20
15
  const {
21
16
  RawSource
@@ -40,7 +35,5 @@ class AddFileToManifestJson {
40
35
  });
41
36
  });
42
37
  }
43
-
44
38
  }
45
-
46
39
  exports.AddFileToManifestJson = AddFileToManifestJson;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.removeHashFromFileName = removeHashFromFileName;
7
-
8
7
  function removeHashFromFileName(fileName, hashDigestLength) {
9
8
  let outputFileName = '';
10
9
  fileName.split('.').forEach(iterateValue => {
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _webpack = require("webpack");
9
-
10
8
  const pluginName = 'prefetch-preload-chunk-plugin';
9
+
11
10
  /**
12
11
  * NOTE: below functions are useable in webpack 5.79.0 as per day 28 Apr 2023
13
12
  * Please checkout for future changes
@@ -32,40 +31,36 @@ class ResourceHintsPlugin {
32
31
  css: publicPath,
33
32
  i18n: publicPath
34
33
  };
35
- } // eslint-disable-next-line class-methods-use-this
36
-
34
+ }
37
35
 
36
+ // eslint-disable-next-line class-methods-use-this
38
37
  apply(compiler) {
39
38
  compiler.hooks.thisCompilation.tap(pluginName, compilation => {
40
39
  const enabledChunks = new WeakSet();
41
-
42
40
  const handler = (entryRuntimeChunk, set) => {
43
41
  if (enabledChunks.has(entryRuntimeChunk)) {
44
42
  return;
45
43
  }
46
-
47
44
  enabledChunks.add(entryRuntimeChunk);
48
- set.add(_webpack.RuntimeGlobals.getFullHash); // set.add(RuntimeGlobals.getChunkCssFilename);
45
+ set.add(_webpack.RuntimeGlobals.getFullHash);
49
46
 
47
+ // set.add(RuntimeGlobals.getChunkCssFilename);
50
48
  const {
51
49
  publicPathsTemplateObj
52
50
  } = this;
53
- compilation.addRuntimeModule(entryRuntimeChunk, // eslint-disable-next-line no-use-before-define
51
+ compilation.addRuntimeModule(entryRuntimeChunk,
52
+ // eslint-disable-next-line no-use-before-define
54
53
  new ResourceHintsRuntimePlugin(compiler, {
55
54
  chunk: entryRuntimeChunk,
56
55
  allowPrefetchingMultipleChunks: this.allowPrefetchingMultipleChunks,
57
56
  publicPathsTemplateObj
58
57
  }));
59
58
  };
60
-
61
59
  compilation.hooks.runtimeRequirementInTree.for(_webpack.RuntimeGlobals.ensureChunkHandlers).tap(pluginName, handler);
62
60
  });
63
61
  }
64
-
65
62
  }
66
-
67
63
  exports.default = ResourceHintsPlugin;
68
-
69
64
  class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
70
65
  constructor(compiler, {
71
66
  chunk,
@@ -78,7 +73,6 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
78
73
  this.allowPrefetchingMultipleChunks = allowPrefetchingMultipleChunks;
79
74
  this.chunk = chunk;
80
75
  }
81
-
82
76
  generate() {
83
77
  const {
84
78
  chunk
@@ -89,7 +83,6 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
89
83
  Object.keys(idNameMap).forEach(key => {
90
84
  const value = idNameMap[key];
91
85
  nameIdMap[value] = key;
92
-
93
86
  if (key !== value) {
94
87
  needsMap = true;
95
88
  }
@@ -102,6 +95,7 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
102
95
  jsPP = jsPP || _webpack.RuntimeGlobals.publicPath;
103
96
  cssPP = cssPP || _webpack.RuntimeGlobals.publicPath;
104
97
  i18nPP = i18nPP || _webpack.RuntimeGlobals.publicPath;
98
+
105
99
  /**
106
100
  * naming abbr
107
101
  * ntc -> nameToChunkIdMap
@@ -150,7 +144,8 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
150
144
  return chunkId;
151
145
  }
152
146
  ${_webpack.RuntimeGlobals.require}.getChunkIds = function getChunkIds(chunkId) {
153
- ${// eslint-disable-next-line no-nested-ternary
147
+ ${
148
+ // eslint-disable-next-line no-nested-ternary
154
149
  this.allowPrefetchingMultipleChunks ? `
155
150
  const isRegExAsChunkId = chunkId instanceof RegExp;
156
151
  if(isRegExAsChunkId) {
@@ -173,13 +168,15 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
173
168
  let idOfAChunk = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId)[0];
174
169
  lpp(idOfAChunk, "preload");
175
170
  }
176
- ` // `// Prefetch a chunk (${pluginName})`,
171
+ `
172
+ // `// Prefetch a chunk (${pluginName})`,
177
173
  // `${RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {`,
178
174
  // Template.indent([
179
175
  // `chunkId = ${RuntimeGlobals.require}.getChunkId(chunkId)`,
180
176
  // `${RuntimeGlobals.require}.e(chunkId);`
181
177
  // ]),
182
178
  // '};',
179
+
183
180
  // `// Preload a chunk (${pluginName})`,
184
181
  // `${RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {`,
185
182
  // Template.indent([
@@ -189,5 +186,4 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
189
186
  // '};'
190
187
  ]);
191
188
  }
192
-
193
189
  }