@zohodesk/client_build_tool 0.0.22-exp.3 → 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 (242) 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 +2 -2
  7. package/lib/schemas/defaultConfigValuesOnly.js +0 -5
  8. package/lib/shared/babel/babelWebConfig.js +2 -1
  9. package/lib/shared/bundler/webpack/configCustomLoaders.js +1 -4
  10. package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/utils.js +15 -0
  11. package/lib/shared/bundler/webpack/entryConfig.js +2 -3
  12. package/lib/shared/bundler/webpack/moduleConcatenationConfig.js +18 -0
  13. package/lib/shared/bundler/webpack/optimizationConfig.js +4 -9
  14. package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +1 -1
  15. package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +1 -1
  16. package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +1 -1
  17. package/package.json +1 -1
  18. package/es/allCommandsConfigs.js +0 -15
  19. package/es/commands/build/commandExecutor.js +0 -6
  20. package/es/commands/build/config.js +0 -5
  21. package/es/commands/build/optionsProcessor.js +0 -25
  22. package/es/commands/build/preProcessor.js +0 -4
  23. package/es/commands/buildEs/commandExecutor.js +0 -29
  24. package/es/commands/buildEs/config.js +0 -5
  25. package/es/commands/buildEs/preProcessor.js +0 -9
  26. package/es/commands/buildLib/commandExecutor.js +0 -24
  27. package/es/commands/buildLib/config.js +0 -5
  28. package/es/commands/buildLib/preProcessor.js +0 -9
  29. package/es/commands/mockserver/commandExecutor.js +0 -32
  30. package/es/commands/mockserver/config.js +0 -5
  31. package/es/commands/pre_process/commandExecutor.js +0 -10
  32. package/es/commands/pre_process/config.js +0 -5
  33. package/es/commands/start/commandExecutor.js +0 -4
  34. package/es/commands/start/config.js +0 -5
  35. package/es/commands/start/optionsProcessor.js +0 -21
  36. package/es/commands/start/preProcessor.js +0 -4
  37. package/es/commands/template/commandExecutor.js +0 -17
  38. package/es/commands/template/config.js +0 -5
  39. package/es/commands/version/commandExecutor.js +0 -5
  40. package/es/commands/version/config.js +0 -5
  41. package/es/commandsRouter.js +0 -58
  42. package/es/index.js +0 -4
  43. package/es/logger.js +0 -23
  44. package/es/schemas/applyValuesToSchema/index.js +0 -25
  45. package/es/schemas/applyValuesToSchema/isObject.js +0 -3
  46. package/es/schemas/applyValuesToSchema/isValid.js +0 -7
  47. package/es/schemas/cliArgsToObject.js +0 -32
  48. package/es/schemas/defaultConfigValues.js +0 -394
  49. package/es/schemas/defaultConfigValuesOnly.js +0 -196
  50. package/es/schemas/deprecatedOptionsHandler.js +0 -60
  51. package/es/schemas/getNpmVersion.js +0 -13
  52. package/es/schemas/giveDefaultValue.js +0 -11
  53. package/es/schemas/npmConfigToObject.js +0 -27
  54. package/es/schemas/readOptions.js +0 -67
  55. package/es/schemas/readOptionsForConfigFile.js +0 -28
  56. package/es/shared/babel/addDefaultPlugins.js +0 -8
  57. package/es/shared/babel/babelWebConfig.js +0 -43
  58. package/es/shared/babel/babel_plugins/removeAttributesPlugin.js +0 -21
  59. package/es/shared/babel/getBabelPlugin.js +0 -36
  60. package/es/shared/babel/runBabelForJSFile.js +0 -15
  61. package/es/shared/babel/runBabelForTsFile.js +0 -34
  62. package/es/shared/bundler/webpack/common/decidePublicPath.js +0 -45
  63. package/es/shared/bundler/webpack/common/libAlias.js +0 -24
  64. package/es/shared/bundler/webpack/common/modeUtils.js +0 -24
  65. package/es/shared/bundler/webpack/common/nameTemplates.js +0 -95
  66. package/es/shared/bundler/webpack/common/resourceBasedPublicPath.js +0 -12
  67. package/es/shared/bundler/webpack/configCustomLoaders.js +0 -3
  68. package/es/shared/bundler/webpack/cssLoaders.js +0 -8
  69. package/es/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +0 -76
  70. package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +0 -102
  71. package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +0 -36
  72. package/es/shared/bundler/webpack/custom_plugins/ChunkHierarchyPlugin.js +0 -65
  73. package/es/shared/bundler/webpack/custom_plugins/CssCustomOrderPlugin.js +0 -37
  74. package/es/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +0 -97
  75. package/es/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +0 -98
  76. package/es/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +0 -211
  77. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +0 -11
  78. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +0 -160
  79. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +0 -66
  80. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +0 -201
  81. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +0 -95
  82. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +0 -59
  83. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +0 -82
  84. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +0 -25
  85. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +0 -13
  86. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -15
  87. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +0 -72
  88. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +0 -23
  89. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +0 -40
  90. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +0 -59
  91. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -15
  92. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +0 -22
  93. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +0 -35
  94. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +0 -70
  95. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +0 -56
  96. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +0 -6
  97. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +0 -10
  98. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -2
  99. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -121
  100. package/es/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +0 -85
  101. package/es/shared/bundler/webpack/custom_plugins/InjectChunkGraphPlugin.js +0 -47
  102. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +0 -20
  103. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +0 -11
  104. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +0 -26
  105. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +0 -11
  106. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +0 -34
  107. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +0 -11
  108. package/es/shared/bundler/webpack/custom_plugins/MurphyInjectorPlugin/index.js +0 -79
  109. package/es/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +0 -0
  110. package/es/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +0 -185
  111. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +0 -47
  112. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +0 -70
  113. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +0 -34
  114. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +0 -14
  115. package/es/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +0 -63
  116. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +0 -9
  117. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +0 -63
  118. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +0 -43
  119. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +0 -7
  120. package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +0 -104
  121. package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +0 -6
  122. package/es/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +0 -74
  123. package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +0 -10
  124. package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +0 -36
  125. package/es/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +0 -35
  126. package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +0 -52
  127. package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +0 -341
  128. package/es/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +0 -67
  129. package/es/shared/bundler/webpack/custom_plugins/emitAsset.js +0 -7
  130. package/es/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +0 -43
  131. package/es/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +0 -79
  132. package/es/shared/bundler/webpack/defaultVendorPatternList.js +0 -3
  133. package/es/shared/bundler/webpack/devtoolConfig.js +0 -6
  134. package/es/shared/bundler/webpack/entryConfig.js +0 -25
  135. package/es/shared/bundler/webpack/externals.js +0 -10
  136. package/es/shared/bundler/webpack/getCSSLoaders.js +0 -17
  137. package/es/shared/bundler/webpack/getFilenameFromModule.js +0 -15
  138. package/es/shared/bundler/webpack/jsLoaders.js +0 -16
  139. package/es/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -4
  140. package/es/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +0 -10
  141. package/es/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +0 -45
  142. package/es/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -11
  143. package/es/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +0 -23
  144. package/es/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -13
  145. package/es/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -71
  146. package/es/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +0 -56
  147. package/es/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +0 -11
  148. package/es/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +0 -40
  149. package/es/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +0 -116
  150. package/es/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +0 -5
  151. package/es/shared/bundler/webpack/loaders/workerLoader.js +0 -121
  152. package/es/shared/bundler/webpack/optimizationConfig.js +0 -42
  153. package/es/shared/bundler/webpack/outputConfig.js +0 -35
  154. package/es/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +0 -30
  155. package/es/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +0 -27
  156. package/es/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +0 -17
  157. package/es/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +0 -16
  158. package/es/shared/bundler/webpack/pluginConfigs/configChunkHierarchyPlugin.js +0 -10
  159. package/es/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +0 -50
  160. package/es/shared/bundler/webpack/pluginConfigs/configCssCustomOrderPlugin.js +0 -8
  161. package/es/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +0 -12
  162. package/es/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +0 -67
  163. package/es/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +0 -37
  164. package/es/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -43
  165. package/es/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +0 -52
  166. package/es/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +0 -17
  167. package/es/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +0 -29
  168. package/es/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -8
  169. package/es/shared/bundler/webpack/pluginConfigs/configInjectChunkGraphPlugin.js +0 -12
  170. package/es/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +0 -36
  171. package/es/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +0 -13
  172. package/es/shared/bundler/webpack/pluginConfigs/configMurphyInjectorPlugin.js +0 -19
  173. package/es/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +0 -18
  174. package/es/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +0 -11
  175. package/es/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -19
  176. package/es/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +0 -20
  177. package/es/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +0 -18
  178. package/es/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +0 -29
  179. package/es/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +0 -12
  180. package/es/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +0 -20
  181. package/es/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +0 -15
  182. package/es/shared/bundler/webpack/plugins.js +0 -33
  183. package/es/shared/bundler/webpack/resolvers.js +0 -70
  184. package/es/shared/bundler/webpack/splitChunksConfig.js +0 -106
  185. package/es/shared/bundler/webpack/statsConfig.js +0 -23
  186. package/es/shared/bundler/webpack/tsLoaders.js +0 -16
  187. package/es/shared/bundler/webpack/utils/index.js +0 -8
  188. package/es/shared/bundler/webpack/utils/object-manipulation.js +0 -82
  189. package/es/shared/bundler/webpack/utils/updateArrayWithDefault.js +0 -29
  190. package/es/shared/bundler/webpack/webpackBuild.js +0 -14
  191. package/es/shared/bundler/webpack/webpackConfig.js +0 -35
  192. package/es/shared/commands-utils/doBasicRequirementCheck.js +0 -10
  193. package/es/shared/commands-utils/getCliPath.js +0 -28
  194. package/es/shared/commands-utils/index.js +0 -3
  195. package/es/shared/commands-utils/log.js +0 -4
  196. package/es/shared/commands-utils/readArgsFormCommandLine.js +0 -4
  197. package/es/shared/commands-utils/readOptionFormCommandLine.js +0 -4
  198. package/es/shared/commands-utils/spawnSyncIO.js +0 -24
  199. package/es/shared/constants.js +0 -22
  200. package/es/shared/fileUtils/copyFile.js +0 -23
  201. package/es/shared/fileUtils/directoryIterator.js +0 -12
  202. package/es/shared/fileUtils/watchRun.js +0 -96
  203. package/es/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +0 -18
  204. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +0 -2
  205. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +0 -58
  206. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +0 -122
  207. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +0 -22
  208. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +0 -11
  209. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +0 -13
  210. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +0 -17
  211. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +0 -32
  212. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +0 -28
  213. package/es/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +0 -125
  214. package/es/shared/postcss/custom_postcss_plugins/SelectorReplace.js +0 -82
  215. package/es/shared/postcss/custom_postcss_plugins/ValueReplacer.js +0 -50
  216. package/es/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +0 -318
  217. package/es/shared/postcss/filterPluginsAllowedForSpecficFile.js +0 -41
  218. package/es/shared/postcss/getAllowedPostCssPlugins.js +0 -20
  219. package/es/shared/postcss/getSpecificPostCssPlugin.js +0 -38
  220. package/es/shared/postcss/runPostCssForCssFile.js +0 -25
  221. package/es/shared/pre_process/runPreProcess.js +0 -47
  222. package/es/shared/server/configWebpackDevMiddleware.js +0 -26
  223. package/es/shared/server/corsHandling.js +0 -23
  224. package/es/shared/server/getIp.js +0 -18
  225. package/es/shared/server/getServerURL.js +0 -28
  226. package/es/shared/server/httpsOptions.js +0 -36
  227. package/es/shared/server/initExpressApp.js +0 -9
  228. package/es/shared/server/initialHTMLHandling.js +0 -92
  229. package/es/shared/server/mockApiHandler.js +0 -53
  230. package/es/shared/server/mockServer.js +0 -34
  231. package/es/shared/server/serveContextFiles.js +0 -17
  232. package/es/shared/server/serverBywebpackDevMiddleware.js +0 -21
  233. package/es/shared/server/startHttpServer.js +0 -18
  234. package/es/shared/server/startHttpsServer.js +0 -26
  235. package/es/shared/server/unwanted/addHttp2Server.js +0 -32
  236. package/es/shared/server/unwanted/configWebpackDevMiddleware.js +0 -35
  237. package/es/shared/server/unwanted/mockApiSupport.js +0 -11
  238. package/es/shared/server/unwanted/websocketMockSetup.js +0 -36
  239. package/es/shared/server/urlConcat.js +0 -35
  240. package/es/shared/utils/requireLocalOrGlobal.js +0 -57
  241. package/es/shared/utils/utils.js +0 -0
  242. package/es/shared/utils/versionPrint.js +0 -9
