@zohodesk/react-cli 1.1.29-exp.1 → 1.1.29-exp.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/lib/babel/babel-option-utils/babel-preset-react-option.js +0 -3
  2. package/lib/babel/cmjs-plugins-presets.js +1 -8
  3. package/lib/babel/es-plugins-presets.js +1 -8
  4. package/lib/common/buildEs.js +1 -0
  5. package/lib/common/getEntries.js +2 -13
  6. package/lib/common/getPublicPathConfig.js +0 -6
  7. package/lib/common/index.js +1 -6
  8. package/lib/common/runPreProcess.js +6 -15
  9. package/lib/common/splitChunks.js +2 -21
  10. package/lib/common/sslcertUpdater.js +7 -18
  11. package/lib/common/templateParameters.js +0 -2
  12. package/lib/common/testPattern.js +10 -21
  13. package/lib/common/valueReplacer.js +1 -16
  14. package/lib/configs/jest.config.js +1 -10
  15. package/lib/configs/libAlias.js +8 -14
  16. package/lib/configs/resolvers.js +4 -14
  17. package/lib/configs/webpack.component.umd.config.js +1 -6
  18. package/lib/configs/webpack.css.umd.config.js +6 -14
  19. package/lib/configs/webpack.dev.config.js +1 -14
  20. package/lib/configs/webpack.docs.config.js +1 -9
  21. package/lib/configs/webpack.impact.config.js +1 -8
  22. package/lib/configs/webpack.prod.config.js +4 -17
  23. package/lib/constants.js +9 -18
  24. package/lib/deprecationLogger.js +0 -7
  25. package/lib/hooks/docsProptypeHook.js +4 -8
  26. package/lib/jest/commitedFilesResult.js +4 -46
  27. package/lib/jest/coverageCollector.js +1 -12
  28. package/lib/jest/jsonMaker.js +0 -6
  29. package/lib/jest/preProcessors/cssPreprocessor.js +1 -9
  30. package/lib/jest/preProcessors/jsPreprocessor.js +1 -6
  31. package/lib/jest/preProcessors/otherFilesPreprocessor.js +1 -4
  32. package/lib/jest/result.js +1 -23
  33. package/lib/jest/run.js +7 -18
  34. package/lib/jest/setup.js +8 -60
  35. package/lib/loaderUtils/configsAssetsLoaders.js +2 -12
  36. package/lib/loaderUtils/getCSSLoaders.js +10 -22
  37. package/lib/loaderUtils/getDevJsLoaders.js +4 -13
  38. package/lib/loaderUtils/index.js +1 -4
  39. package/lib/loaderUtils/tests/windowsModification.test.js +0 -1
  40. package/lib/loaderUtils/windowsModification.js +2 -3
  41. package/lib/loaders/__test__/markdownLoader.spec.js +0 -1
  42. package/lib/loaders/composeLoader.js +13 -37
  43. package/lib/loaders/docsLoader.js +1 -12
  44. package/lib/loaders/docsPropsLoader.js +4 -8
  45. package/lib/loaders/enhancedReactLiveConverter.js +2 -23
  46. package/lib/loaders/fileBountryLoader.js +1 -3
  47. package/lib/loaders/fileLoader.js +12 -23
  48. package/lib/loaders/markdownLoader.js +14 -19
  49. package/lib/loaders/reactLiveConvertor.js +5 -15
  50. package/lib/loaders/scriptInstrumentLoader.js +7 -16
  51. package/lib/loaders/selectorMappingLoader.js +7 -26
  52. package/lib/loaders/workerLoader.js +9 -24
  53. package/lib/logger.js +0 -4
  54. package/lib/middlewares/HMRMiddleware.js +13 -27
  55. package/lib/middlewares/SSTMiddleware.js +1 -5
  56. package/lib/pluginUtils/configHtmlWebpackPlugins.js +1 -24
  57. package/lib/pluginUtils/getDevPlugins.js +9 -42
  58. package/lib/pluginUtils/getDocsPlugins.js +3 -13
  59. package/lib/pluginUtils/getLibraryImactPlugins.js +5 -6
  60. package/lib/pluginUtils/getLibraryPlugins.js +2 -8
  61. package/lib/pluginUtils/getProdPlugins.js +8 -47
  62. package/lib/pluginUtils/getServerPlugins.js +2 -8
  63. package/lib/pluginUtils/getUMDCSSPlugins.js +2 -10
  64. package/lib/pluginUtils/getUMDComponentPlugins.js +2 -10
  65. package/lib/pluginUtils/index.js +1 -9
  66. package/lib/plugins/CdnChangePlugin.js +2 -18
  67. package/lib/plugins/CleanupStatsPlugin.js +0 -5
  68. package/lib/plugins/CssOrderControlPlugin.js +3 -6
  69. package/lib/plugins/CustomAttributePlugin.js +14 -19
  70. package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +3 -23
  71. package/lib/plugins/EFCPlugin.js +20 -34
  72. package/lib/plugins/EFCTemplatePlugin.js +19 -30
  73. package/lib/plugins/EfcResourceCleanupPlugin.js +0 -3
  74. package/lib/plugins/EventsHandlingPlugin.js +2 -4
  75. package/lib/plugins/I18NInjectIntoIndexPlugin.js +11 -37
  76. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +10 -15
  77. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
  78. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +12 -25
  79. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +55 -133
  80. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +12 -23
  81. package/lib/plugins/I18nSplitPlugin/index.js +13 -24
  82. package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +64 -58
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
  84. package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +10 -29
  85. package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +8 -19
  86. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
  87. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
  88. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +1 -8
  89. package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
  90. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -20
  91. package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +0 -1
  92. package/lib/plugins/ManifestPlugin.js +1 -18
  93. package/lib/plugins/MinifyPlugin.js +1 -10
  94. package/lib/plugins/ModuleStatsPlugin.js +1 -24
  95. package/lib/plugins/OptimizeJSPlugin.js +2 -10
  96. package/lib/plugins/PublicPathCallbackPlugin.js +1 -12
  97. package/lib/plugins/PublicPathChangePlugin.js +6 -39
  98. package/lib/plugins/ReportGeneratePlugin.js +5 -32
  99. package/lib/plugins/RequireVariablePublicPlugin.js +1 -8
  100. package/lib/plugins/ResourceHintsPlugin.js +4 -13
  101. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
  102. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +10 -17
  103. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
  104. package/lib/plugins/ScriptInstrumentPlugin.js +1 -8
  105. package/lib/plugins/SelectorPlugin.js +6 -32
  106. package/lib/plugins/ServiceWorkerPlugin.js +5 -22
  107. package/lib/plugins/ShadowDOMSupportPlugin.js +4 -41
  108. package/lib/plugins/SourceMapHookPlugin.js +2 -12
  109. package/lib/plugins/StatsPlugin.js +0 -14
  110. package/lib/plugins/TPHashMappingPlugin.js +3 -18
  111. package/lib/plugins/UnusedFilesFindPlugin.js +4 -39
  112. package/lib/plugins/VariableConversionCollector.js +15 -42
  113. package/lib/plugins/index.js +1 -20
  114. package/lib/plugins/libraryImpactPlugin.js +1 -33
  115. package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +306 -0
  116. package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +363 -0
  117. package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +694 -0
  118. package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +1258 -0
  119. package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +542 -0
  120. package/lib/plugins/newi18nsplitplugin/18nplugin.js +974 -0
  121. package/lib/plugins/newi18nsplitplugin/ChunkManager.js +131 -0
  122. package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +59 -0
  123. package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +262 -0
  124. package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +166 -0
  125. package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +111 -0
  126. package/lib/plugins/newi18nsplitplugin/KeyCollector.js +163 -0
  127. package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +88 -0
  128. package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +101 -0
  129. package/lib/plugins/newi18nsplitplugin/constants.js +162 -0
  130. package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +78 -0
  131. package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +22 -0
  132. package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +18 -0
  133. package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +580 -0
  134. package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +54 -0
  135. package/lib/plugins/utils/classHandling.js +0 -6
  136. package/lib/plugins/utils/fileHandling.js +6 -15
  137. package/lib/plugins/utils/tests/fileHandling.test.js +0 -4
  138. package/lib/plugins/variableConvertorUtils.js +14 -29
  139. package/lib/plugins/webpackwatchrunplugin.js +0 -5
  140. package/lib/postcss-plugins/EmptyPlugin.js +3 -4
  141. package/lib/postcss-plugins/ExcludePlugin.js +1 -5
  142. package/lib/postcss-plugins/IncludePlugin.js +1 -5
  143. package/lib/postcss-plugins/RTLSplitPlugin.js +14 -27
  144. package/lib/postcss-plugins/SelectorReplace.js +1 -16
  145. package/lib/postcss-plugins/ValueReplacer.js +7 -6
  146. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
  147. package/lib/postcss-plugins/__test__/selectorReplace.test.js +6 -3
  148. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +2 -5
  149. package/lib/postcss-plugins/hoverActivePlugin.js +31 -67
  150. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -7
  151. package/lib/postcss-plugins/variableModificationPlugin/index.js +28 -49
  152. package/lib/schemas/index.js +3 -9
  153. package/lib/servers/clusterHubServer.js +1 -11
  154. package/lib/servers/devBuild.js +14 -26
  155. package/lib/servers/docsServer.js +1 -3
  156. package/lib/servers/docsServerCore.js +1 -22
  157. package/lib/servers/getCliPath.js +0 -9
  158. package/lib/servers/helpServer.js +1 -6
  159. package/lib/servers/httpsOptions.js +2 -8
  160. package/lib/servers/impactServer.js +3 -35
  161. package/lib/servers/mockserver.js +1 -10
  162. package/lib/servers/nowatchserver.js +12 -37
  163. package/lib/servers/requireLocalOrGlobal.js +6 -17
  164. package/lib/servers/scrServer.js +14 -21
  165. package/lib/servers/server.js +6 -36
  166. package/lib/servers/ssServer.js +1 -17
  167. package/lib/templates/CoverageScriptTemplate.js +0 -14
  168. package/lib/templates/WMSTemplate.js +7 -13
  169. package/lib/templates/linterConstant.js +2 -4
  170. package/lib/utils/babelPresets.js +3 -7
  171. package/lib/utils/clean.js +3 -9
  172. package/lib/utils/copy.js +1 -7
  173. package/lib/utils/copyTimezones.js +1 -9
  174. package/lib/utils/createEventStream.js +1 -6
  175. package/lib/utils/cssClassNameGenerate.js +10 -30
  176. package/lib/utils/cssURLReplacer.js +1 -22
  177. package/lib/utils/dependencyPostPublish.js +1 -10
  178. package/lib/utils/deprecationSupport.js +7 -32
  179. package/lib/utils/fileUtils.js +1 -28
  180. package/lib/utils/folderIterator.js +2 -13
  181. package/lib/utils/getComponents.js +0 -21
  182. package/lib/utils/getCurrentBranch.js +0 -5
  183. package/lib/utils/getDependenciesImpactList.js +1 -22
  184. package/lib/utils/getFileType.js +2 -10
  185. package/lib/utils/getHash.js +1 -8
  186. package/lib/utils/getIp.js +0 -2
  187. package/lib/utils/getOptions.js +16 -53
  188. package/lib/utils/getServerURL.js +1 -10
  189. package/lib/utils/index.js +4 -51
  190. package/lib/utils/init.js +0 -1
  191. package/lib/utils/initPreCommitHook.js +7 -30
  192. package/lib/utils/jsonHelper.js +3 -22
  193. package/lib/utils/libraryImpactConfig.js +2 -5
  194. package/lib/utils/lint/addScripts.js +2 -5
  195. package/lib/utils/lint/checkExistingConfig.js +3 -12
  196. package/lib/utils/lint/copyConfigs.js +0 -3
  197. package/lib/utils/lint/index.js +0 -9
  198. package/lib/utils/lint/lintScripts.js +0 -1
  199. package/lib/utils/lint/lintSetup.js +3 -4
  200. package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
  201. package/lib/utils/lint/question.js +0 -7
  202. package/lib/utils/lintReporter.js +0 -20
  203. package/lib/utils/log.js +0 -1
  204. package/lib/utils/mailSender.js +1 -8
  205. package/lib/utils/object-manipulation.js +1 -17
  206. package/lib/utils/pullOrigin.js +0 -4
  207. package/lib/utils/reinstallDependencies.js +1 -29
  208. package/lib/utils/removeAttributes.js +1 -8
  209. package/lib/utils/repoClone.js +3 -28
  210. package/lib/utils/request.js +0 -12
  211. package/lib/utils/rtl.js +5 -17
  212. package/lib/utils/selectorReplacer.js +10 -16
  213. package/lib/utils/setEnvVariables.js +0 -2
  214. package/lib/utils/ssTestHack.js +1 -11
  215. package/lib/utils/switchBranch.js +0 -5
  216. package/lib/utils/typeCheck.js +0 -1
  217. package/lib/utils/urlConcat.js +0 -4
  218. package/lib/utils/useExitCleanup.js +9 -10
  219. package/lib/utils/variableConverter.js +22 -31
  220. package/{npm-shrinkwrap.json → package-lock.json} +2098 -1999
  221. package/package.json +1 -1
