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

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 (222) hide show
  1. package/README.md +18 -0
  2. package/lib/babel/babel-option-utils/babel-preset-react-option.js +3 -0
  3. package/lib/babel/cmjs-plugins-presets.js +13 -2
  4. package/lib/babel/es-plugins-presets.js +14 -3
  5. package/lib/common/buildEs.js +0 -1
  6. package/lib/common/getEntries.js +13 -2
  7. package/lib/common/getPublicPathConfig.js +6 -0
  8. package/lib/common/index.js +6 -1
  9. package/lib/common/runPreProcess.js +15 -6
  10. package/lib/common/splitChunks.js +21 -2
  11. package/lib/common/sslcertUpdater.js +18 -7
  12. package/lib/common/templateParameters.js +2 -0
  13. package/lib/common/testPattern.js +21 -10
  14. package/lib/common/valueReplacer.js +16 -1
  15. package/lib/configs/jest.config.js +11 -2
  16. package/lib/configs/libAlias.js +16 -10
  17. package/lib/configs/resolvers.js +16 -6
  18. package/lib/configs/webpack.component.umd.config.js +6 -1
  19. package/lib/configs/webpack.css.umd.config.js +14 -6
  20. package/lib/configs/webpack.dev.config.js +14 -1
  21. package/lib/configs/webpack.docs.config.js +9 -1
  22. package/lib/configs/webpack.impact.config.js +8 -1
  23. package/lib/configs/webpack.prod.config.js +17 -4
  24. package/lib/constants.js +18 -9
  25. package/lib/deprecationLogger.js +7 -0
  26. package/lib/hooks/docsProptypeHook.js +8 -4
  27. package/lib/jest/commitedFilesResult.js +46 -4
  28. package/lib/jest/coverageCollector.js +12 -1
  29. package/lib/jest/jsonMaker.js +6 -0
  30. package/lib/jest/preProcessors/cssPreprocessor.js +9 -1
  31. package/lib/jest/preProcessors/jsPreprocessor.js +11 -2
  32. package/lib/jest/preProcessors/otherFilesPreprocessor.js +4 -1
  33. package/lib/jest/result.js +23 -1
  34. package/lib/jest/run.js +18 -7
  35. package/lib/jest/setup.js +60 -8
  36. package/lib/loaderUtils/configsAssetsLoaders.js +12 -2
  37. package/lib/loaderUtils/getCSSLoaders.js +22 -10
  38. package/lib/loaderUtils/getDevJsLoaders.js +13 -4
  39. package/lib/loaderUtils/index.js +4 -1
  40. package/lib/loaderUtils/tests/windowsModification.test.js +1 -0
  41. package/lib/loaderUtils/windowsModification.js +3 -2
  42. package/lib/loaders/__test__/markdownLoader.spec.js +1 -0
  43. package/lib/loaders/composeLoader.js +37 -13
  44. package/lib/loaders/docsLoader.js +12 -1
  45. package/lib/loaders/docsPropsLoader.js +8 -4
  46. package/lib/loaders/enhancedReactLiveConverter.js +23 -2
  47. package/lib/loaders/fileBountryLoader.js +3 -1
  48. package/lib/loaders/fileLoader.js +23 -12
  49. package/lib/loaders/markdownLoader.js +19 -14
  50. package/lib/loaders/reactLiveConvertor.js +15 -5
  51. package/lib/loaders/scriptInstrumentLoader.js +16 -7
  52. package/lib/loaders/selectorMappingLoader.js +26 -7
  53. package/lib/loaders/workerLoader.js +24 -9
  54. package/lib/logger.js +4 -0
  55. package/lib/middlewares/HMRMiddleware.js +27 -13
  56. package/lib/middlewares/SSTMiddleware.js +5 -1
  57. package/lib/pluginUtils/configHtmlWebpackPlugins.js +24 -1
  58. package/lib/pluginUtils/getDevPlugins.js +42 -9
  59. package/lib/pluginUtils/getDocsPlugins.js +13 -3
  60. package/lib/pluginUtils/getLibraryImactPlugins.js +6 -5
  61. package/lib/pluginUtils/getLibraryPlugins.js +8 -2
  62. package/lib/pluginUtils/getProdPlugins.js +47 -8
  63. package/lib/pluginUtils/getServerPlugins.js +8 -2
  64. package/lib/pluginUtils/getUMDCSSPlugins.js +10 -2
  65. package/lib/pluginUtils/getUMDComponentPlugins.js +10 -2
  66. package/lib/pluginUtils/index.js +9 -1
  67. package/lib/plugins/CdnChangePlugin.js +18 -2
  68. package/lib/plugins/CleanupStatsPlugin.js +5 -0
  69. package/lib/plugins/CssOrderControlPlugin.js +6 -3
  70. package/lib/plugins/CustomAttributePlugin.js +19 -14
  71. package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +23 -3
  72. package/lib/plugins/EFCPlugin.js +34 -20
  73. package/lib/plugins/EFCTemplatePlugin.js +30 -19
  74. package/lib/plugins/EfcResourceCleanupPlugin.js +3 -0
  75. package/lib/plugins/EventsHandlingPlugin.js +4 -2
  76. package/lib/plugins/I18NInjectIntoIndexPlugin.js +37 -14
  77. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +15 -10
  78. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
  79. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +155 -78
  80. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +81 -198
  81. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +23 -12
  82. package/lib/plugins/I18nSplitPlugin/index.js +24 -13
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
  85. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
  86. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +8 -1
  87. package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
  88. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -0
  89. package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +1 -0
  90. package/lib/plugins/ManifestPlugin.js +18 -1
  91. package/lib/plugins/MinifyPlugin.js +10 -1
  92. package/lib/plugins/ModuleStatsPlugin.js +24 -1
  93. package/lib/plugins/OptimizeJSPlugin.js +10 -2
  94. package/lib/plugins/PublicPathCallbackPlugin.js +12 -1
  95. package/lib/plugins/PublicPathChangePlugin.js +39 -6
  96. package/lib/plugins/ReportGeneratePlugin.js +32 -5
  97. package/lib/plugins/RequireVariablePublicPlugin.js +8 -1
  98. package/lib/plugins/ResourceHintsPlugin.js +13 -4
  99. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
  100. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +17 -10
  101. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
  102. package/lib/plugins/ScriptInstrumentPlugin.js +8 -1
  103. package/lib/plugins/SelectorPlugin.js +32 -6
  104. package/lib/plugins/ServiceWorkerPlugin.js +22 -5
  105. package/lib/plugins/ShadowDOMSupportPlugin.js +41 -4
  106. package/lib/plugins/SourceMapHookPlugin.js +12 -2
  107. package/lib/plugins/StatsPlugin.js +14 -0
  108. package/lib/plugins/TPHashMappingPlugin.js +18 -3
  109. package/lib/plugins/UnusedFilesFindPlugin.js +39 -4
  110. package/lib/plugins/VariableConversionCollector.js +42 -15
  111. package/lib/plugins/index.js +20 -1
  112. package/lib/plugins/libraryImpactPlugin.js +33 -1
  113. package/lib/plugins/utils/classHandling.js +6 -0
  114. package/lib/plugins/utils/fileHandling.js +15 -6
  115. package/lib/plugins/utils/tests/fileHandling.test.js +4 -0
  116. package/lib/plugins/variableConvertorUtils.js +29 -14
  117. package/lib/plugins/webpackwatchrunplugin.js +5 -0
  118. package/lib/postcss-plugins/EmptyPlugin.js +4 -3
  119. package/lib/postcss-plugins/ExcludePlugin.js +5 -1
  120. package/lib/postcss-plugins/IncludePlugin.js +5 -1
  121. package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
  122. package/lib/postcss-plugins/SelectorReplace.js +16 -1
  123. package/lib/postcss-plugins/ValueReplacer.js +6 -7
  124. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
  125. package/lib/postcss-plugins/__test__/selectorReplace.test.js +3 -6
  126. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +5 -2
  127. package/lib/postcss-plugins/hoverActivePlugin.js +67 -31
  128. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +7 -0
  129. package/lib/postcss-plugins/variableModificationPlugin/index.js +49 -28
  130. package/lib/schemas/index.js +10 -3
  131. package/lib/servers/clusterHubServer.js +11 -1
  132. package/lib/servers/devBuild.js +26 -14
  133. package/lib/servers/docsServer.js +3 -1
  134. package/lib/servers/docsServerCore.js +22 -1
  135. package/lib/servers/getCliPath.js +9 -0
  136. package/lib/servers/helpServer.js +6 -1
  137. package/lib/servers/httpsOptions.js +8 -2
  138. package/lib/servers/impactServer.js +35 -3
  139. package/lib/servers/mockserver.js +10 -1
  140. package/lib/servers/nowatchserver.js +37 -12
  141. package/lib/servers/requireLocalOrGlobal.js +17 -6
  142. package/lib/servers/scrServer.js +21 -14
  143. package/lib/servers/server.js +36 -6
  144. package/lib/servers/ssServer.js +17 -1
  145. package/lib/templates/CoverageScriptTemplate.js +14 -0
  146. package/lib/templates/WMSTemplate.js +13 -7
  147. package/lib/templates/linterConstant.js +4 -2
  148. package/lib/utils/babelPresets.js +7 -3
  149. package/lib/utils/clean.js +9 -3
  150. package/lib/utils/copy.js +7 -1
  151. package/lib/utils/copyTimezones.js +9 -1
  152. package/lib/utils/createEventStream.js +6 -1
  153. package/lib/utils/cssClassNameGenerate.js +30 -10
  154. package/lib/utils/cssURLReplacer.js +22 -1
  155. package/lib/utils/dependencyPostPublish.js +10 -1
  156. package/lib/utils/deprecationSupport.js +32 -7
  157. package/lib/utils/fileUtils.js +28 -1
  158. package/lib/utils/folderIterator.js +13 -2
  159. package/lib/utils/getComponents.js +21 -0
  160. package/lib/utils/getCurrentBranch.js +5 -0
  161. package/lib/utils/getDependenciesImpactList.js +22 -1
  162. package/lib/utils/getFileType.js +10 -2
  163. package/lib/utils/getHash.js +8 -1
  164. package/lib/utils/getIp.js +2 -0
  165. package/lib/utils/getOptions.js +53 -16
  166. package/lib/utils/getServerURL.js +10 -1
  167. package/lib/utils/index.js +51 -4
  168. package/lib/utils/init.js +1 -0
  169. package/lib/utils/initPreCommitHook.js +30 -7
  170. package/lib/utils/jsonHelper.js +22 -3
  171. package/lib/utils/libraryImpactConfig.js +5 -2
  172. package/lib/utils/lint/addScripts.js +5 -2
  173. package/lib/utils/lint/checkExistingConfig.js +12 -3
  174. package/lib/utils/lint/copyConfigs.js +3 -0
  175. package/lib/utils/lint/index.js +9 -0
  176. package/lib/utils/lint/lintScripts.js +1 -0
  177. package/lib/utils/lint/lintSetup.js +4 -3
  178. package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
  179. package/lib/utils/lint/question.js +7 -0
  180. package/lib/utils/lintReporter.js +20 -0
  181. package/lib/utils/log.js +1 -0
  182. package/lib/utils/mailSender.js +8 -1
  183. package/lib/utils/object-manipulation.js +17 -1
  184. package/lib/utils/pullOrigin.js +4 -0
  185. package/lib/utils/reinstallDependencies.js +29 -1
  186. package/lib/utils/removeAttributes.js +8 -1
  187. package/lib/utils/repoClone.js +28 -3
  188. package/lib/utils/request.js +12 -0
  189. package/lib/utils/rtl.js +17 -5
  190. package/lib/utils/selectorReplacer.js +16 -10
  191. package/lib/utils/setEnvVariables.js +2 -0
  192. package/lib/utils/ssTestHack.js +11 -1
  193. package/lib/utils/switchBranch.js +5 -0
  194. package/lib/utils/typeCheck.js +1 -0
  195. package/lib/utils/urlConcat.js +4 -0
  196. package/lib/utils/useExitCleanup.js +10 -9
  197. package/lib/utils/variableConverter.js +31 -22
  198. package/{package-lock.json → npm-shrinkwrap.json} +2333 -2101
  199. package/package.json +3 -2
  200. package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +0 -279
  201. package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +0 -51
  202. package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +0 -48
  203. package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +0 -306
  204. package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +0 -363
  205. package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +0 -694
  206. package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +0 -1258
  207. package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +0 -542
  208. package/lib/plugins/newi18nsplitplugin/18nplugin.js +0 -974
  209. package/lib/plugins/newi18nsplitplugin/ChunkManager.js +0 -131
  210. package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +0 -59
  211. package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +0 -262
  212. package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +0 -166
  213. package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +0 -111
  214. package/lib/plugins/newi18nsplitplugin/KeyCollector.js +0 -163
  215. package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +0 -88
  216. package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +0 -101
  217. package/lib/plugins/newi18nsplitplugin/constants.js +0 -162
  218. package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +0 -78
  219. package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +0 -22
  220. package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +0 -18
  221. package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +0 -580
  222. package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +0 -54
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "1.1.29-exp.2",
3
+ "version": "1.1.29-exp.3",
4
4
  "description": "A CLI tool for build modern web application and libraries",
