@zohodesk/client_build_tool 0.0.22-exp.4 → 0.0.22-exp.5

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 (240) hide show
  1. package/README.md +0 -723
  2. package/README_backup.md +0 -723
  3. package/app/README.MD +30 -0
  4. package/app/es/test.js +47 -0
  5. package/app/package.json +12 -0
  6. package/lib/schemas/defaultConfigValues.js +3 -6
  7. package/lib/shared/babel/babelWebConfig.js +2 -1
  8. package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/utils.js +15 -0
  9. package/lib/shared/bundler/webpack/entryConfig.js +2 -3
  10. package/lib/shared/bundler/webpack/moduleConcatenationConfig.js +18 -0
  11. package/lib/shared/bundler/webpack/optimizationConfig.js +8 -10
  12. package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +1 -1
  13. package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +1 -1
  14. package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +1 -1
  15. package/package.json +1 -1
  16. package/es/allCommandsConfigs.js +0 -15
  17. package/es/commands/build/commandExecutor.js +0 -6
  18. package/es/commands/build/config.js +0 -5
  19. package/es/commands/build/optionsProcessor.js +0 -25
  20. package/es/commands/build/preProcessor.js +0 -4
  21. package/es/commands/buildEs/commandExecutor.js +0 -29
  22. package/es/commands/buildEs/config.js +0 -5
  23. package/es/commands/buildEs/preProcessor.js +0 -9
  24. package/es/commands/buildLib/commandExecutor.js +0 -24
  25. package/es/commands/buildLib/config.js +0 -5
  26. package/es/commands/buildLib/preProcessor.js +0 -9
  27. package/es/commands/mockserver/commandExecutor.js +0 -32
  28. package/es/commands/mockserver/config.js +0 -5
  29. package/es/commands/pre_process/commandExecutor.js +0 -10
  30. package/es/commands/pre_process/config.js +0 -5
  31. package/es/commands/start/commandExecutor.js +0 -4
  32. package/es/commands/start/config.js +0 -5
  33. package/es/commands/start/optionsProcessor.js +0 -21
  34. package/es/commands/start/preProcessor.js +0 -4
  35. package/es/commands/template/commandExecutor.js +0 -17
  36. package/es/commands/template/config.js +0 -5
  37. package/es/commands/version/commandExecutor.js +0 -5
  38. package/es/commands/version/config.js +0 -5
  39. package/es/commandsRouter.js +0 -58
  40. package/es/index.js +0 -4
  41. package/es/logger.js +0 -23
  42. package/es/schemas/applyValuesToSchema/index.js +0 -25
  43. package/es/schemas/applyValuesToSchema/isObject.js +0 -3
  44. package/es/schemas/applyValuesToSchema/isValid.js +0 -7
  45. package/es/schemas/cliArgsToObject.js +0 -32
  46. package/es/schemas/defaultConfigValues.js +0 -394
  47. package/es/schemas/defaultConfigValuesOnly.js +0 -196
  48. package/es/schemas/deprecatedOptionsHandler.js +0 -60
  49. package/es/schemas/getNpmVersion.js +0 -13
  50. package/es/schemas/giveDefaultValue.js +0 -11
  51. package/es/schemas/npmConfigToObject.js +0 -27
  52. package/es/schemas/readOptions.js +0 -67
  53. package/es/schemas/readOptionsForConfigFile.js +0 -28
  54. package/es/shared/babel/addDefaultPlugins.js +0 -8
  55. package/es/shared/babel/babelWebConfig.js +0 -43
  56. package/es/shared/babel/babel_plugins/removeAttributesPlugin.js +0 -21
  57. package/es/shared/babel/getBabelPlugin.js +0 -36
  58. package/es/shared/babel/runBabelForJSFile.js +0 -15
  59. package/es/shared/babel/runBabelForTsFile.js +0 -34
  60. package/es/shared/bundler/webpack/common/decidePublicPath.js +0 -45
  61. package/es/shared/bundler/webpack/common/libAlias.js +0 -24
  62. package/es/shared/bundler/webpack/common/modeUtils.js +0 -24
  63. package/es/shared/bundler/webpack/common/nameTemplates.js +0 -95
  64. package/es/shared/bundler/webpack/common/resourceBasedPublicPath.js +0 -12
  65. package/es/shared/bundler/webpack/configCustomLoaders.js +0 -3
  66. package/es/shared/bundler/webpack/cssLoaders.js +0 -8
  67. package/es/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +0 -76
  68. package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +0 -102
  69. package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +0 -36
  70. package/es/shared/bundler/webpack/custom_plugins/ChunkHierarchyPlugin.js +0 -65
  71. package/es/shared/bundler/webpack/custom_plugins/CssCustomOrderPlugin.js +0 -37
  72. package/es/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +0 -97
  73. package/es/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +0 -98
  74. package/es/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +0 -211
  75. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +0 -11
  76. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +0 -160
  77. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +0 -66
  78. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +0 -201
  79. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +0 -95
  80. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +0 -59
  81. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +0 -82
  82. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +0 -25
  83. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +0 -13
  84. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -15
  85. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +0 -72
  86. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +0 -23
  87. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +0 -40
  88. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +0 -59
  89. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -15
  90. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +0 -22
  91. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +0 -35
  92. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +0 -70
  93. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +0 -56
  94. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +0 -6
  95. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +0 -10
  96. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -2
  97. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -121
  98. package/es/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +0 -85
  99. package/es/shared/bundler/webpack/custom_plugins/InjectChunkGraphPlugin.js +0 -47
  100. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +0 -20
  101. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +0 -11
  102. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +0 -26
  103. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +0 -11
  104. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +0 -34
  105. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +0 -11
  106. package/es/shared/bundler/webpack/custom_plugins/MurphyInjectorPlugin/index.js +0 -79
  107. package/es/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +0 -0
  108. package/es/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +0 -185
  109. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +0 -47
  110. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +0 -70
  111. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +0 -34
  112. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +0 -14
  113. package/es/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +0 -63
  114. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +0 -9
  115. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +0 -63
  116. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +0 -43
  117. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +0 -7
  118. package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +0 -104
  119. package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +0 -6
  120. package/es/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +0 -74
  121. package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +0 -10
  122. package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +0 -36
  123. package/es/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +0 -35
  124. package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +0 -52
  125. package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +0 -341
  126. package/es/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +0 -67
  127. package/es/shared/bundler/webpack/custom_plugins/emitAsset.js +0 -7
  128. package/es/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +0 -43
  129. package/es/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +0 -79
  130. package/es/shared/bundler/webpack/defaultVendorPatternList.js +0 -3
  131. package/es/shared/bundler/webpack/devtoolConfig.js +0 -6
  132. package/es/shared/bundler/webpack/entryConfig.js +0 -25
  133. package/es/shared/bundler/webpack/externals.js +0 -10
  134. package/es/shared/bundler/webpack/getCSSLoaders.js +0 -17
  135. package/es/shared/bundler/webpack/getFilenameFromModule.js +0 -15
  136. package/es/shared/bundler/webpack/jsLoaders.js +0 -16
  137. package/es/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -4
  138. package/es/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +0 -10
  139. package/es/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +0 -45
  140. package/es/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -11
  141. package/es/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +0 -23
  142. package/es/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -13
  143. package/es/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -71
  144. package/es/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +0 -56
  145. package/es/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +0 -11
  146. package/es/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +0 -40
  147. package/es/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +0 -116
  148. package/es/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +0 -5
  149. package/es/shared/bundler/webpack/loaders/workerLoader.js +0 -121
  150. package/es/shared/bundler/webpack/optimizationConfig.js +0 -42
  151. package/es/shared/bundler/webpack/outputConfig.js +0 -35
  152. package/es/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +0 -30
  153. package/es/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +0 -27
  154. package/es/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +0 -17
  155. package/es/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +0 -16
  156. package/es/shared/bundler/webpack/pluginConfigs/configChunkHierarchyPlugin.js +0 -10
  157. package/es/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +0 -50
  158. package/es/shared/bundler/webpack/pluginConfigs/configCssCustomOrderPlugin.js +0 -8
  159. package/es/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +0 -12
  160. package/es/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +0 -67
  161. package/es/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +0 -37
  162. package/es/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -43
  163. package/es/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +0 -52
  164. package/es/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +0 -17
  165. package/es/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +0 -29
  166. package/es/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -8
  167. package/es/shared/bundler/webpack/pluginConfigs/configInjectChunkGraphPlugin.js +0 -12
  168. package/es/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +0 -36
  169. package/es/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +0 -13
  170. package/es/shared/bundler/webpack/pluginConfigs/configMurphyInjectorPlugin.js +0 -19
  171. package/es/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +0 -18
  172. package/es/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +0 -11
  173. package/es/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -19
  174. package/es/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +0 -20
  175. package/es/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +0 -18
  176. package/es/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +0 -29
  177. package/es/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +0 -12
  178. package/es/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +0 -20
  179. package/es/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +0 -15
  180. package/es/shared/bundler/webpack/plugins.js +0 -33
  181. package/es/shared/bundler/webpack/resolvers.js +0 -70
  182. package/es/shared/bundler/webpack/splitChunksConfig.js +0 -106
  183. package/es/shared/bundler/webpack/statsConfig.js +0 -23
  184. package/es/shared/bundler/webpack/tsLoaders.js +0 -16
  185. package/es/shared/bundler/webpack/utils/index.js +0 -8
  186. package/es/shared/bundler/webpack/utils/object-manipulation.js +0 -82
  187. package/es/shared/bundler/webpack/utils/updateArrayWithDefault.js +0 -29
  188. package/es/shared/bundler/webpack/webpackBuild.js +0 -14
  189. package/es/shared/bundler/webpack/webpackConfig.js +0 -35
  190. package/es/shared/commands-utils/doBasicRequirementCheck.js +0 -10
  191. package/es/shared/commands-utils/getCliPath.js +0 -28
  192. package/es/shared/commands-utils/index.js +0 -3
  193. package/es/shared/commands-utils/log.js +0 -4
  194. package/es/shared/commands-utils/readArgsFormCommandLine.js +0 -4
  195. package/es/shared/commands-utils/readOptionFormCommandLine.js +0 -4
  196. package/es/shared/commands-utils/spawnSyncIO.js +0 -24
  197. package/es/shared/constants.js +0 -22
  198. package/es/shared/fileUtils/copyFile.js +0 -23
  199. package/es/shared/fileUtils/directoryIterator.js +0 -12
  200. package/es/shared/fileUtils/watchRun.js +0 -96
  201. package/es/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +0 -18
  202. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +0 -2
  203. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +0 -58
  204. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +0 -122
  205. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +0 -22
  206. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +0 -11
  207. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +0 -13
  208. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +0 -17
  209. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +0 -32
  210. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +0 -28
  211. package/es/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +0 -125
  212. package/es/shared/postcss/custom_postcss_plugins/SelectorReplace.js +0 -82
  213. package/es/shared/postcss/custom_postcss_plugins/ValueReplacer.js +0 -50
  214. package/es/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +0 -318
  215. package/es/shared/postcss/filterPluginsAllowedForSpecficFile.js +0 -41
  216. package/es/shared/postcss/getAllowedPostCssPlugins.js +0 -20
  217. package/es/shared/postcss/getSpecificPostCssPlugin.js +0 -38
  218. package/es/shared/postcss/runPostCssForCssFile.js +0 -25
  219. package/es/shared/pre_process/runPreProcess.js +0 -47
  220. package/es/shared/server/configWebpackDevMiddleware.js +0 -26
  221. package/es/shared/server/corsHandling.js +0 -23
  222. package/es/shared/server/getIp.js +0 -18
  223. package/es/shared/server/getServerURL.js +0 -28
  224. package/es/shared/server/httpsOptions.js +0 -36
  225. package/es/shared/server/initExpressApp.js +0 -9
  226. package/es/shared/server/initialHTMLHandling.js +0 -92
  227. package/es/shared/server/mockApiHandler.js +0 -53
  228. package/es/shared/server/mockServer.js +0 -34
  229. package/es/shared/server/serveContextFiles.js +0 -17
  230. package/es/shared/server/serverBywebpackDevMiddleware.js +0 -21
  231. package/es/shared/server/startHttpServer.js +0 -18
  232. package/es/shared/server/startHttpsServer.js +0 -26
  233. package/es/shared/server/unwanted/addHttp2Server.js +0 -32
  234. package/es/shared/server/unwanted/configWebpackDevMiddleware.js +0 -35
  235. package/es/shared/server/unwanted/mockApiSupport.js +0 -11
  236. package/es/shared/server/unwanted/websocketMockSetup.js +0 -36
  237. package/es/shared/server/urlConcat.js +0 -35
  238. package/es/shared/utils/requireLocalOrGlobal.js +0 -57
  239. package/es/shared/utils/utils.js +0 -0
  240. package/es/shared/utils/versionPrint.js +0 -9