@@ -4,17 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _utils = require("./utils");
9
-
10
- const pluginName = 'I18nDebugPlugin'; // this plugin only for debug related purpose
8
+ const pluginName = 'I18nDebugPlugin';
9
+ // this plugin only for debug related purpose
11
10
 
12
11
  class I18nDebugPlugin {
13
12
  constructor(jsResourceI18nKeys) {
14
13
  this.jsResourceI18nKeys = jsResourceI18nKeys;
15
14
  this.warnings = [];
16
15
  }
17
-
18
16
  apply(compiler) {
19
17
  compiler.hooks.thisCompilation.tap(pluginName, (compilation, compilationParams) => {
20
18
  // TEMP : only for debugging purpose
@@ -25,20 +23,19 @@ class I18nDebugPlugin {
25
23
  if (!this.compilationParams || this.compilationParams.normalModuleFactory === factory) {
26
24
  return;
27
25
  }
28
-
29
26
  const handler = parser => {
30
27
  parser.hooks.program.tap(pluginName, (ast, commmets) => {
31
28
  const {
32
29
  module
33
- } = parser.state; //
34
-
30
+ } = parser.state;
31
+ //
35
32
  if (!(module && /\.jsx?$/.test(module.resource))) {
36
33
  return;
37
- } // i18n grep proper contract regex
38
-
39
-
34
+ }
35
+ // i18n grep proper contract regex
40
36
  let i18nKeys = (0, _utils.collectI18nKeysfromAST)(ast, this.jsResourceI18nKeys);
41
- i18nKeys = i18nKeys.concat( // i18n grep proper contract regex
37
+ i18nKeys = i18nKeys.concat(
38
+ // i18n grep proper contract regex
42
39
  (0, _utils.collectI18nKeysfromComments)(commmets, this.jsResourceI18nKeys));
43
40
  i18nKeys.length && this.warnings.push({
44
41
  message: 'skiped i18n keys',
@@ -48,12 +45,10 @@ class I18nDebugPlugin {
48
45
  });
49
46
  });
50
47
  };
51
-
52
48
  factory.hooks.parser.for('javascript/auto').tap(pluginName, handler);
53
- factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler); // factory.hooks.parser.for('javascript/esm').tap(pluginName, handler);
49
+ factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler);
50
+ // factory.hooks.parser.for('javascript/esm').tap(pluginName, handler);
54
51
  });
55
52
  }