5
5
  "scripts": {
6
6
  "init": "node ./lib/utils/init.js",
@@ -33,6 +33,7 @@
33
33
  "react-cli": "bin/cli.js"
34
34
  },
35
35
  "dependencies": {
36
+ "@babel/plugin-proposal-decorators": "7.10.5",
36
37
  "@babel/cli": "7.10.5",
37
38
  "@babel/core": "7.11.1",
38
39
  "@babel/plugin-proposal-object-rest-spread": "7.11.0",
@@ -41,7 +42,7 @@
41
42
  "@babel/preset-env": "7.11.0",
42
43
  "@babel/preset-react": "7.10.4",
43
44
  "@babel/runtime": "7.11.2",
44
- "@zohodesk/client_packages_group": "1.0.2",
45
+ "@zohodesk/client_packages_group": "1.0.3",
45
46
  "@zohodesk/eslint-plugin-react-performance": "1.0.3",
46
47
  "@zohodesk/eslint-plugin-zsecurity": "0.0.1-beta.4",
47
48
  "@zohodesk/postcss-rtl": "1.5.2",
@@ -1,279 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.applyMetaManifest = applyMetaManifest;
7
- var _fs = _interopRequireDefault(require("fs"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- function applyMetaManifest(compilation, plugin) {
10
- const {
11
- moduleIdMap
12
- } = plugin;
13
- const manifestPath = './metaManifest.json';
14
- if (!plugin.detailedManifest || Object.keys(plugin.detailedManifest).length === 0) {
15
- console.warn('No detailedManifest available, skipping manifest comparison');
16
- return {
17
- extraKeys: new Set(),
18
- movedKeys: new Set(),
19
- error: 'No detailedManifest available'
20
- };
21
- }
22
-
23
- // Track keys in current build
24
- const currentBuildKeys = new Set();
25
- const currentKeyToModule = new Map();
26
- const currentModules = new Map();
27
- const currentKeySets = new Map();
28
- const moduleIdToName = new Map();
29
-
30
- // Process current build modules with final IDs
31
- for (const [resourcePath, chunkData] of Object.entries(plugin.detailedManifest)) {
32
- // Get the final module ID if it exists in our mapping
33
- const finalModuleId = moduleIdMap.get(resourcePath) || resourcePath;
34
- const chunkName = chunkData.chunkName || `chunk_${chunkData.chunkId || "unknown"}`;
35
-
36
- // Store module name mapping for better logging
37
- moduleIdToName.set(finalModuleId, chunkName);
38
- const keys = Array.isArray(chunkData.keysUsed) ? chunkData.keysUsed : Array.from(chunkData.keysUsed);
39
-
40
- // Skip empty modules
41
- if (keys.length === 0) continue;
42
-
43
- // Sort keys for consistent comparison
44
- const sortedKeys = [...keys].sort();
45
- const keySetString = sortedKeys.join(',');
46
-
47
- // Store module data using final IDs
48
- currentModules.set(finalModuleId, {
49
- id: finalModuleId,
50
- resourcePath: resourcePath,
51
- chunkId: chunkData.chunkId,
52
- name: chunkName,
53
- keys: sortedKeys
54
- });
55
-
56
- // Store key set for module fingerprinting
57
- currentKeySets.set(keySetString, finalModuleId);
58
-
59
- // Store individual key mappings
60
- keys.forEach(key => {
61
- currentBuildKeys.add(key);
62
- currentKeyToModule.set(key, finalModuleId);
63
- });
64
- }
65
- const currentKeyCount = currentBuildKeys.size;
66
- const currentModuleCount = currentModules.size;
67
- console.log(`Current build: ${currentKeyCount} keys in ${currentModuleCount} modules`);
68
- try {
69
- // Read from specified manifest path
70
- if (!_fs.default.existsSync(manifestPath)) {
71
- console.warn(`Meta manifest not found at ${manifestPath}`);
72
- return {
73
- extraKeys: new Set(),
74
- movedKeys: new Set(),
75
- error: `Meta manifest not found at ${manifestPath}`
76
- };
77
- }
78
- const fileContent = _fs.default.readFileSync(manifestPath, 'utf8');
79
- const remoteMetaManifest = JSON.parse(fileContent);
80
-
81
- // Handle non-existent or invalid modules
82
- if (!remoteMetaManifest.modules) {
83
- console.warn('Meta manifest does not contain modules section');
84
- return {
85
- extraKeys: new Set(),
86
- movedKeys: new Set(),
87
- error: 'Meta manifest does not contain modules section'
88
- };
89
- }
90
-
91
- // Track all keys in remote manifest modules
92
- const remoteModuleKeys = new Set();
93
- const remoteKeyToModule = new Map();
94
- const remoteModules = new Map();
95
- const remoteKeySets = new Map();
96
- const remoteModuleIdToName = new Map();
97
- const moduleEquivalenceMap = new Map();
98
-
99
- // Process remote manifest modules
100
- for (const [moduleId, moduleData] of Object.entries(remoteMetaManifest.modules)) {
101
- if (moduleData.keys && Array.isArray(moduleData.keys)) {
102
- // Store module name for better logging
103
- const moduleName = moduleId;
104
- remoteModuleIdToName.set(moduleId, moduleName);
105
-
106
- // Skip empty modules
107
- if (moduleData.keys.length === 0) continue;
108
-
109
- // Sort keys for consistent comparison
110
- const sortedKeys = [...moduleData.keys].sort();
111
- const keySetString = sortedKeys.join(',');
112
-
113
- // Store module data
114
- remoteModules.set(moduleId, {
115
- id: moduleData.id || moduleId,
116
- name: moduleName,
117
- keys: sortedKeys,
118
- keyCount: moduleData.keys.length
119
- });
120
-
121
- // Store key set
122
- remoteKeySets.set(keySetString, moduleId);
123
-
124
- // Store individual key mappings
125
- moduleData.keys.forEach(key => {
126
- remoteModuleKeys.add(key);
127
- remoteKeyToModule.set(key, moduleId);
128
- });
129
- }
130
- }
131
-
132
- // Get keys from the master chunk in the remote manifest (if it exists)
133
- const remoteMasterKeys = new Set();
134
- if (remoteMetaManifest.masterKeys && Array.isArray(remoteMetaManifest.masterKeys)) {
135
- remoteMetaManifest.masterKeys.forEach(key => {
136
- remoteMasterKeys.add(key);
137
- });
138
- }
139
-
140
- // Get all unique keys from the remote manifest (modules + master)
141
- const remoteAllKeys = new Set([...remoteModuleKeys, ...remoteMasterKeys]);
142
- const remoteKeyCount = remoteAllKeys.size;
143
- const remoteModuleCount = remoteModules.size;
144
- const remoteMasterKeyCount = remoteMasterKeys.size;
145
- console.log(`Remote manifest: ${remoteKeyCount} keys in ${remoteModuleCount} modules, ${remoteMasterKeyCount} master keys`);
146
-
147
- // Find intersection and differences for keys
148
- const inBothSets = new Set([...currentBuildKeys].filter(key => remoteAllKeys.has(key)));
149
- const missingKeys = new Set([...remoteAllKeys].filter(key => !currentBuildKeys.has(key)));
150
- const extraKeys = new Set([...currentBuildKeys].filter(key => !remoteAllKeys.has(key)));
151
- console.log(`Key comparison: ${inBothSets.size} shared keys, ${missingKeys.size} missing, ${extraKeys.size} new`);
152
-
153
- // Enhanced multi-level module equivalence mapping
154
- // 1. First pass: Match by module name
155
- for (const [remoteId, remoteModule] of remoteModules.entries()) {
156
- if (remoteModule.name) {
157
- // Find a current module with matching name
158
- for (const [currentId, currentModule] of currentModules.entries()) {
159
- if (currentModule.name && currentModule.name === remoteModule.name) {
160
- moduleEquivalenceMap.set(remoteId, currentId);
161
- break;
162
- }
163
- }
164
- }
165
- }
166
-
167
- // 2. Second pass: Match by resource path
168
- const unmatchedRemote = [...remoteModules.keys()].filter(id => !moduleEquivalenceMap.has(id));
169
- for (const remoteId of unmatchedRemote) {
170
- for (const [resourcePath, currentModuleId] of moduleIdMap.entries()) {
171
- if (resourcePath.includes(remoteId)) {
172
- moduleEquivalenceMap.set(remoteId, currentModuleId);
173
- break;
174
- }
175
- }
176
- }
177
-
178
- // 3. Third pass: Match by key set fingerprint
179
- const stillUnmatchedRemote = [...remoteModules.keys()].filter(id => !moduleEquivalenceMap.has(id));
180
- for (const remoteId of stillUnmatchedRemote) {
181
- const remoteModule = remoteModules.get(remoteId);
182
- const keySetString = remoteModule.keys.join(',');
183
- if (currentKeySets.has(keySetString)) {
184
- moduleEquivalenceMap.set(remoteId, currentKeySets.get(keySetString));
185
- }
186
- }
187
-
188
- // Find moved keys based on enhanced module equivalence map
189
- const trulyMovedKeys = new Set();
190
- const keyMovementDetails = new Map();
191
- for (const key of inBothSets) {
192
- // Skip keys that are in the master chunk
193
- if (remoteMasterKeys.has(key)) {
194
- continue;
195
- }
196
- const remoteModuleId = remoteKeyToModule.get(key);
197
- const currentModuleId = currentKeyToModule.get(key);
198
-
199
- // Normalize module names for comparison
200
- const remoteModuleName = remoteModuleIdToName.get(remoteModuleId) || remoteModuleId;
201
- const currentModuleName = moduleIdToName.get(currentModuleId) || currentModuleId;
202
-
203
- // Only consider a key moved if it's actually in a different module
204
- const moduleNameComparison = remoteModuleName !== currentModuleName;
205
- if (moduleNameComparison) {
206
- trulyMovedKeys.add(key);
207
- keyMovementDetails.set(key, {
208
- from: remoteModuleId,
209
- fromName: remoteModuleName,
210
- to: currentModuleId,
211
- toName: currentModuleName,
212
- type: 'module_change'
213
- });
214
- }
215
- }
216
-
217
- // Get keys from unmatched modules that exist in the current build
218
- const unmatchedRemoteModules = [...remoteModules.keys()].filter(id => !moduleEquivalenceMap.has(id));
219
- unmatchedRemoteModules.forEach(moduleId => {
220
- const module = remoteModules.get(moduleId);
221
- const moduleName = remoteModuleIdToName.get(moduleId) || moduleId;
222
- module.keys.forEach(key => {
223
- // Only add the key if it exists in the current build
224
- if (currentBuildKeys.has(key)) {
225
- const currentModuleId = currentKeyToModule.get(key);
226
- const currentModuleName = moduleIdToName.get(currentModuleId) || currentModuleId;
227
-
228
- // Only add if actually in a different module
229
- if (moduleName !== currentModuleName) {
230
- trulyMovedKeys.add(key);
231
- keyMovementDetails.set(key, {
232
- from: moduleId,
233
- fromName: moduleName,
234
- to: currentModuleId,
235
- toName: currentModuleName,
236
- type: 'unmatched_module'
237
- });
238
- }
239
- }
240
- });
241
- });
242
- const movedKeyCount = trulyMovedKeys.size;
243
- console.log(`Found ${extraKeys.size} new keys and ${movedKeyCount} moved keys`);
244
-
245
- // Add extra and moved keys to the plugin's tracking for master chunk inclusion
246
- plugin.extraKeys = extraKeys;
247
- plugin.movedKeys = trulyMovedKeys;
248
-
249
- // Store key counts for reference
250
- plugin.keyStats = {
251
- current: currentKeyCount,
252
- remote: remoteKeyCount,
253
- extra: extraKeys.size,
254
- moved: movedKeyCount
255
- };
256
-
257
- // Update master keys in the generated meta manifest
258
- if (plugin.generatedMetaManifest) {
259
- // Only include extra (new) and moved keys in the master keys
260
- const masterKeys = [...Array.from(extraKeys), ...Array.from(trulyMovedKeys)];
261
- plugin.generatedMetaManifest.masterKeys = masterKeys;
262
- }
263
- return {
264
- extraKeys,
265
- movedKeys: trulyMovedKeys,
266
- keyStats: plugin.keyStats
267
- };
268
- } catch (error) {
269
- console.error(`Error during manifest comparison: ${error.message}`);
270
- // Return empty sets for keys if there was an error
271
- plugin.extraKeys = new Set();
272
- plugin.movedKeys = new Set();
273
- return {
274
- extraKeys: new Set(),
275
- movedKeys: new Set(),
276
- error: error.message
277
- };
278
- }
279
- }
@@ -1,51 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createMetaManifest = createMetaManifest;
7
- var _webpackSources = require("webpack-sources");
8
- function createMetaManifest(compilation, plugin, skipEmit = false) {
9
- const {
10
- detailedManifest
11
- } = plugin;
12
- const i18nMetaManifestFileName = plugin.i18nMetaManifestFileName;
13
- if (!skipEmit) {
14
- console.log('Generating meta manifest:', i18nMetaManifestFileName);
15
- }
16
- const finalMetaManifest = {
17
- modules: {}
18
- };
19
- for (const [chunkId, chunkData] of Object.entries(detailedManifest)) {
20
- const chunkName = chunkData.chunkName || `chunk_${chunkId}`;
21
- const keysArray = Array.isArray(chunkData.keysUsed) ? chunkData.keysUsed : Array.from(chunkData.keysUsed);
22
- if (keysArray.length > 0) {
23
- finalMetaManifest.modules[chunkName] = {
24
- id: chunkId,
25
- keys: keysArray
26
- };
27
- }
28
- }
29
- if (plugin.extraKeys && plugin.movedKeys) {
30
- const masterKeysSet = new Set([...(Array.from(plugin.extraKeys) || []), ...(Array.from(plugin.movedKeys) || [])]);
31
- finalMetaManifest.masterKeys = Array.from(masterKeysSet);
32
- if (finalMetaManifest.masterKeys.length > 0) {
33
- console.log(`Extra and moved keys to add to master chunk: ${finalMetaManifest.masterKeys.length}`);
34
- finalMetaManifest.masterKeys.forEach(key => {
35
- console.log(` - ${key}`);
36
- });
37
- }
38
- }
39
- plugin.generatedMetaManifest = finalMetaManifest;
40
- if (!skipEmit) {
41
- const metaManifestSource = new _webpackSources.RawSource(JSON.stringify(finalMetaManifest, null, 2));
42
- if (!compilation.emitAsset) {
43
- compilation.assets[i18nMetaManifestFileName] = metaManifestSource;
44
- } else {
45
- compilation.emitAsset(i18nMetaManifestFileName, metaManifestSource, {
46
- desc: 'Streamlined chunk-module-i18nKeys mapping with optimized master keys'
47
- });
48
- }
49
- }
50
- return finalMetaManifest;
51
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createRegularManifest = createRegularManifest;
7
- var _webpackSources = require("webpack-sources");
8
- function createRegularManifest(compilation, plugin) {
9
- const {
10
- regularManifest,
11
- // e.g., { chunkId: { localeA: pathA, localeB: pathB, ... }, ... }
12
- locales,
13
- // e.g., ['en_US', 'fr_FR', ...]
14
- i18nManifestFileName,
15
- // e.g., 'i18n-manifest.json'
16
- deskI18nManifestFileName = 'i18n-chunk/desk-i18n-manifest.js'
17
- } = plugin;
18
- const finalManifest = {
19
- locales: [...locales],
20
- chunks: {},
21
- basePath: 'i18n-chunk/[locale]/'
22
- };
23
- for (const chunkId of Object.keys(regularManifest)) {
24
- const localePaths = regularManifest[chunkId];
25
- if (!localePaths) continue;
26
- const entries = Object.entries(localePaths);
27
- if (!entries.length) continue;
28
- const [someLocale, fullPath] = entries[0];
29
- if (!fullPath) continue;
30
- const pathSegments = fullPath.split('/');
31
- const basename = pathSegments.slice(2).join('/');
32
- finalManifest.chunks[chunkId] = basename;
33
- }
34
- const manifestStr = JSON.stringify(finalManifest, null, 2);
35
- const jsonManifestSource = new _webpackSources.RawSource(manifestStr);
36
- const deskI18nManifestCode = `
37
- (function() {
38
- window.desk_i18n_manifest = ${manifestStr};
39
- })();
40
- `;
41
- const deskI18nManifestSource = new _webpackSources.RawSource(deskI18nManifestCode);
42
- compilation.emitAsset(i18nManifestFileName, jsonManifestSource, {
43
- desc: 'Emitted plain JSON i18n manifest'
44
- });
45
- compilation.emitAsset(deskI18nManifestFileName, deskI18nManifestSource, {
46
- desc: 'Emitted manifest attached to window.desk_i18n_manifest'
47
- });
48
- }