@@ -1,13 +0,0 @@
1
- export const MODULE_TYPE = 'i18n/mini-extract';
2
- export const AUTO_PUBLIC_PATH = '__mini_i18n_extract_plugin_public_path_auto__';
3
- export const ABSOLUTE_PUBLIC_PATH = 'webpack:///mini-i18n-extract-plugin/';
4
- export const BASE_URI = 'webpack://';
5
- export const SINGLE_DOT_PATH_SEGMENT = '__mini_i18n_extract_plugin_single_dot_path_segment__';
6
- export const I18N_CHUNK_NAME_GENERATION_SEGMENT = '__mini_i18n_extract_plugin_i18n_chunk_name_generation_segment__';
7
- export const DEFAULT_FILENAME = 'i18n-chunks/[locale]/[name].[contenthash].i18n.js';
8
- export const DEFAULT_CHUNK_FILENAME = 'i18n-chunks/[locale]/[id].[contenthash].i18n.js';
9
- export const TYPES = new Set([MODULE_TYPE]);
10
- export const CODE_GENERATION_RESULT = {
11
- sources: new Map(),
12
- runtimeRequirements: new Set()
13
- };
@@ -1,15 +0,0 @@
1
- import { util } from 'webpack';
2
- export function createHash(_ref) {
3
- let {
4
- outputOptions,
5
- content
6
- } = _ref;
7
- const {
8
- hashFunction,
9
- hashDigest,
10
- hashDigestLength
11
- } = outputOptions;
12
- const hash = util.createHash(hashFunction);
13
- hash.update(content);
14
- return hash.digest(hashDigest).substring(0, hashDigestLength);
15
- }
@@ -1,72 +0,0 @@
1
- import { Template, RuntimeGlobals, RuntimeModule } from 'webpack';
2
- /* eslint-disable no-restricted-syntax */
3
-
4
- const getChunksMapObject = i18nChunks => {
5
- const obj = {};
6
-
7
- for (const chunk of i18nChunks) {
8
- obj[chunk.id] = 1;
9
- }
10
-
11
- return obj;
12
- };
13
-
14
- export function getI18nLoadingRuntimeModule(_ref) {
15
- let {
16
- getI18nChunks
17
- } = _ref;
18
-
19
- class I18nLoadingRuntimeModule extends RuntimeModule {
20
- constructor(runtimeRequirements, _ref2) {
21
- let {
22
- runtimeOptions,
23
- prefixFunc
24
- } = _ref2;
25
- super('i18n loading', 10);
26
- this.runtimeRequirements = runtimeRequirements;
27
- this.prefixFunc = prefixFunc;
28
- this.runtimeOptions = runtimeOptions;
29
- }
30
-
31
- generate() {
32
- const {
33
- chunk,
34
- runtimeRequirements,
35
- prefixFunc,
36
- compilation
37
- } = this;
38
- const {
39
- runtimeTemplate,
40
- outputOptions: {
41
- crossOriginLoading
42
- }
43
- } = compilation; // const i18nChunks = getI18nChunks(chunk, compilation);
44
- // REASON: we do it in here is in dev mode thing may change
45
- // const i18nChunks = getI18nChunks(entryRuntimeChunk);
46
-
47
- const i18nChunks = getI18nChunks(chunk);
48
- const withLoading = runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers) && i18nChunks.length > 0;
49
-
50
- if (!withLoading) {
51
- return '// no i18n chunks loading';
52
- }
53
-
54
- const chunkMap = getChunksMapObject(i18nChunks);
55
- const {
56
- attributes,
57
- scriptType,
58
- insert: insertRoot
59
- } = this.runtimeOptions;
60
- const insertPlace = typeof insertRoot === 'function' ? `(${insertRoot.toString()})(scriptTag)` : Template.asString([`var target = document.querySelector("${insertRoot}");`, 'target.parentNode.insertBefore(scriptTag, target.nextSibling);']);
61
- return Template.asString([`${prefixFunc(i18nChunks)}`, `var createI18nScriptTag = ${runtimeTemplate.basicFunction('chunkId, fullsrc, resolve, reject', ['var scriptTag = document.createElement("script");', attributes ? Template.asString(Object.entries(attributes).map(entry => {
62
- const [key, value] = entry;
63
- return `scriptTag.setAttribute(${JSON.stringify(key)}, ${JSON.stringify(value)});`;
64
- })) : '', '__webpack_require__.nc && scriptTag.setAttribute("nonce", __webpack_require__.nc)', scriptType ? `scriptTag.type = ${JSON.stringify(scriptType)};` : '', `var onScriptComplete = ${runtimeTemplate.basicFunction('event', ['// avoid mem leaks.', 'scriptTag.onerror = scriptTag.onload = null;', 'if (event.type === \'load\') {', Template.indent(['resolve();']), '} else {', Template.indent(['var errorType = event && (event.type === \'load\' ? \'missing\' : event.type);', 'var realSrc = event && event.target && event.target.src || fullsrc;', 'var err = new Error("Loading I18N chunk " + chunkId + " failed.\\n(" + realSrc + ")");', 'err.code = "I18N_CHUNK_LOAD_FAILED";', 'err.type = errorType;', 'err.request = realSrc;', 'scriptTag.parentNode.removeChild(scriptTag)', 'reject(err);']), '}'])}`, 'scriptTag.onerror = scriptTag.onload = onScriptComplete;', 'scriptTag.src = fullsrc;', crossOriginLoading ? Template.asString(['if (scriptTag.src.indexOf(window.location.origin + \'/\') !== 0) {', Template.indent(`scriptTag.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', insertRoot && insertPlace || Template.asString(['document.head.appendChild(scriptTag);']), 'return scriptTag;'])};`, `var findI18nScriptTag = ${runtimeTemplate.basicFunction('src, fullsrc', ['var existingScriptTags = document.getElementsByTagName("script");', 'for(var i = 0; i < existingScriptTags.length; i++) {', Template.indent(['var tag = existingScriptTags[i];', 'var dataSrc = tag.getAttribute("data-src") || tag.getAttribute("src");', 'if((dataSrc === src || dataSrc === fullsrc)) return tag;']), '}', 'var existingStyleTags = document.getElementsByTagName("style");', 'for(var i = 0; i < existingStyleTags.length; i++) {', Template.indent(['var tag = existingStyleTags[i];', 'var dataSrc = tag.getAttribute("data-src");', 'if(dataSrc === src || dataSrc === fullsrc) return tag;']), '}'])};`, `var loadI18nScriptTag = ${runtimeTemplate.basicFunction('chunkId', `return new Promise(${runtimeTemplate.basicFunction('resolve, reject', [`var src = ${RuntimeGlobals.require}.miniI18nF(chunkId);`, `var fullsrc = ${RuntimeGlobals.publicPath} + src;`, 'if(findI18nScriptTag(src, fullsrc)) return resolve();', 'createI18nScriptTag(chunkId, fullsrc, resolve, reject);'])});`)}`, '// object to store loaded I18N chunks', 'var installedI18nChunks = {', Template.indent(
65
- /** @type {string[]} */
66
- chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(',\n')), '};', '', `${RuntimeGlobals.ensureChunkHandlers}.miniI18n = ${runtimeTemplate.basicFunction('chunkId, promises', [`var i18nChunks = ${JSON.stringify(chunkMap)};`, 'if(installedI18nChunks[chunkId]) promises.push(installedI18nChunks[chunkId]);', 'else if(installedI18nChunks[chunkId] !== 0 && i18nChunks[chunkId]) {', Template.indent([`promises.push(installedI18nChunks[chunkId] = loadI18nScriptTag(chunkId).then(${runtimeTemplate.basicFunction('', 'installedI18nChunks[chunkId] = 0;')}, ${runtimeTemplate.basicFunction('e', ['delete installedI18nChunks[chunkId];', 'throw e;'])}));`]), '}'])};`, '']);
67
- }
68
-
69
- }
70
-
71
- return I18nLoadingRuntimeModule;
72
- }
@@ -1,23 +0,0 @@
1
- import I18nKeysIdentifer from "./I18nKeysIdentifer"; // import getI18nKeysFormModules from './utils/getI18nKeysFormModules';
2
-
3
- import { optionsHandler } from "./optionsHandler";
4
- import { I18nFilesEmitPlugin } from "./I18nFilesEmitPlugin";
5
- import { I18nRuntimeDealerPlugin } from "./I18nRuntimeDealerPlugin";
6
- export const pluginName = 'mini-i18n-extract-plugin';
7
- const pluginSymbol = Symbol(pluginName);
8
- export default class I18nExtractPlugin {
9
- constructor() {
10
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11
- // initialize options
12
- this.options = optionsHandler(options);
13
- }
14
-
15
- apply(compiler) {
16
- new I18nKeysIdentifer(this.options).apply(compiler);
17
- new I18nFilesEmitPlugin(this.options).apply(compiler);
18
- new I18nRuntimeDealerPlugin(this.options).apply(compiler);
19
- }
20
-
21
- }
22
- I18nExtractPlugin.pluginName = pluginName;
23
- I18nExtractPlugin.pluginSymbol = pluginSymbol;
@@ -1,40 +0,0 @@
1
- import ConcatenatedModule from 'webpack/lib/optimize/ConcatenatedModule';
2
- import { getChunkModules } from "./utils/getChunkModules";
3
- export function iterateModulesInChunk(_ref) {
4
- let {
5
- chunk,
6
- cb,
7
- compilation
8
- } = _ref;
9
- let canStopLoop = false;
10
-
11
- function stopLoop() {
12
- canStopLoop = true;
13
- }
14
-
15
- function iterateNestedModules(mod) {
16
- if (mod.resource) {
17
- cb({
18
- module: mod,
19
- stop: stopLoop
20
- });
21
- return canStopLoop;
22
- }
23
-
24
- if (mod instanceof ConcatenatedModule) {
25
- const {
26
- modules
27
- } = mod;
28
- return Array.from(modules).some(mod => iterateNestedModules(mod));
29
- }
30
-
31
- return canStopLoop;
32
- } // eslint-disable-next-line no-restricted-syntax
33
-
34
-
35
- for (const mod of getChunkModules(chunk, compilation)) {
36
- if (iterateNestedModules(mod)) {
37
- return;
38
- }
39
- }
40
- }
@@ -1,59 +0,0 @@
1
- /* eslint-disable no-use-before-define */
2
- import { DEFAULT_CHUNK_FILENAME, DEFAULT_FILENAME } from "./constants";
3
- import { readI18nValues } from "./readI18nValues";
4
- export function optionsHandler(options) {
5
- const {
6
- disableDefault,
7
- jsResource,
8
- propertiesFolder
9
- } = options;
10
- const {
11
- jsResourceI18nKeys,
12
- allI18nObject,
13
- locales
14
- } = readI18nValues({
15
- jsResource,
16
- propertiesFolder,
17
- disableDefault
18
- });
19
- return {
20
- filename: options.filename || DEFAULT_FILENAME,
21
- chunkFilename: options.chunkFilename || chunkNameDecider(options.filename),
22
- mainChunkName: options.mainChunkName,
23
- templateLabel: options.templateLabel,
24
- publicPath: options.publicPath,
25
- disableDefault: options.disableDefault,
26
- i18nManifestFileName: options.i18nManifestFileName,
27
- jsonpFunc: options.jsonpFunc,
28
- localeVarName: options.localeVarName,
29
- jsResource: options.jsResource,
30
- propertiesFolder: options.propertiesFolder,
31
- jsResourceI18nKeys,
32
- allI18nObject,
33
- locales,
34
- // template: (object, locale) => `window.loadI18n(${JSON.stringify(object)}, ${JSON.stringify(locale)})`,
35
- runtime: true,
36
- runtimeOptions: {
37
- insert: options.insert,
38
- scriptType: typeof options.scriptType === 'boolean' && options.scriptType === true || typeof options.scriptType === 'undefined' ? 'text/javascript' : options.scriptType,
39
- attributes: options.attributes
40
- }
41
- };
42
- }
43
-
44
- function chunkNameDecider(filename) {
45
- if (typeof filename !== 'function') {
46
- const hasName = filename.includes('[name]');
47
- const hasId = filename.includes('[id]');
48
- const hasChunkHash = filename.includes('[chunkhash]');
49
- const hasContentHash = filename.includes('[contenthash]');
50
-
51
- if (hasChunkHash || hasContentHash || hasName || hasId) {
52
- return filename;
53
- }
54
-
55
- return filename.replace(/(^|\/)([^/]*(?:\?|$))/, '$1[id].$2');
56
- }
57
-
58
- return DEFAULT_CHUNK_FILENAME;
59
- }
@@ -1,15 +0,0 @@
1
- import { MODULE_TYPE } from "./constants";
2
- export function pathCreator(filenameTemplate, compilation, data) {
3
- return compilation.getAssetPath(filenameTemplate.replace(/\[locale\]/gi, data.locale), {
4
- hash: data.hash,
5
- chunk: {
6
- id: data.chunkId,
7
- hash: data.chunkHash,
8
- contentHash: {
9
- [MODULE_TYPE]: data.contentHash
10
- },
11
- name: data.chunkName
12
- },
13
- contentHashType: MODULE_TYPE
14
- });
15
- }
@@ -1,22 +0,0 @@
1
- import { getAllI18n, getPropertiesAsJSON } from "./utils/propertiesUtils"; // gethere i18n keys and values
2
-
3
- export function readI18nValues(_ref) {
4
- let {
5
- jsResource,
6
- propertiesFolder,
7
- disableDefault
8
- } = _ref;
9
- const jsResourceI18nKeys = jsResource ? getPropertiesAsJSON(jsResource) : {};
10
- const allI18nObject = getAllI18n({
11
- folderPath: propertiesFolder,
12
- disableDefault,
13
- jsResourceI18nKeys
14
- }); // initialize base data's and plugis
15
-
16
- const locales = Object.keys(allI18nObject);
17
- return {
18
- jsResourceI18nKeys,
19
- allI18nObject,
20
- locales
21
- };
22
- }
@@ -1,35 +0,0 @@
1
- import { Template, RuntimeGlobals } from 'webpack';
2
- import { templateHashHelpers } from "./templateHashHelpers";
3
- export function templateFileName(_ref) {
4
- let {
5
- compilation,
6
- dynamicFilename,
7
- localeVarName,
8
- chunks,
9
- contentHashes
10
- } = _ref;
11
- const MODULE_TYPE = 'text/mini-i18n';
12
- const {
13
- mapExpr,
14
- mapExprWithLength
15
- } = templateHashHelpers(chunks); // "i18n-chunk/[locale]/[name].[chunkhash].js"
16
-
17
- const i18nURLPathTemplate = compilation.getPath(JSON.stringify(dynamicFilename).replace(/\[locale\]/gi, '"+ locale +"'), {
18
- hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
19
- hashWithLength: length => `" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
20
- chunk: {
21
- id: '" + chunkId + "',
22
- hash: mapExpr(c => c.renderedHash),
23
- hashWithLength: mapExprWithLength(c => c.renderedHash),
24
- name: mapExpr(c => c.name || c.id),
25
- contentHash: {
26
- [MODULE_TYPE]: mapExpr(c => contentHashes[c.id])
27
- },
28
- contentHashWithLength: {
29
- [MODULE_TYPE]: mapExprWithLength(c => contentHashes[c.id])
30
- }
31
- },
32
- contentHashType: MODULE_TYPE
33
- });
34
- return Template.asString([`${RuntimeGlobals.require}.miniI18nF = function(chunkId){var locale = (${localeVarName});return (${i18nURLPathTemplate})}`]);
35
- }
@@ -1,70 +0,0 @@
1
- /**
2
- * this function will be used for chunk name, chunk hash, contentHash
3
- * in these, sometime chunk name and chunk id same for some chunkss so below logic has little towek
4
- * @param {Chunk} chunks
5
- * @returns { mapExpr, mapExprWithLength }
6
- */
7
- export function templateHashHelpers(chunks) {
8
- /**
9
- * @param {function(Chunk): string | number} fn function from chunk to value
10
- * @returns {string} code with static mapping of results of fn
11
- */
12
- const createMap = fn => {
13
- const obj = {};
14
- let useId = false;
15
- let lastKey;
16
- let entries = 0; // eslint-disable-next-line no-restricted-syntax
17
-
18
- for (const c of chunks) {
19
- const value = fn(c);
20
-
21
- if (value === c.id) {
22
- useId = true;
23
- } else {
24
- obj[c.id] = value;
25
- lastKey = c.id;
26
- entries++;
27
- }
28
- }
29
-
30
- if (entries === 0) {
31
- return 'chunkId';
32
- }
33
-
34
- if (entries === 1) {
35
- return useId ? `(chunkId === ${JSON.stringify(lastKey)} ? ${JSON.stringify(obj[lastKey])} : chunkId)` : JSON.stringify(obj[lastKey]);
36
- }
37
-
38
- return useId ? `(${JSON.stringify(obj)}[chunkId] || chunkId)` : `${JSON.stringify(obj)}[chunkId]`;
39
- };
40
- /**
41
- * @param {function(Chunk): string | number} fn function from chunk to value
42
- * @returns {string} code with static mapping of results of fn for including in quoted string
43
- */
44
-
45
-
46
- const mapExpr = fn => `" + ${createMap(fn)} + "`;
47
- /**
48
- * @param {function(Chunk): string | number} fn function from chunk to value
49
- * @returns {function(number): string} function which generates code with static mapping of results of fn for including in quoted string for specific length
50
- */
51
-
52
-
53
- const mapExprWithLength = fn => length => // console.log('called with lentch', length),
54
- `" + ${createMap(c => `${fn(c)}`.slice(0, length))} + "`;
55
-
56
- return {
57
- mapExpr,
58
- mapExprWithLength
59
- };
60
- }
61
- /**
62
- function mapExpr(fn) {
63
- const obj = {};
64
- // eslint-disable-next-line no-restricted-syntax
65
- for (const c of chunks) {
66
- obj[c.id] = fn(c);
67
- }
68
- return `(${JSON.stringify(obj)})[chunkId]`;
69
- }
70
- */
@@ -1,56 +0,0 @@
1
- import { walk } from 'estree-walker';
2
- export function collectI18nKeysfromAST(ast, allI18n) {
3
- const i18nKeys = {};
4
- walk(ast, {
5
- enter(node) {
6
- if (node.type === 'Literal') {
7
- if ((node.raw[0] === '\'' || node.raw[0] === '"') && Object.hasOwnProperty.call(allI18n, node.value)) {
8
- i18nKeys[node.value] = allI18n[node.value];
9
- }
10
- }
11
- }
12
-
13
- });
14
- return Object.keys(i18nKeys);
15
- }
16
- const prefixI18nComment = 'I18N';
17
- const prefixI18nComment1 = 'dynamic-i18n-key';
18
-
19
- function getI18nKeysFromComment(comment) {
20
- const commentString = comment.value.trim();
21
- let i18nKeyStr;
22
-
23
- if (commentString.startsWith(prefixI18nComment)) {
24
- i18nKeyStr = commentString.slice(prefixI18nComment.length).trim();
25
- } else if (commentString.startsWith(prefixI18nComment1)) {
26
- i18nKeyStr = commentString.slice(prefixI18nComment1.length).trim();
27
- }
28
-
29
- if (!i18nKeyStr) {
30
- return [];
31
- }
32
-
33
- const i18nKeys = i18nKeyStr.split(',');
34
- return i18nKeys;
35
- } // export function fromComments(comments, allI18n) {
36
-
37
-
38
- export function collectI18nKeysfromComments(comments, allI18n) {
39
- // TODO: need to implement
40
- const i18nKeys = {};
41
- /* eslint-disable no-restricted-syntax */
42
-
43
- for (const comment of comments) {
44
- const keys = getI18nKeysFromComment(comment);
45
-
46
- for (const key of keys) {
47
- if (key && allI18n[key]) {
48
- i18nKeys[key] = allI18n[key];
49
- }
50
- }
51
- }
52
- /* eslint-enable no-restricted-syntax */
53
-
54
-
55
- return Object.keys(i18nKeys);
56
- }
@@ -1,6 +0,0 @@
1
- export function getChunkModules(chunk, compilation) {
2
- const {
3
- chunkGraph
4
- } = compilation || {};
5
- return typeof chunkGraph !== 'undefined' ? chunkGraph.getChunkModules(chunk) : chunk.modulesIterable;
6
- }
@@ -1,10 +0,0 @@
1
- // export const REGEXP_CHUNKHASH = /\[chunkhash(?::(\d+))?\]/gi;
2
- // export const REGEXP_HASH = /\[hash(?::(\d+))?\]/gi;
3
- // export const REGEXP_NAME = /\[name\]/gi;
4
- // export const REGEXP_PLACEHOLDERS = /\[(name|id|chunkhash)\]/gi;
5
- // TODO: want to choose file type for i18n load
6
- export const REGEXP_CONTENTHASH = /\[contenthash(?::(\d+))?\]/gi;
7
- export function hasContentHash(filenameTemplate) {
8
- REGEXP_CONTENTHASH.lastIndex = 0;
9
- return REGEXP_CONTENTHASH.test(filenameTemplate);
10
- }
@@ -1,2 +0,0 @@
1
- export * from "./collectI18nKeys";
2
- export * from "./propertiesUtils";
@@ -1,121 +0,0 @@
1
- import { readFileSync, readdirSync } from 'fs';
2
- import { join } from 'path';
3
- import { joinWithAppPath } from "../../../../../constants";
4
- export function decodeUnicodeEscapes(str) {
5
- return str.replace(/\\u([0-9A-Fa-f]{4})/g, (_, code) => String.fromCharCode(parseInt(code, 16)));
6
- }
7
-
8
- function isComment(line) {
9
- return line[0] === '#';
10
- }
11
-
12
- export function getPropertiesAsJSON(filePath) {
13
- try {
14
- const data = readFileSync(filePath);
15
- const source = data.toString();
16
- const i18nObj = {};
17
- source.split(/\r?\n\r?/).forEach(fline => {
18
- const line = fline.trim();
19
-
20
- if (!line || isComment(line)) {
21
- return;
22
- }
23
-
24
- const ind = line.indexOf('=');
25
- const key = line.slice(0, ind).replace(/\\ /g, ' ');
26
- const value = line.slice(ind + 1);
27
-
28
- if (key && value) {
29
- i18nObj[key] = value;
30
- }
31
- }, {});
32
- return i18nObj;
33
- } catch (err) {
34
- return {};
35
- }
36
- } // TODO: need to make it as custom option and dynamic
37
-
38
- function getLang(file) {
39
- const underScoreIndex = file.indexOf('_');
40
- let language = 'en_US';
41
-
42
- if (underScoreIndex !== -1) {
43
- language = file.substring(underScoreIndex + 1);
44
- language = language.slice(0, language.indexOf('.'));
45
- }
46
-
47
- return language;
48
- }
49
-
50
- export function getAllI18n(_ref) {
51
- let {
52
- folderPath,
53
- disableDefault,
54
- jsResourceI18nKeys,
55
- exclude = /^[^_]+$/,
56
- include = /\.properties$/
57
- } = _ref;
58
-
59
- try {
60
- const files = readdirSync(folderPath, 'utf8');
61
- const allLangI18n = {};
62
- const context = joinWithAppPath(folderPath);
63
- files.forEach(file => {
64
- const filePath = join(context, file);
65
-
66
- if (exclude.test(filePath) || !include.test(filePath)) {
67
- return;
68
- }
69
-
70
- const i18n = getPropertiesAsJSON(filePath);
71
- allLangI18n[getLang(file)] = disableDefault ? i18n : { ...jsResourceI18nKeys,
72
- ...i18n
73
- };
74
- });
75
- return allLangI18n;
76
- } catch (err) {
77
- console.log(err);
78
- return {};
79
- }
80
- }
81
- export function jsonToString(json, keySeperator) {
82
- let str = '{';
83
- const keys = Object.keys(json);
84
- keys.forEach((key, i) => {
85
- const value = json[key];
86
-
87
- if (!value) {
88
- return;
89
- }
90
-
91
- str += `"${keySeperator ? key.replace(/(\.|\\(\s+))/g, keySeperator) : key}":"${value.replace(/.?"/g, match => {
92
- if (match[0] === '\\') {
93
- return match;
94
- }
95
-
96
- if (match.length === 2) {
97
- return `${match[0]}\\${match[1]}`;
98
- }
99
-
100
- return `\\${match}`;
101
- }).replace(/(\r\n|\n|\r)/g, '')}"`;
102
-
103
- if (i !== keys.length - 1) {
104
- str += ',';
105
- }
106
- });
107
- str += '}';
108
- return str;
109
- }
110
- /**
111
- * not useable due to special charector
112
- *
113
- return `{${Object.keys(data).map(key => `"${key}": "${data[key]}"`).join(",")}}`
114
- // return JSON.stringify(data);
115
- let str = "{";
116
- for (const key of Object.keys(data)) {
117
- str+= `"${key}": "${data[key]}",`
118
- }
119
- str+="}";
120
- return str;
121
- */
@@ -1,85 +0,0 @@
1
- import HtmlWebpackPlugin from 'html-webpack-plugin';
2
- const pluginName = 'InitialHtmlPlugin';
3
- export class InitialHtmlPlugin {
4
- constructor(options) {
5
- this.options = options;
6
- }
7
-
8
- getBaseName(str) {
9
- const fileName = str.split("/").pop();
10
- const parts = fileName.split("."); // Find index of the hash-like segment
11
-
12
- const hashIndex = parts.findIndex(p => /^[0-9a-f_]{20,}$/i.test(p)); // If a hash is found, return everything before it
13
-
14
- if (hashIndex < 0) {
15
- console.error('this initial file dont have a hash');
16
- return parts.slice(0, -1).join(".");
17
- }
18
-
19
- return parts.slice(0, hashIndex).join("."); // Otherwise fallback: remove only ".js"
20
- }
21
-
22
- apply(compiler) {
23
- const {
24
- filename,
25
- template,
26
- minify,
27
- inject,
28
- mainChunkName,
29
- enableSubResourceIntegrity
30
- } = this.options;
31
- new HtmlWebpackPlugin({
32
- filename,
33
- template,
34
- minify,
35
- chunks: [mainChunkName],
36
- inject,
37
- scriptLoading: 'defer'
38
- }).apply(compiler);
39
- compiler.hooks.thisCompilation.tap(pluginName, compilation => {
40
- HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tapAsync(pluginName, (data, cb) => {
41
- const headTags = [];
42
- const bodyTags = [];
43
- data.headTags.forEach(tag => {
44
- const url = tag.attributes?.src || tag.attributes?.href;
45
- let chunkName;
46
-
47
- const addIntegrity = (tag, suffix) => {
48
- if (enableSubResourceIntegrity && chunkName) {
49
- Object.assign(tag.attributes, {
50
- integrity: `{{--${chunkName}-${suffix}-integrity}}`
51
- });
52
- }
53
- };
54
-
55
- if (enableSubResourceIntegrity) {
56
- chunkName = this.getBaseName(url);
57
- }
58
-
59
- Object.assign(tag.attributes, {
60
- nonce: '{{--CSP-nonce}}',
61
- crossorigin: "anonymous"
62
- });
63
-
64
- if (tag.tagName === 'link') {
65
- addIntegrity(tag, 'css');
66
- headTags.push(tag);
67
- } else {
68
- if (url.endsWith('.i18n.js')) {
69
- addIntegrity(tag, 'i18n');
70
- } else {
71
- addIntegrity(tag, 'js');
72
- }
73
-
74
- bodyTags.push(tag);
75
- }
76
- });
77
- cb(null, { ...data,
78
- headTags,
79
- bodyTags
80
- });
81
- });
82
- });
83
- }
84
-
85
- }