56
-
57
53
  }
58
-
59
54
  exports.default = I18nDebugPlugin;
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.I18nDependencyTemplate = exports.I18nDependency = void 0;
7
-
8
7
  var _webpack = require("webpack");
9
-
10
8
  // const webpack = require('webpack');
9
+
11
10
  class I18nDependency extends _webpack.Dependency {
12
11
  constructor({
13
12
  identifier,
@@ -19,26 +18,21 @@ class I18nDependency extends _webpack.Dependency {
19
18
  this.i18nKeys = i18nKeys;
20
19
  this.context = context;
21
20
  }
22
-
23
21
  getResourceIdentifier() {
24
22
  return `i18n-module-${this.identifier}-${this.identifierIndex}`;
25
23
  }
26
-
27
24
  }
28
-
29
25
  exports.I18nDependency = I18nDependency;
30
-
31
26
  class I18nDependencyTemplate {
32
27
  //eslint-disable-next-line no-empty-function
33
- apply() {} // apply(dep, source) {
28
+ apply() {}
29
+ // apply(dep, source) {
34
30
  // if (typeof dep.range === "number") {
35
31
  // source.insert(0, `/* comment by I18nSplitPlugin , i18n keys = ${JSON.stringify(dep.i18nKeys)} */`);
36
32
  // return;
37
33
  // }
34
+
38
35
  // source.replace(dep.range[0], dep.range[1] - 1, dep.expression);
39
36
  // }
40
-
41
-
42
37
  }
43
-
44
38
  exports.I18nDependencyTemplate = I18nDependencyTemplate;
@@ -4,13 +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
  var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nKeysIdentifer"));
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
  /**
15
11
  * this plugin for the download i18n files
16
12
  * So, if need to downoad i18n in browser this plugin handle that
@@ -29,9 +25,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
29
25
  * some thing missing in this definetion
30
26
  *
31
27
  */
28
+
32
29
  const pluginName = 'DownloadLogicOfI18n';
33
30
  const MODULE_TYPE = 'json/i18n';
34
-
35
31
  class I18nDownlodLogic {
36
32
  constructor({
37
33
  filenameTemplate,
@@ -47,7 +43,6 @@ class I18nDownlodLogic {
47
43
  };
48
44
  this.finalChunkIds = new Map();
49
45
  }
50
-
51
46
  captureChunkIds(compilation) {
52
47
  this.finalChunkIds.clear();
53
48
  compilation.chunks.forEach(chunk => {
@@ -57,54 +52,48 @@ class I18nDownlodLogic {
57
52
  });
58
53
  });
59
54
  }
60
-
61
55
  getI18nChunkObject(mainChunk) {
62
56
  const obj = {};
63
-
64
57
  for (const chunk of mainChunk.getAllAsyncChunks()) {
65
58
  const finalChunkId = chunk.id;
66
-
67
59
  if (_I18nKeysIdentifer.default.isChunkHasI18n(chunk)) {
68
60
  // Store using the final chunk ID
69
- obj[finalChunkId] = 1; // Also keep track of which chunks have i18n content
61
+ obj[finalChunkId] = 1;
70
62
 
63
+ // Also keep track of which chunks have i18n content
71
64
  this.finalChunkIds.set(finalChunkId, {
72
65
  original: chunk.id,
73
66
  name: chunk.name || null
74
67
  });
75
68
  }
76
69
  }
77
-
78
70
  return obj;
79
71
  }
80
-
81
72
  addDownloadLogicOfI18nInMainTemplate(mainTemplate) {
82
73
  // Extend localVars to create a container for tracking loaded i18n chunks.
83
74
  mainTemplate.hooks.localVars.tap(pluginName, (source, mainChunk) => {
84
75
  const chunkMap = this.getI18nChunkObject(mainChunk);
85
-
86
76
  if (!Object.keys(chunkMap).length) {
87
77
  return source;
88
78
  }
89
-
90
79
  return _webpack.Template.asString([source, '', '// Object to store loaded I18N chunks', '// Using final chunk IDs from webpack', 'var installedI18nChunks = {', _webpack.Template.indent(mainChunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(',\n')), '};']);
91
- }); // Extend requireEnsure so that whenever a JS chunk is requested,
92
- // we also download its associated i18n file (if available).
80
+ });
93
81
 
82
+ // Extend requireEnsure so that whenever a JS chunk is requested,
83
+ // we also download its associated i18n file (if available).
94
84
  mainTemplate.hooks.requireEnsure.tap(pluginName, (source, mainChunk, hash) => {
95
85
  const chunkMap = this.getI18nChunkObject(mainChunk);
96
-
97
86
  if (!Object.keys(chunkMap).length) {
98
87
  return source;
99
88
  }
100
-
101
89
  const {
102
90
  crossOriginLoading
103
91
  } = mainTemplate.outputOptions;
104
92
  const {
105
93
  localeVarName = 'document.documentElement.lang'
106
- } = this.options; // Use the provided publicPath or fallback to the one provided by Webpack.
94
+ } = this.options;
107
95
 
96
+ // Use the provided publicPath or fallback to the one provided by Webpack.
108
97
  const publicPath = this.publicPath ? JSON.stringify(this.publicPath) : `${mainTemplate.requireFn}.p`;
109
98
  return _webpack.Template.asString([source, `
110
99
  (function() {
@@ -178,20 +167,20 @@ class I18nDownlodLogic {
178
167
  `]);
179
168
  });
180
169
  }