@@ -1,160 +0,0 @@
1
- /* eslint-disable no-restricted-syntax */
2
- import { sources } from 'webpack';
3
- import { createHash } from "./createHash";
4
- import { pathCreator } from "./pathCreator";
5
- import { jsonToString } from "./utils/propertiesUtils";
6
- import { getLocaleChunkAssetsStore } from "./LocaleChunkAssetsStore";
7
- const pluginName = 'I18nFilesEmitPlugin';
8
- const {
9
- RawSource
10
- } = sources;
11
- export class I18nFilesEmitPlugin {
12
- constructor(options) {
13
- this.options = options; // this.options = {
14
- // locales: options.locales,
15
- // chunkFilename: options.chunkFilename,
16
- // filename: options.filename,
17
- // allI18nObject: options.allI18nObject,
18
- // jsonpFunc: options.jsonpFunc
19
- // };
20
- }
21
-
22
- apply(compiler) {
23
- compiler.hooks.thisCompilation.tap(pluginName, compilation => {
24
- // Get store for cache
25
- this.store = getLocaleChunkAssetsStore(compilation);
26
- const i18nStore = this.store;
27
- compilation.hooks.beforeHash.tap(pluginName, () => {
28
- i18nStore.clear();
29
- this.createAndStoreFileContentForEveryChunkAndLocale(compilation);
30
- });
31
- compilation.hooks.chunkHash.tap(pluginName, (chunk, hash) => {
32
- this.updateChunkHashForEveryLocale(chunk, hash);
33
- });
34
- compilation.hooks.contentHash.tap(pluginName, chunk => {
35
- if (!i18nStore.isChunkHasI18n(chunk.id)) {
36
- return;
37
- }
38
-
39
- this.emitI18nFileForEveryLocale(chunk, compilation);
40
- });
41
- });
42
- }
43
-
44
- createAndStoreFileContentForEveryChunkAndLocale(compilation) {
45
- const {
46
- chunks
47
- } = compilation;
48
- const {
49
- locales
50
- } = this.options;
51
- const i18nStore = this.store;
52
-
53
- for (const chunk of chunks) {
54
- const i18nKeys = i18nStore.getI18nKeysForChunk(chunk);
55
-
56
- if (!i18nKeys.length) {
57
- // eslint-disable-next-line no-continue
58
- continue;
59
- }
60
-
61
- for (const locale of locales) {
62
- const content = this.getI18nChunkFileContent(i18nKeys, locale);
63
- i18nStore.storeData(chunk.id, locale, {
64
- content
65
- });
66
- }
67
- }
68
- }
69
-
70
- updateChunkHashForEveryLocale(chunk, hash) {
71
- const {
72
- locales
73
- } = this.options;
74
- const i18nStore = this.store;
75
-
76
- if (i18nStore.isChunkHasI18n(chunk.id)) {
77
- for (const loc of locales) {
78
- const content = i18nStore.getContent(chunk.id, loc);
79
- hash.update(content);
80
- }
81
- }
82
- }
83
-
84
- emitI18nFileForEveryLocale(chunk, compilation) {
85
- const i18nStore = this.store;
86
- const {
87
- locales,
88
- chunkFilename,
89
- filename
90
- } = this.options;
91
- const fileNameTemplate = chunk.canBeInitial() ? filename : chunkFilename; // const { chunks } = compilation;
92
-
93
- for (const locale of locales) {
94
- const content = i18nStore.getContent(chunk.id, locale);
95
- const contentHash = createHash({
96
- outputOptions: compilation.outputOptions,
97
- content
98
- });
99
- const {
100
- filename
101
- } = I18nFilesEmitPlugin.createFilenameWithHash({
102
- compilation,
103
- contentHash,
104
- fileNameTemplate,
105
- chunk,
106
- locale
107
- });
108
- i18nStore.storeData(chunk.id, locale, {
109
- contentHash,
110
- filename
111
- });
112
- compilation.emitAsset(filename, new RawSource(content));
113
- }
114
- }
115
-
116
- static createFilenameWithHash(_ref) {
117
- let {
118
- compilation,
119
- fileNameTemplate,
120
- chunk,
121
- locale,
122
- contentHash
123
- } = _ref;
124
- const fileName = fileNameTemplate.replaceAll('[locale]', locale);
125
- const filename = pathCreator(fileName, compilation, {
126
- hash: compilation.hash,
127
- locale,
128
- chunkName: chunk.name,
129
- chunkId: chunk.id,
130
- chunkHash: chunk.hash,
131
- contentHash
132
- });
133
- return {
134
- contentHash,
135
- filename
136
- };
137
- }
138
-
139
- getI18nContentForkeys(i18nKeys, locale) {
140
- const {
141
- allI18nObject
142
- } = this.options;
143
- const data = {};
144
-
145
- for (const key of i18nKeys) {
146
- data[key] = allI18nObject[locale][key];
147
- }
148
-
149
- return data;
150
- }
151
-
152
- getI18nChunkFileContent(i18nKeys, loc) {
153
- const {
154
- jsonpFunc
155
- } = this.options;
156
- const data = this.getI18nContentForkeys(i18nKeys, loc);
157
- return `${jsonpFunc}(${jsonToString(data)})`;
158
- }
159
-
160
- }
@@ -1,66 +0,0 @@
1
- /* eslint-disable max-classes-per-file */
2
- import { collectI18nKeysfromAST, collectI18nKeysfromComments } from "./utils";
3
- import { LocaleChunkAssetsStore, setLocaleChunkAssetsStore } from "./LocaleChunkAssetsStore";
4
- const pluginName = 'I18nKeysIdentifier';
5
- /**
6
- * this plugin search the i18 keys and make it as I18nDependency.
7
- * how it works?
8
- * this plugin get jsResourceI18nKeys in constructor.
9
- * we walk thought the js files AST
10
- * if any string literal in that AST is in jsResourceI18nKeys then we consider that string as I18n key
11
- * after the walk of AST we get some I18n keys
12
- * then we make it as I18nDependency.
13
- */
14
-
15
- export default class I18nKeysIdentifer {
16
- constructor(_ref) {
17
- let {
18
- jsResourceI18nKeys
19
- } = _ref;
20
- this.jsResourceI18nKeys = jsResourceI18nKeys;
21
- this.store = new LocaleChunkAssetsStore();
22
- }
23
-
24
- apply(compiler) {
25
- // const { splitChunks } = compiler.options.optimization;
26
- // if (splitChunks) {
27
- // if (splitChunks.defaultSizeTypes.includes('...')) {
28
- // splitChunks.defaultSizeTypes.push(MODULE_TYPE);
29
- // }
30
- // }
31
- compiler.hooks.thisCompilation.tap(pluginName, compilation => {
32
- this.store.updateCompilation(compilation);
33
- setLocaleChunkAssetsStore(compilation, this.store);
34
- });
35
- compiler.hooks.normalModuleFactory.tap(pluginName, factory => {
36
- // handler for parser
37
- const handler = parser => {
38
- parser.hooks.program.tap(pluginName, (ast, comments) => {
39
- const {
40
- module
41
- } = parser.state; //
42
-
43
- if (!(module && /\.jsx?$/.test(module.resource))) {
44
- return;
45
- } // i18n grep proper contract regex
46
-
47
-
48
- let i18nKeys = collectI18nKeysfromAST(ast, this.jsResourceI18nKeys);
49
- i18nKeys = i18nKeys.concat( // i18n grep proper contract regex
50
- collectI18nKeysfromComments(comments, this.jsResourceI18nKeys));
51
-
52
- if (i18nKeys.length) {
53
- // console.log('i18nKeys.length', module.resource, i18nKeys);
54
- this.store.updateModuleI18nKeys(module.resource, i18nKeys);
55
- }
56
- });
57
- }; // this below hook was tapped for collect I18n Key from files and add as Dependency
58
- // const factory = params.normalModuleFactory;
59
-
60
-
61
- factory.hooks.parser.for('javascript/auto').tap(pluginName, handler);
62
- factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler);
63
- });
64
- }
65
-
66
- }
@@ -1,201 +0,0 @@
1
- import { Compilation, RuntimeGlobals, sources } from 'webpack';
2
- import HtmlWebpackPlugin from 'html-webpack-plugin';
3
- import { I18N_CHUNK_NAME_GENERATION_SEGMENT } from "./constants";
4
- import { getI18nLoadingRuntimeModule } from "./getI18nLoadingRuntimeModule";
5
- import { templateFileName } from "./templateFileName";
6
- import { hasContentHash } from "./utils/hashUtils";
7
- import { urlConcat } from "../../../../server/urlConcat";
8
- import { I18nFilesEmitPlugin } from "./I18nFilesEmitPlugin";
9
- import { getLocaleChunkAssetsStore } from "./LocaleChunkAssetsStore";
10
- import { verboseLogger } from "../../../../../logger";
11
- const {
12
- RawSource
13
- } = sources;
14
- const pluginName = 'I18nRuntimeDealerPlugin'; // I18nExtractPlugin.loader = require.resolve('./loader');
15
-
16
- export class I18nRuntimeDealerPlugin {
17
- constructor(options) {
18
- this.options = options;
19
- }
20
-
21
- apply(compiler) {
22
- compiler.hooks.thisCompilation.tap(pluginName, compilation => {
23
- // Get store for cache
24
- this.store = getLocaleChunkAssetsStore(compilation);
25
-
26
- if (!this.options.runtime) {
27
- return;
28
- }
29
-
30
- this.createI18nDownloadCodeInRuntimeFile(compilation);
31
- this.addI18nIntoInitialHtml(compilation);
32
- });
33
- }
34
-
35
- addI18nIntoInitialHtml(compilation) {
36
- const i18nStore = this.store;
37
- HtmlWebpackPlugin.getHooks(compilation).beforeAssetTagGeneration.tap(pluginName, hookOptions => {
38
- const {
39
- assets
40
- } = hookOptions;
41
- const {
42
- templateLabel,
43
- filename,
44
- publicPath = '',
45
- mainChunkName
46
- } = this.options; // const dummyContent = '// dummy comment';
47
-
48
- const dummyContentHash = 'dummy0content0hashes';
49
- const entryPoint = compilation.entrypoints.get(mainChunkName);
50
- const initialChunks = Array.from(entryPoint.chunks).filter(c => c.canBeInitial() && c.id !== c.runtime);
51
- const initialI18nAssets = initialChunks.filter(c => i18nStore.isChunkHasI18n(c)).map(c => {
52
- const data = I18nFilesEmitPlugin.createFilenameWithHash({
53
- compilation,
54
- fileNameTemplate: filename,
55
- chunk: c,
56
- locale: templateLabel,
57
- // NOTE: we used dummy content hash.
58
- // Because we have no plan on use in content hash to initial I18n chunks
59
- // So Dummy hash was being used it will not work just skip warnings
60
- contentHash: dummyContentHash
61
- });
62
- return urlConcat(publicPath, data.filename);
63
- });
64
- const allJSAssets = [...initialI18nAssets, ...assets.js].map(url => url.replaceAll('[locale]', templateLabel).replaceAll('%5Blocale%5D', templateLabel));
65
- return {
66
- assets: { ...assets,
67
- js: allJSAssets
68
- }
69
- };
70
- });
71
- }
72
-
73
- createI18nDownloadCodeInRuntimeFile(compilation) {
74
- const {
75
- chunkFilename,
76
- locales,
77
- localeVarName
78
- } = this.options;
79
- const chunkFilenameHasContentHash = hasContentHash(chunkFilename);
80
-
81
- const getI18nChunks = mainChunk => this.filterI18nUsedChunks(mainChunk.getAllAsyncChunks());
82
-
83
- const I18nLoadingRuntimeModule = getI18nLoadingRuntimeModule({
84
- getI18nChunks
85
- });
86
- const enabledChunks = new WeakSet();
87
-
88
- const chunkFilenameUrlGenerator = (i18nChunks, locale) => templateFileName({
89
- compilation,
90
- localeVarName,
91
- dynamicFilename: chunkFilename,
92
- contentHashes: this.getContentHashes(locale),
93
- chunks: i18nChunks
94
- });
95
-
96
- const prefixFunc = () => I18N_CHUNK_NAME_GENERATION_SEGMENT;
97
-
98
- const handler = (entryRuntimeChunk, set) => {
99
- if (enabledChunks.has(entryRuntimeChunk)) {
100
- return;
101
- }
102
-
103
- enabledChunks.add(entryRuntimeChunk);
104
- const {
105
- chunkFilename,
106
- // filename: initialFilename,
107
- runtimeOptions
108
- } = this.options;
109
-
110
- if (typeof chunkFilename === 'string' && /\[(full)?hash(:\d+)?\]/.test(chunkFilename)) {
111
- set.add(RuntimeGlobals.getFullHash);
112
- }
113
-
114
- set.add(RuntimeGlobals.publicPath);
115
- compilation.addRuntimeModule(entryRuntimeChunk, new I18nLoadingRuntimeModule(set, {
116
- prefixFunc: chunkFilenameHasContentHash ? prefixFunc : chunkFilenameUrlGenerator,
117
- runtimeOptions,
118
- chunkFilename
119
- }));
120
- };
121
-
122
- compilation.hooks.runtimeRequirementInTree.for(RuntimeGlobals.ensureChunkHandlers).tap(pluginName, handler);
123
-
124
- if (chunkFilenameHasContentHash) {
125
- compilation.hooks.processAssets.tap({
126
- name: pluginName,
127
- stage: Compilation.PROCESS_ASSETS_STAGE_DERIVED // additionalAssets: true
128
-
129
- }, assets => {
130
- // eslint-disable-next-line no-underscore-dangle
131
- const entries = compilation._getChunkGraphEntries();
132
-
133
- function createRuntimeFilePerLocale(_ref) {
134
- let {
135
- locale,
136
- runtimeFileName,
137
- runtimeFileSourceStr,
138
- i18nChunks
139
- } = _ref;
140
- const newRuntimeName = runtimeFileName.replaceAll('[locale]', locale);
141
- const replaceText = chunkFilenameUrlGenerator(i18nChunks, locale);
142
- const replacedStr = runtimeFileSourceStr.replace(I18N_CHUNK_NAME_GENERATION_SEGMENT, replaceText);
143
- compilation.emitAsset(newRuntimeName, new RawSource(replacedStr));
144
- } // eslint-disable-next-line no-restricted-syntax
145
-
146
-
147
- for (const entryChunk of entries) {
148
- const i18nChunks = getI18nChunks(entryChunk);
149
- const runtimeFileName = [...entryChunk.files][0];
150
- const runtimeFileSourceStr = assets[runtimeFileName].source();
151
- locales.forEach(locale => createRuntimeFilePerLocale({
152
- locale,
153
- entryChunk,
154
- runtimeFileName,
155
- runtimeFileSourceStr,
156
- i18nChunks
157
- })); // NOTE: we don't delete, Because of HTML plugin needs to add runtime file in html and efc
158
- // compilation.deleteAsset(runtimeFileName);
159
- }
160
- });
161
- compilation.hooks.processAssets.tap({
162
- name: pluginName,
163
- stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE // additionalAssets: true
164
-
165
- }, () => {
166
- // eslint-disable-next-line no-underscore-dangle
167
- const entries = compilation._getChunkGraphEntries(); // eslint-disable-next-line no-restricted-syntax
168
-
169
-
170
- for (const entryChunk of entries) {
171
- const runtimeFileName = [...entryChunk.files][0] || '';
172
-
173
- if (runtimeFileName.includes('runtime') && runtimeFileName.includes('[locale]')) {
174
- verboseLogger('deleteAsset', runtimeFileName);
175
- compilation.deleteAsset(runtimeFileName);
176
- }
177
- }
178
- });
179
- }
180
- }
181
-
182
- filterI18nUsedChunks(chunks) {
183
- const i18nStore = this.store;
184
- return Array.from(chunks).filter(c => i18nStore.isChunkHasI18n(c.id));
185
- }
186
-
187
- getContentHashes(locale) {
188
- const i18nStore = this.store;
189
- const contentHashes = {};
190
- i18nStore.forEachChunkId(chunkId => {
191
- const contentHash = i18nStore.getContentHash(chunkId, locale);
192
-
193
- if (contentHash) {
194
- contentHashes[chunkId] = contentHash;
195
- }
196
- }); // console.log({ contentHashes });
197
-
198
- return contentHashes;
199
- }
200
-
201
- }
@@ -1,95 +0,0 @@
1
- # I18n Split As Chunks Plugin
2
-
3
- generaly we have manage our all I18n keys and values as language specific i18n files and then we download all i18n in initial page load.
4
-
5
- ### what is the problem with this?.
6
-
7
- the problem is i18n file keep get's grown it will affect the the inital page load and critial rendering path.
8
- So, We have decide to create a plugin for split i18n per chunk's of js vise.
9
-
10
- ### what is i18n split?
11
-
12
- it is like code split for i18n.
13
- we will collect i18n from js chunk and we will create separate i18n chunk per js chunk,
14
- with this we already load Js chunks are on demand and now we also download i18n also ondemand with this the initial and forthere actions.
15
- when js download's we will download i18n with it.
16
-
17
- ### How to we going to i18n split?
18
-
19
- we will read the js chunk and collect I18n keys form it,
20
- then we will create i18n chunk files with these used keys.
21
-
22
- ### how do you collect i18n keys from js files?
23
-
24
- we will traverse the js file's AST (static analysis) and find i18 keys,
25
- we will concider all string which is in jsResource file as i18n keys.
26
- and you can tell dynamic i18n key by js comments,
27
- Like Below:-
28
-
29
- ```js
30
- fetch('tickets?view=view1').then(data => {
31
- // I18n support.ticketsEmpty
32
- // I18n support.viewNotFount
33
- // I18n support.permissionDenied
34
- let text = getI18nValue(data.i18nkey);
35
- });
36
- ```
37
-
38
- ### is there any posiblity for unwanted keys in some chunk?
39
-
40
- Yes, there is two posiblity
41
-
42
- 1. js comment , if you write js comment but it is not needed then it will be add into i18n chunk
43
- `To Resolve` we currently do not have perfect idea for this, But we can check this by chunk size limit.
44
- `idea's will be welcome`
45
- 2. like we said "we will concider all string which is in jsResource file as i18n keys",
46
- So if you use string not for i18n but it was in jsResource then it will be add into i18n chunk.
47
- `To Resolve` this problem we can use some kinda prefix or something.
48
-
49
- ### how do we downlowd and give to app?
50
-
51
- we have over write defualt webpack requireEnsure (every dynamic chunk requests are done by that function) function.
52
- and we parlarly dowload i18n files. and we ask jsonFunction, to our plugin.
53
- So we send i18nkeys , when it was download,
54
- you must store all i18n keys, we give asycrnsly by that function download in that patticular.
55
- so you must store and update (like append or assign) everytime that function call.
56
-
57
- ### how to use this feature?
58
-
59
- to use this feature use have give the below oprtions
60
- `package.json`
61
-
62
- ```json
63
- {
64
- /// ...some things
65
- "react-cli": {
66
- // ...some things
67
- "i18n": {
68
- "chunkSplitEnable": true,
69
- "jsResource": "./deskapp/properties/JSResources.properties",
70
- "localeVarName": "window.userInfo.langCode",
71
- "jsonpFunc": "window.loadI18nChunk",
72
- "templateLabel": "{{--user-locale}}", // this is for html template i18n file path locate template
73
- "propertiesFolder": "./deskapp/properties"
74
- }
75
- // ...some things
76
- }
77
- }
78
- ```
79
-
80
- <!-- not need below -->
81
- <!--we have added new feature for css to write logic to how hover related css work in hoverhover and a
82
-
83
- ### is there any problems with static analysis?
84
- Yes,
85
-
86
- ### how do we use dynamic i18n key?
87
-
88
- and we will download i18n file with
89
-
90
- and when js chunk download's then we will download i18n as need.
91
- we all know in our app we loading i18n as one single big file for each locale(language).
92
- we are going to split i18n as per js chunk, and when js chunk download's then we will download i18n as need.
93
-
94
-
95
- -->
@@ -1,59 +0,0 @@
1
- import { ModulesI18nKeysStore } from "./ModulesI18nKeysStore";
2
- export class LocaleChunkAssetsStore extends ModulesI18nKeysStore {
3
- constructor() {
4
- super();
5
- this.data = {};
6
- }
7
-
8
- clear() {
9
- this.data = {};
10
- }
11
-
12
- storeData(chunkId, locale, data) {
13
- if (!this.data[chunkId]) {
14
- this.data[chunkId] = {};
15
- }
16
-
17
- const chunkBasedData = this.data[chunkId];
18
- chunkBasedData[locale] = { ...(chunkBasedData[locale] || {}),
19
- ...data
20
- };
21
- }
22
-
23
- getChunkIdsWhichHasI18n() {
24
- return Object.keys(this.data);
25
- }
26
-
27
- forEachChunkId(cb) {
28
- // Object.keys(localeChunkAssestMap).forEach
29
- this.getChunkIdsWhichHasI18n().forEach(cb);
30
- }
31
-
32
- isChunkHasI18n(chunkId) {
33
- if (typeof chunkId === 'object') {
34
- return super.isChunkHasI18n(chunkId);
35
- }
36
-
37
- return !!this.data[chunkId];
38
- }
39
-
40
- getDate(chunkId, locale) {
41
- return this.data[chunkId]?.[locale];
42
- }
43
-
44
- getContent(chunkId, locale) {
45
- return this.data[chunkId]?.[locale]?.content;
46
- }
47
-
48
- getContentHash(chunkId, locale) {
49
- return this.data[chunkId]?.[locale]?.contentHash;
50
- }
51
-
52
- }
53
- const storeCache = new WeakMap();
54
- export function getLocaleChunkAssetsStore(compilation) {
55
- return storeCache.get(compilation);
56
- }
57
- export function setLocaleChunkAssetsStore(compilation, store) {
58
- return storeCache.set(compilation, store);
59
- }
@@ -1,82 +0,0 @@
1
- import { iterateModulesInChunk } from "./iterateModulesInChunk";
2
- export class ModulesI18nKeysStore {
3
- constructor() {
4
- this.modulesI18nKeysMap = {};
5
- this.compilation = null;
6
- }
7
-
8
- updateCompilation(compilation) {
9
- this.compilation = compilation;
10
- }
11
-
12
- updateModuleI18nKeys(resource, i18nKeys) {
13
- this.modulesI18nKeysMap[resource] = i18nKeys;
14
- }
15
-
16
- getModuleI18nKeys(resource) {
17
- return this.modulesI18nKeysMap[resource];
18
- }
19
-
20
- isChunkHasI18n(chunk) {
21
- const {
22
- modulesI18nKeysMap,
23
- compilation
24
- } = this;
25
- let hasModuleI18n = false;
26
- iterateModulesInChunk({
27
- chunk,
28
- compilation,
29
- cb: _ref => {
30
- let {
31
- module: mod,
32
- stop: stopLoop
33
- } = _ref;
34
-
35
- if (mod.resource) {
36
- const keys = modulesI18nKeysMap[mod.resource];
37
-
38
- if (keys && keys.length > 0) {
39
- hasModuleI18n = true;
40
- stopLoop();
41
- }
42
- }
43
- }
44
- });
45
- return hasModuleI18n;
46
- }
47
-
48
- getI18nKeysForChunk(chunk) {
49
- const {
50
- modulesI18nKeysMap,
51
- compilation
52
- } = this;
53
- const i18nKeysMap = {};
54
-
55
- function updateI18nKeys(mod) {
56
- const keys = modulesI18nKeysMap[mod.resource];
57
-
58
- if (keys) {
59
- // eslint-disable-next-line no-restricted-syntax
60
- for (const key of keys) {
61
- i18nKeysMap[key] = 1;
62
- }
63
- }
64
- }
65
-
66
- iterateModulesInChunk({
67
- chunk,
68
- compilation,
69
- cb: _ref2 => {
70
- let {
71
- module: mod
72
- } = _ref2;
73
-
74
- if (mod.resource) {
75
- updateI18nKeys(mod);
76
- }
77
- }
78
- });
79
- return Object.keys(i18nKeysMap);
80
- }
81
-
82
- }
@@ -1,25 +0,0 @@
1
- # I18n Split As Chunks Plugin
2
-
3
- generaly we have manage our all I18n keys and values as language specific i18n files and then we download all i18n in initial page load.
4
-
5
- Ok, what is the problem with this?.
6
- the problem is i18n file keep get's grown it will affect the the inital page load and critial rendering path.
7
- So, We have decide to create a plugin for split i18n per chunk's of js vise, Which mean we diside to create for each js chunk has its own i18n chunks, with this we already load Js chunks are on demand and now we also download i18n also ondemand with this the initial and forthere actions.
8
-
9
- Ok, How to you do this thing?
10
- we have read the js chunk and collect I18n keys what are used in that chunk and we will create i18n chunk files with only used key.
11
-
12
- Ok, How do you collect that keys?
13
- we now have two experimental stage to collect I18n keys.
14
-
15
- 1. we read jsResource.properties (or all keys I18n file) then we walk this AST of js and we collect all string which is jsResource.properties.
16
- 2. for dynamic we discide to use comment some thing like
17
- `// I18n support.tickekt.email.notvalid`
18
-
19
- ok, how do you downlowd and give to app?
20
- we have over write defualt webpack require ensure function.
21
- So every dynamic chunk requset are done by that function.
22
- So we parlarly dowload i18n files. and we ask jsonFunction, to our plugin.
23
- So we send i18nkeys , when it was download,
24
- you must store all i18n keys, we give asycrnsly by that function download in that patticular.
25
- so you must store and update (like append or assign) everytime that function call.