170
+
181
171
  /**
182
172
  * Applies the plugin by tapping into the appropriate Webpack hooks.
183
173
  * Now captures final chunk IDs after compilation is complete.
184
174
  *
185
175
  * @param {Compiler} compiler - The Webpack compiler instance.
186
176
  */
187
-
188
-
189
177
  apply(compiler) {
190
178
  // First capture final chunk IDs after compilation
191
179
  compiler.hooks.afterCompile.tap(pluginName, compilation => {
192
180
  this.captureChunkIds(compilation);
193
- }); // Then inject download logic in thisCompilation
181
+ });
194
182
 
183
+ // Then inject download logic in thisCompilation
195
184
  compiler.hooks.thisCompilation.tap(pluginName, compilation => {
196
185
  // console.log(`${pluginName}: Adding download logic with final chunk IDs`);
197
186
  const {
@@ -200,7 +189,5 @@ class I18nDownlodLogic {
200
189
  this.addDownloadLogicOfI18nInMainTemplate(mainTemplate);
201
190
  });
202
191
  }
203
-
204
192
  }
205
-
206
193
  exports.default = I18nDownlodLogic;
@@ -4,30 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _webpackSources = require("webpack-sources");
9
-
10
8
  var _utils = require("./utils");
11
-
12
9
  var _getI18nKeysFormModules = _interopRequireDefault(require("./utils/getI18nKeysFormModules"));
13
-
14
10
  var _createRegularManifest = require("./utils/createRegularManifest");
15
-
16
11
  var _createMetaManifest = require("./utils/createMetaManifest");
17
-
18
12
  var _applyMetaManifest = require("./utils/applyMetaManifest");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
14
  /**
23
15
  * this plugin was creating the chunk specific i18n chunk's.
24
16
  */
25
- // this plugin's kick starter is apply method
17
+
26
18
  const pluginName = 'I18nFilesEmitter';
27
19
  const MODULE_TYPE = 'json/i18n';
28
-
29
20
  const i18ntype = locale => `${MODULE_TYPE}/${locale}`;
30
-
31
21
  class I18nFilesEmitter {
32
22
  constructor({
33
23
  allI18nObject,
@@ -37,8 +27,7 @@ class I18nFilesEmitter {
37
27
  jsonpFunc,
38
28
  i18nMetaManifestFileName,
39
29
  entryPointNames = ['main'],
40
- masterChunkFileName = 'master.i18n.js',
41
- publicPath
30
+ masterChunkFileName = 'master.i18n.js'
42
31
  }) {
43
32
  this.locales = locales;
44
33
  this.allI18nObject = allI18nObject;
@@ -46,7 +35,7 @@ class I18nFilesEmitter {
46
35
  this.jsonpFunc = jsonpFunc;
47
36
  this.prevHashes = {};
48
37
  this.i18nManifestFileName = i18nManifestFileName;
49
- this.i18nMetaManifestFileName = i18nMetaManifestFileName || 'metaManifest.json';
38
+ this.i18nMetaManifestFileName = i18nMetaManifestFileName || 'i18n-chunk/metaManifest.json';
50
39
  this.regularManifest = {};
51
40
  this.detailedManifest = {};
52
41
  this.entryPointNames = Array.isArray(entryPointNames) ? entryPointNames : [entryPointNames];
@@ -59,16 +48,10 @@ class I18nFilesEmitter {
59
48
  this.movedKeys = new Set();
60
49
  this.entryPointKeys = new Set();
61
50
  this.combinedChunks = {};
62
- this.publicPath = publicPath; // Add a map to store module ID mappings
63
-
64
- this.moduleIdMap = new Map(); // Map to track which modules belong to which chunks
65
-
66
- this.moduleToChunks = new Map(); // Store original resource paths for stable identification
67
-
51
+ this.moduleIdMap = new Map();
52
+ this.moduleToChunks = new Map();
68
53
  this.resourceToModule = new Map();
69
- console.log(`I18nFilesEmitter initialized with publicPath: "${this.publicPath}"`);
70
54
  }
71
-
72
55
  emitAsset(compilation, filename, source, info) {
73
56
  if (!compilation.emitAsset) {
74
57
  compilation.assets[filename] = source;
@@ -76,7 +59,6 @@ class I18nFilesEmitter {
76
59
  compilation.emitAsset(filename, source, info);
77
60
  }
78
61
  }
79
-
80
62
  getI18nObjectByLocale(i18nKeys, locale) {
81
63
  const data = {};
82
64
  i18nKeys.forEach(key => {
@@ -86,12 +68,10 @@ class I18nFilesEmitter {
86
68
  });
87
69
  return data;
88
70
  }
89
-
90
71
  getTemplateString(i18nKeys, locale) {
91
72
  const i18nObject = this.getI18nObjectByLocale(i18nKeys, locale);
92
73
  return `${this.jsonpFunc}(${(0, _utils.jsonToString)(i18nObject)});`;
93
74
  }
94
-
95
75
  renderI18nLocaleChunk(chunk, locale, i18nKeys) {
96
76
  const filenameTemplate = this.filenameTemplate.replace(/\[locale\]/g, locale);
97
77
  const pathOptions = {
@@ -105,42 +85,38 @@ class I18nFilesEmitter {
105
85
  identifier: `${pluginName}.${chunk.id}.${locale}`,
106
86
  hash: chunk.contentHash[i18ntype(locale)]
107
87
  };
108
- } // Capture final module IDs from compilation
109
-
110
-
88
+ }
111
89
  captureModuleIds(compilation) {
112
90
  console.log('Capturing final module IDs from compilation...');
113
91
  this.moduleIdMap.clear();
114
92
  this.resourceToModule.clear();
115
- this.moduleToChunks.clear(); // Process all modules to build our mapping
93
+ this.moduleToChunks.clear();
116
94
 
95
+ // Process all modules to build our mapping
117
96
  compilation.modules.forEach(module => {
118
97
  // Skip modules without resources
119
98
  if (!module.resource) return;
120
99
  const originalId = module.resource;
121
- const finalId = module.id; // Map resource path to final module ID
100
+ const finalId = module.id;
122
101
 
123
- this.moduleIdMap.set(originalId, finalId); // Map resource path to module object
124
-
125
- this.resourceToModule.set(originalId, module); // Build chunk membership for each module
102
+ // Map resource path to final module ID
103
+ this.moduleIdMap.set(originalId, finalId);
104
+ // Map resource path to module object
105
+ this.resourceToModule.set(originalId, module);
126
106
 
107
+ // Build chunk membership for each module
127
108
  const chunkIds = Array.from(module.chunksIterable || []).map(chunk => chunk.id).filter(Boolean);
128
-
129
109
  if (chunkIds.length > 0) {
130
110
  this.moduleToChunks.set(originalId, chunkIds);
131
111
  }
132
112
  });
133
- console.log(`Captured ${this.moduleIdMap.size} module ID mappings`);
134
- } // Modified to use stable resource identifiers
135
-
136
113
 
114
+ // console.log(`Captured ${this.moduleIdMap.size} module ID mappings`);
115
+ }
137
116
  gatherModuleDetails(chunk, i18nKeys) {
138
- if (!i18nKeys.length) return; // Get stable identifiers for each module in the chunk
139
-
140
- const stableModuleIds = Array.from(chunk.modulesIterable).map(module => module.resource).filter(Boolean); // If no stable IDs found, fallback to chunk ID
141
-
117
+ if (!i18nKeys.length) return;
118
+ const stableModuleIds = Array.from(chunk.modulesIterable).map(module => module.resource).filter(Boolean);
142
119
  const moduleKey = stableModuleIds.length ? stableModuleIds[0] : `chunk_${chunk.id}`;
143
-
144
120
  if (!this.detailedManifest[moduleKey]) {
145
121
  this.detailedManifest[moduleKey] = {
146
122
  chunkId: chunk.id,
@@ -148,12 +124,10 @@ class I18nFilesEmitter {
148
124
  keysUsed: new Set()
149
125
  };
150
126
  }
151
-
152
127
  i18nKeys.forEach(key => {
153
128
  this.detailedManifest[moduleKey].keysUsed.add(key);
154
129
  });
155
130
  }
156
-
157
131
  emitI18nFilesForChunk(chunk, compilation) {
158
132
  const i18nKeys = (0, _getI18nKeysFormModules.default)(chunk.modulesIterable);
159
133
  const manifestForChunk = {
@@ -161,20 +135,15 @@ class I18nFilesEmitter {
161
135
  hasI18n: false,
162
136
  hasChanges: false
163
137
  };
164
-
165
138
  if (!i18nKeys.length) {
166
139
  return manifestForChunk;
167
140
  }
168
-
169
141
  this.gatherModuleDetails(chunk, i18nKeys);
170
- manifestForChunk.hasI18n = true; // Check if this is an entry point chunk
171
-
172
- const isEntryPoint = this.isPartOfEntryPoint(chunk, compilation); // If it's an entry point, add its keys to our tracking set
173
-
142
+ manifestForChunk.hasI18n = true;
143
+ const isEntryPoint = this.isPartOfEntryPoint(chunk, compilation);
174
144
  if (isEntryPoint) {
175
145
  i18nKeys.forEach(key => this.entryPointKeys.add(key));
176
146
  }
177
-
178
147
  this.locales.forEach(locale => {
179
148
  const result = this.renderI18nLocaleChunk(chunk, locale, i18nKeys);
180
149
  const {
@@ -186,26 +155,20 @@ class I18nFilesEmitter {
186
155
  } = result;
187
156
  const filePath = compilation.getPath(filenameTemplate, pathOptions);
188
157
  manifestForChunk.assets[locale] = filePath;
189
-
190
158
  if (this.prevHashes[identifier] === hash) {
191
159
  return;
192
160
  }
193
-
194
161
  manifestForChunk.hasChanges = true;
195
- this.prevHashes[identifier] = hash; // Get the rendered content
196
-
197
- const renderedContent = render().source(); // Emit the asset
198
-
162
+ this.prevHashes[identifier] = hash;
163
+ const renderedContent = render().source();
199
164
  this.emitAsset(compilation, filePath, new _webpackSources.RawSource(renderedContent), {
200
165
  locale,
201
166
  chunkId: chunk.id,
202
167
  chunkName: chunk.name
203
- }); // Store chunk content for later reference
204
-
168
+ });
205
169
  if (!this.combinedChunks[locale]) {
206
170
  this.combinedChunks[locale] = [];
207
171
  }
208
-
209
172
  this.combinedChunks[locale].push({
210
173
  path: filePath,
211
174
  content: renderedContent,
@@ -214,36 +177,27 @@ class I18nFilesEmitter {
214
177
  });
215
178
  });
216
179
  return manifestForChunk;
217
- } // Check if a chunk is part of an entry point we're interested in
218
-
219
-
180
+ }
220
181
  isPartOfEntryPoint(chunk, compilation) {
221
182
  let isEntryChunk = false;
222
183
  this.entryPointNames.forEach(entryName => {
223
184
  const entryPoint = compilation.entrypoints.get(entryName);
224
-
225
185
  if (entryPoint && entryPoint.chunks.includes(chunk)) {
226
186
  isEntryChunk = true;
227
187
  }
228
188
  });
229
189
  return isEntryChunk;
230
- } // Create meta manifest with final module IDs
231
-
232
-
190
+ }
233
191
  createMetaManifestWithFinalIds(compilation) {
234
- console.log('Creating meta manifest with final module IDs...'); // Initialize meta manifest structure
235
-
192
+ console.log('Creating meta manifest with final module IDs...');
236
193
  const finalMetaManifest = {
237
194
  modules: {},
238
195
  masterKeys: []
239
- }; // Process each module with its final ID
240
-
196
+ };
241
197
  for (const [resourcePath, moduleData] of Object.entries(this.detailedManifest)) {
242
- // Get the final module ID if available
243
198
  const finalId = this.moduleIdMap.get(resourcePath) || resourcePath;
244
199
  const chunkName = moduleData.chunkName || `chunk_${finalId}`;
245
- const keysArray = Array.isArray(moduleData.keysUsed) ? moduleData.keysUsed : Array.from(moduleData.keysUsed); // Only add modules that have i18n keys
246
-
200
+ const keysArray = Array.isArray(moduleData.keysUsed) ? moduleData.keysUsed : Array.from(moduleData.keysUsed);
247
201
  if (keysArray.length > 0) {
248
202
  finalMetaManifest.modules[chunkName] = {
249
203
  id: moduleData.chunkId,
@@ -252,61 +206,48 @@ class I18nFilesEmitter {
252
206
  keys: keysArray
253
207
  };
254
208
  }
255
- } // Store the generated manifest
256
-
257
-
209
+ }
258
210
  this.generatedMetaManifest = finalMetaManifest;
259
211
  console.log(`Created meta manifest with ${Object.keys(finalMetaManifest.modules).length} modules`);
260
- } // Compare the remote meta manifest with current build
261
-
262
-
212
+ }
263
213
  compareWithRemoteManifest(compilation) {
264
- // Use the imported applyMetaManifest function with our updated module ID maps
265
214
  (0, _applyMetaManifest.applyMetaManifest)(compilation, this);
266
- } // Create and emit the combined master chunk for each locale
267
-
268
-
215
+ }
269
216
  emitMasterChunks(compilation) {
270
- // Combine all the keys we need in the master chunk
271
217
  const combinedKeys = new Set([...this.extraKeys, ...this.movedKeys, ...(this.generatedMetaManifest.masterKeys || [])]);
272
- console.log(`Extra and moved keys to add to master chunk: ${combinedKeys.size}`);
273
- console.log(`Entry point keys: ${this.entryPointKeys.size}`); // Add entry point keys to the master keys in meta manifest
274
218
 
219
+ // console.log(`Extra and moved keys to add to master chunk: ${combinedKeys.size}`);
220
+ // console.log(`Entry point keys: ${this.entryPointKeys.size}`);
221
+
222
+ // Add entry point keys to the master keys in meta manifest
275
223
  if (this.generatedMetaManifest) {
276
224
  this.generatedMetaManifest.masterKeys = [...this.generatedMetaManifest.masterKeys, ...Array.from(this.entryPointKeys)];
277
- } // Create a master object that contains all needed keys
278
-
225
+ }
279
226
 
227
+ // Create a master object that contains all needed keys
280
228
  const allMasterKeys = new Set([...combinedKeys, ...this.entryPointKeys]);
281
- console.log(`Creating master chunks with ${allMasterKeys.size} total keys`);
229
+
230
+ // console.log(`Creating master chunks with ${allMasterKeys.size} total keys`);
282
231
 
283
232
  for (const locale of this.locales) {
284
233
  try {
285
- // console.log(`\n========== Processing master chunk for locale: ${locale} ==========`);
286
- // Create the master i18n object with all required keys
287
234
  const masterI18nObject = this.getI18nObjectByLocale([...allMasterKeys], locale);
288
- console.log(`Master i18n object has ${Object.keys(masterI18nObject).length} keys`); // Create the final JSONP content
289
-
235
+ console.log(`Master i18n object has ${Object.keys(masterI18nObject).length} keys`);
290
236
  const finalContent = `${this.jsonpFunc}(${(0, _utils.jsonToString)(masterI18nObject)});`;
291
- const outputPath = `i18n-chunk/${locale}/${this.masterChunkFileName}`; // Emit the combined master chunk
292
-
237
+ const outputPath = `i18n-chunk/${locale}/${this.masterChunkFileName}`;
293
238
  this.emitAsset(compilation, outputPath, new _webpackSources.RawSource(finalContent), {
294
239
  locale,
295
240
  chunkName: 'master',
296
241
  desc: 'Combined master i18n chunk'
297
- }); // Add to manifest
298
-
242
+ });
299
243
  if (!this.regularManifest.master) {
300
244
  this.regularManifest.master = {};
301
245
  }
302
-
303
- this.regularManifest.master[locale] = outputPath; // console.log(`Emitted master chunk for locale ${locale}: ${outputPath} (${Object.keys(masterI18nObject).length} total keys)`);
246
+ this.regularManifest.master[locale] = outputPath;
304
247
  } catch (error) {
305
- console.error(`ERROR processing master chunk for locale ${locale}:`, error.message); // Emit a simplified version with just the master keys
306
-
248
+ console.error(`ERROR processing master chunk for locale ${locale}:`, error.message);
307
249
  try {
308
- console.log(`Attempting to emit a fallback master chunk for locale ${locale}`); // Just use the moved and extra keys as fallback
309
-
250
+ console.log(`Attempting to emit a fallback master chunk for locale ${locale}`);
310
251
  const fallbackI18nObject = this.getI18nObjectByLocale([...combinedKeys], locale);
311
252
  const fallbackContent = `${this.jsonpFunc}(${(0, _utils.jsonToString)(fallbackI18nObject)});`;
312
253
  const outputPath = `i18n-chunk/${locale}/${this.masterChunkFileName}`;
@@ -315,11 +256,9 @@ class I18nFilesEmitter {
315
256
  chunkName: 'master',
316
257
  desc: 'Fallback master i18n chunk (only moved/extra keys)'
317
258
  });
318
-
319
259
  if (!this.regularManifest.master) {
320
260
  this.regularManifest.master = {};
321
261
  }
322
-
323
262
  this.regularManifest.master[locale] = outputPath;
324
263
  console.log(`Emitted fallback master chunk for locale ${locale}: ${outputPath}`);
325
264
  } catch (fallbackError) {
@@ -328,51 +267,34 @@ class I18nFilesEmitter {
328
267
  }
329
268
  }
330
269
  }
331
-
332
270
  emitI18nAssert(compilation) {
333
- console.log('Starting I18n asset emission process...'); // First, capture all final module IDs
334
-
335
- this.captureModuleIds(compilation); // Reset entry point keys for this build
336
-
337
- this.entryPointKeys = new Set(); // 1. Process chunks and collect keys
338
-
271
+ console.log('Starting I18n asset emission process...');
272
+ this.captureModuleIds(compilation);
273
+ this.entryPointKeys = new Set();
339
274
  compilation.chunks.forEach(chunk => {
340
275
  const manifestForChunk = this.emitI18nFilesForChunk(chunk, compilation);
341
-
342
276
  if (manifestForChunk.hasI18n) {
343
277
  this.regularManifest[chunk.id] = manifestForChunk.assets;
344
278
  }
345
- }); // 2. Create our meta manifest with final module IDs
346
-
347
- this.createMetaManifestWithFinalIds(compilation); // 3. Compare with remote manifest to find extra/moved keys
348
-
349
- this.compareWithRemoteManifest(compilation); // 4. Create and emit combined master chunks
350
-
351
- this.emitMasterChunks(compilation); // 5. Create the regular manifest
352
-
353
- (0, _createRegularManifest.createRegularManifest)(compilation, this); // 6. Emit the final meta manifest with updated master keys
354
-
279
+ });
280
+ this.createMetaManifestWithFinalIds(compilation);
281
+ this.compareWithRemoteManifest(compilation);
282
+ this.emitMasterChunks(compilation);
283
+ (0, _createRegularManifest.createRegularManifest)(compilation, this);
355
284
  const metaManifestSource = new _webpackSources.RawSource(JSON.stringify(this.generatedMetaManifest, null, 2));
356
285
  this.emitAsset(compilation, this.i18nMetaManifestFileName, metaManifestSource, {
357
286
  desc: 'Updated meta manifest with master keys'
358
287
  });
359
288
  console.log('Completed I18n asset emission process');
360
289
  }
361
-
362
290
  apply(compiler) {
363
- // Use the afterCompile hook to capture module info after compilation
364
291
  compiler.hooks.afterCompile.tap(pluginName, compilation => {
365
- // console.log(`${pluginName}: Capturing compilation information after compile phase`);
366
292
  this.compilation = compilation;
367
- }); // Use the emit hook to generate the I18n assets with final module IDs
368
-
293
+ });
369
294
  compiler.hooks.emit.tapAsync(pluginName, (compilation, callback) => {
370
- // console.log(`${pluginName}: Emitting I18n assets with final module IDs`);
371
295
  this.emitI18nAssert(compilation);
372
296
  callback();
373
297
  });
374
298
  }
375
-
376
299
  }
377
-
378
300
  exports.default = I18nFilesEmitter;