@zohodesk/react-cli 0.0.1-exp.169.2 → 0.0.1-exp.175.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -179
  3. package/.prettierrc +6 -6
  4. package/README.md +1028 -951
  5. package/bin/cli.js +483 -483
  6. package/cert/Tsicsezwild-22-23.crt +37 -37
  7. package/cert/Tsicsezwild-22-23.key +27 -27
  8. package/docs/CustomChunks.md +26 -26
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/TODOS.md +10 -10
  13. package/docs/ValueReplacer.md +60 -60
  14. package/docs/VariableConversion.md +678 -0
  15. package/docs/warnings_while_install.txt +35 -35
  16. package/files/eslintrc.js +62 -62
  17. package/files/prettierrc.js +3 -3
  18. package/lib/babel/cmjs-plugins-presets.js +0 -4
  19. package/lib/babel/es-plugins-presets.js +0 -4
  20. package/lib/common/getEntries.js +0 -10
  21. package/lib/common/getPublicPathConfig.js +0 -6
  22. package/lib/common/index.js +0 -5
  23. package/lib/common/splitChunks.js +2 -13
  24. package/lib/common/sslcertUpdater.js +6 -17
  25. package/lib/common/templateParameters.js +0 -2
  26. package/lib/common/testPattern.js +10 -21
  27. package/lib/common/valueReplacer.js +0 -15
  28. package/lib/configs/jest.config.js +8 -21
  29. package/lib/configs/libAlias.js +11 -2
  30. package/lib/configs/webpack.component.umd.config.js +0 -5
  31. package/lib/configs/webpack.css.umd.config.js +5 -13
  32. package/lib/configs/webpack.dev.config.js +13 -24
  33. package/lib/configs/webpack.docs.config.js +6 -12
  34. package/lib/configs/webpack.impact.config.js +6 -10
  35. package/lib/configs/webpack.prod.config.js +15 -26
  36. package/lib/hooks/docsProptypeHook.js +3 -7
  37. package/lib/jest/commitedFilesResult.js +3 -45
  38. package/lib/jest/coverageCollector.js +0 -11
  39. package/lib/jest/jsonMaker.js +0 -6
  40. package/lib/jest/preProcessors/cssPreprocessor.js +14 -13
  41. package/lib/jest/preProcessors/jsPreprocessor.js +0 -2
  42. package/lib/jest/preProcessors/otherFilesPreprocessor.js +0 -3
  43. package/lib/jest/result.js +0 -22
  44. package/lib/jest/run.js +6 -17
  45. package/lib/jest/setup.js +5 -57
  46. package/lib/loaderUtils/configsAssetsLoaders.js +34 -44
  47. package/lib/loaderUtils/getCSSLoaders.js +41 -28
  48. package/lib/loaderUtils/getDevJsLoaders.js +0 -8
  49. package/lib/loaderUtils/index.js +0 -3
  50. package/lib/loaders/docsLoader.js +0 -7
  51. package/lib/loaders/docsPropsLoader.js +3 -7
  52. package/lib/loaders/fileBountryLoader.js +0 -2
  53. package/lib/loaders/fileLoader.js +11 -22
  54. package/lib/loaders/scriptInstrumentLoader.js +5 -13
  55. package/lib/loaders/selectorMappingLoader.js +7 -25
  56. package/lib/loaders/workerLoader.js +13 -29
  57. package/lib/middlewares/HMRMiddleware.js +13 -26
  58. package/lib/middlewares/SSTMiddleware.js +0 -3
  59. package/lib/pluginUtils/configHtmlWebpackPlugins.js +53 -0
  60. package/lib/pluginUtils/getDevPlugins.js +20 -64
  61. package/lib/pluginUtils/getDocsPlugins.js +1 -10
  62. package/lib/pluginUtils/getLibraryImactPlugins.js +4 -5
  63. package/lib/pluginUtils/getLibraryPlugins.js +0 -5
  64. package/lib/pluginUtils/getProdPlugins.js +32 -78
  65. package/lib/pluginUtils/getServerPlugins.js +0 -5
  66. package/lib/pluginUtils/getUMDCSSPlugins.js +0 -7
  67. package/lib/pluginUtils/getUMDComponentPlugins.js +0 -7
  68. package/lib/pluginUtils/index.js +0 -8
  69. package/lib/plugins/CdnChangePlugin.js +0 -14
  70. package/lib/plugins/CleanupStatsPlugin.js +0 -5
  71. package/lib/plugins/EFCPlugin.js +23 -34
  72. package/lib/plugins/EFCPlugin.md +6 -6
  73. package/lib/plugins/EFCTemplatePlugin.js +23 -32
  74. package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -38
  75. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +12 -17
  76. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
  77. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +46 -77
  78. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +44 -59
  79. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +21 -30
  80. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  81. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  82. package/lib/plugins/I18nSplitPlugin/index.js +70 -80
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
  85. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
  86. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +0 -6
  87. package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
  88. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +2 -20
  89. package/lib/plugins/ManifestPlugin.js +0 -17
  90. package/lib/plugins/ModuleStatsPlugin.js +0 -23
  91. package/lib/plugins/OptimizeJSPlugin.js +0 -7
  92. package/lib/plugins/PublicPathCallbackPlugin.js +0 -10
  93. package/lib/plugins/PublicPathChangePlugin.js +4 -36
  94. package/lib/plugins/ReportGeneratePlugin.js +4 -30
  95. package/lib/plugins/RequireVariablePublicPlugin.js +0 -6
  96. package/lib/plugins/ResourceHintsPlugin.js +20 -27
  97. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
  98. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +23 -38
  99. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  100. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
  101. package/lib/plugins/ScriptInstrumentPlugin.js +0 -7
  102. package/lib/plugins/ServiceWorkerPlugin.js +13 -29
  103. package/lib/plugins/ShadowDOMSupportPlugin.js +3 -40
  104. package/lib/plugins/SourceMapHookPlugin.js +0 -9
  105. package/lib/plugins/TPHashMappingPlugin.js +5 -19
  106. package/lib/plugins/UglifyCSSPlugin.js +0 -9
  107. package/lib/plugins/UnusedFilesFindPlugin.js +2 -35
  108. package/lib/plugins/index.js +0 -19
  109. package/lib/plugins/libraryImpactPlugin.js +0 -32
  110. package/lib/plugins/webpackwatchrunplugin.js +0 -5
  111. package/lib/postcss-plugins/ExcludePlugin.js +0 -4
  112. package/lib/postcss-plugins/RTLSplitPlugin.js +24 -37
  113. package/lib/postcss-plugins/ValueReplacer.js +9 -6
  114. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
  115. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  116. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  117. package/lib/postcss-plugins/hoverActivePlugin.js +80 -92
  118. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +31 -0
  119. package/lib/postcss-plugins/variableModificationPlugin/index.js +232 -0
  120. package/lib/postcss-plugins/variableModifier.js +14 -20
  121. package/lib/schemas/index.js +28 -13
  122. package/lib/servers/clusterHubServer.js +0 -10
  123. package/lib/servers/devBuild.js +13 -24
  124. package/lib/servers/docsServer.js +0 -2
  125. package/lib/servers/docsServerCore.js +0 -21
  126. package/lib/servers/getCliPath.js +1 -10
  127. package/lib/servers/helpServer.js +0 -5
  128. package/lib/servers/httpsOptions.js +0 -4
  129. package/lib/servers/impactServer.js +2 -34
  130. package/lib/servers/mockserver.js +0 -9
  131. package/lib/servers/nowatchserver.js +12 -34
  132. package/lib/servers/scrServer.js +13 -20
  133. package/lib/servers/server.js +7 -35
  134. package/lib/servers/ssServer.js +0 -16
  135. package/lib/sh/pre-commit.sh +34 -34
  136. package/lib/sh/reportPublish.sh +45 -45
  137. package/lib/templates/CoverageScriptTemplate.js +0 -14
  138. package/lib/templates/WMSTemplate.js +6 -12
  139. package/lib/utils/babelPresets.js +0 -2
  140. package/lib/utils/buildstats.html +148 -148
  141. package/lib/utils/clean.js +2 -8
  142. package/lib/utils/copy.js +0 -6
  143. package/lib/utils/copyTimezones.js +0 -8
  144. package/lib/utils/createEventStream.js +0 -4
  145. package/lib/utils/cssClassNameGenerate.js +3 -19
  146. package/lib/utils/cssURLReplacer.js +0 -25
  147. package/lib/utils/dependencyPostPublish.js +0 -9
  148. package/lib/utils/fileUtils.js +0 -26
  149. package/lib/utils/folderIterator.js +0 -10
  150. package/lib/utils/getComponents.js +0 -21
  151. package/lib/utils/getCurrentBranch.js +0 -5
  152. package/lib/utils/getDependenciesImpactList.js +0 -21
  153. package/lib/utils/getHash.js +0 -7
  154. package/lib/utils/getIp.js +0 -2
  155. package/lib/utils/getOptions.js +38 -35
  156. package/lib/utils/getServerURL.js +0 -7
  157. package/lib/utils/index.js +2 -47
  158. package/lib/utils/init.js +0 -1
  159. package/lib/utils/initPreCommitHook.js +6 -29
  160. package/lib/utils/jsonHelper.js +2 -19
  161. package/lib/utils/libraryImpactConfig.js +0 -2
  162. package/lib/utils/lint/addScripts.js +2 -5
  163. package/lib/utils/lint/checkExistingConfig.js +3 -12
  164. package/lib/utils/lint/copyConfigs.js +0 -3
  165. package/lib/utils/lint/index.js +0 -9
  166. package/lib/utils/lint/lintScripts.js +0 -1
  167. package/lib/utils/lint/lintSetup.js +3 -4
  168. package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
  169. package/lib/utils/lint/question.js +0 -7
  170. package/lib/utils/lintReporter.js +0 -20
  171. package/lib/utils/mailSender.js +0 -7
  172. package/lib/utils/pullOrigin.js +0 -4
  173. package/lib/utils/reinstallDependencies.js +0 -28
  174. package/lib/utils/removeAttributes.js +0 -7
  175. package/lib/utils/repoClone.js +2 -27
  176. package/lib/utils/request.js +0 -12
  177. package/lib/utils/resultSchema.json +73 -73
  178. package/lib/utils/rtl.js +4 -16
  179. package/lib/utils/setEnvVariables.js +0 -2
  180. package/lib/utils/ssTestHack.js +0 -10
  181. package/lib/utils/switchBranch.js +0 -4
  182. package/lib/utils/urlConcat.js +0 -4
  183. package/lib/utils/useExitCleanup.js +9 -10
  184. package/npm8.md +9 -9
  185. package/package.json +146 -148
  186. package/postpublish.js +6 -6
  187. package/templates/app/.eslintrc.js +140 -140
  188. package/templates/app/README.md +12 -12
  189. package/templates/app/app/index.html +24 -24
  190. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  191. package/templates/app/app/properties/i18nkeys.json +3 -3
  192. package/templates/app/docs/all.html +69 -69
  193. package/templates/app/mockapi/index.js +18 -18
  194. package/templates/app/package.json +37 -37
  195. package/templates/app/src/actions/SampleActions/index.js +37 -37
  196. package/templates/app/src/actions/index.js +65 -65
  197. package/templates/app/src/appUrls.js +19 -19
  198. package/templates/app/src/components/Alert/Alert.js +134 -134
  199. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  200. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  201. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  202. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  203. package/templates/app/src/components/Sample/SampleList.js +61 -61
  204. package/templates/app/src/components/Slider/Slider.css +41 -41
  205. package/templates/app/src/components/Slider/Slider.js +55 -55
  206. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  207. package/templates/app/src/containers/AppContainer/index.js +96 -96
  208. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  209. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  210. package/templates/app/src/containers/DevTools/index.js +10 -10
  211. package/templates/app/src/containers/Header/index.js +67 -67
  212. package/templates/app/src/containers/Header/index.module.css +43 -43
  213. package/templates/app/src/containers/Redirect/index.js +63 -63
  214. package/templates/app/src/containers/Redirector/index.js +47 -47
  215. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  216. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  217. package/templates/app/src/historyChange.js +5 -5
  218. package/templates/app/src/index.html +10 -10
  219. package/templates/app/src/index.js +24 -24
  220. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  221. package/templates/app/src/reducers/alertData.js +11 -11
  222. package/templates/app/src/reducers/index.js +6 -6
  223. package/templates/app/src/reducers/samples.js +19 -19
  224. package/templates/app/src/store/configureStore.dev.js +51 -51
  225. package/templates/app/src/store/configureStore.js +5 -5
  226. package/templates/app/src/store/configureStore.prod.js +26 -26
  227. package/templates/app/src/util/Common.js +5 -5
  228. package/templates/app/src/util/RequestAPI.js +132 -132
  229. package/templates/docs/all.html +249 -249
  230. package/templates/docs/component.html +178 -178
  231. package/templates/docs/components.html +221 -221
  232. package/templates/docs/css/b.min.css +6 -6
  233. package/templates/docs/css/component.css +42 -42
  234. package/templates/docs/css/componentTest.css +6 -6
  235. package/templates/docs/css/hopscotch.css +585 -585
  236. package/templates/docs/css/style.css +1022 -1022
  237. package/templates/docs/impactReportTemplate.html +154 -154
  238. package/templates/docs/index.html +1501 -1493
  239. package/templates/docs/js/active-line.js +72 -72
  240. package/templates/docs/js/b.min.js +7 -7
  241. package/templates/docs/js/codemirror.js +9680 -9680
  242. package/templates/docs/js/designTokens.js +334 -334
  243. package/templates/docs/js/j.min.js +4 -4
  244. package/templates/docs/js/javascript.js +874 -874
  245. package/templates/docs/js/matchbrackets.js +145 -145
@@ -4,24 +4,19 @@ 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
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- /**
17
- * this plugin was creating the chunk specific i18n chunk's.
11
+ /**
12
+ * this plugin was creating the chunk specific i18n chunk's.
18
13
  */
14
+
19
15
  // this plugin's kick starter is apply method
16
+
20
17
  const pluginName = 'I18nFilesEmitter';
21
18
  const MODULE_TYPE = 'json/i18n';
22
-
23
19
  const i18ntype = locale => `${MODULE_TYPE}/${locale}`;
24
-
25
20
  class I18nFilesEmitter {
26
21
  constructor({
27
22
  allI18nObject,
@@ -32,13 +27,12 @@ class I18nFilesEmitter {
32
27
  }) {
33
28
  this.locales = locales;
34
29
  this.allI18nObject = allI18nObject;
35
- this.filenameTemplate = filenameTemplate; // this.filenameTemplate = "i18n-chunk/[locale]/[name].js"
36
-
30
+ this.filenameTemplate = filenameTemplate;
31
+ // this.filenameTemplate = "i18n-chunk/[locale]/[name].js"
37
32
  this.jsonpFunc = jsonpFunc;
38
33
  this.prevHashes = {};
39
34
  this.i18nManifestFileName = i18nManifestFileName;
40
35
  }
41
-
42
36
  emitAsset(compilation, filename, source, info) {
43
37
  // NOTE: info support available since webpack v4.40.0 https://webpack.js.org/api/stats/#asset-objects
44
38
  if (!compilation.emitAsset) {
@@ -46,9 +40,9 @@ class I18nFilesEmitter {
46
40
  } else {
47
41
  compilation.emitAsset(filename, source, info);
48
42
  }
49
- } // this method for create object and assign value for i18nkeys
50
-
43
+ }
51
44
 
45
+ // this method for create object and assign value for i18nkeys
52
46
  getI18nObjectByLocale(i18nKeys, locale) {
53
47
  const data = {};
54
48
  i18nKeys.forEach(key => {
@@ -56,10 +50,10 @@ class I18nFilesEmitter {
56
50
  });
57
51
  return data;
58
52
  }
59
-
60
53
  getTemplateString(i18nKeys, locale) {
61
54
  let i18nObject = this.getI18nObjectByLocale(i18nKeys, locale);
62
- return `${this.jsonpFunc}(${(0, _utils.jsonToString)(i18nObject)});`; // return `${this.jsonpFunc}(JSON.parse(${JSON.stringify(jsonToString(i18nObject))}));`;
55
+ return `${this.jsonpFunc}(${(0, _utils.jsonToString)(i18nObject)});`;
56
+ // return `${this.jsonpFunc}(JSON.parse(${JSON.stringify(jsonToString(i18nObject))}));`;
63
57
  }
64
58
 
65
59
  renderI18nLocaleChunk(chunk, locale, i18nKeys) {
@@ -77,7 +71,6 @@ class I18nFilesEmitter {
77
71
  hash: chunk.contentHash[i18ntype(locale)]
78
72
  };
79
73
  }
80
-
81
74
  emitI18nFilesForChunk(chunk, compilation) {
82
75
  const i18nKeys = (0, _getI18nKeysFormModules.default)(chunk.modulesIterable);
83
76
  const manifestForChunk = {
@@ -85,14 +78,12 @@ class I18nFilesEmitter {
85
78
  hasI18n: false,
86
79
  hasChanges: false
87
80
  };
88
-
89
81
  if (!i18nKeys.length) {
90
82
  // why it is not checked as 0
91
83
  return manifestForChunk;
92
84
  }
93
-
94
- manifestForChunk.hasI18n = true; // const locales = ['en_US'];
95
-
85
+ manifestForChunk.hasI18n = true;
86
+ // const locales = ['en_US'];
96
87
  this.locales.forEach(locale => {
97
88
  const result = this.renderI18nLocaleChunk(chunk, locale, i18nKeys, compilation);
98
89
  const {
@@ -104,34 +95,31 @@ class I18nFilesEmitter {
104
95
  } = result;
105
96
  const filePath = compilation.getPath(filenameTemplate, pathOptions);
106
97
  manifestForChunk.assets[locale] = filePath;
107
-
108
98
  if (this.prevHashes[identifier] === hash) {
109
99
  return;
110
100
  }
111
-
112
101
  manifestForChunk.hasChanges = true;
113
102
  this.prevHashes[identifier] = hash;
114
103
  this.emitAsset(compilation, filePath, render(), {
115
104
  locale,
116
105
  chunkId: chunk.id,
117
106
  chunkName: chunk.name
118
- }); // compilation.assets[filePath] = render();
107
+ });
108
+ // compilation.assets[filePath] = render();
119
109
  });
110
+
120
111
  return manifestForChunk;
121
112
  }
122
-
123
113
  emitI18nAssert(compilation) {
124
114
  let manifest = {};
125
115
  let needEmitManifest = false;
126
116
  compilation.chunks.forEach(chunk => {
127
117
  const manifestForChunk = this.emitI18nFilesForChunk(chunk, compilation);
128
-
129
118
  if (manifestForChunk.hasI18n) {
130
119
  manifest[chunk.id] = manifestForChunk.assets;
131
120
  needEmitManifest = needEmitManifest || manifestForChunk.hasChanges;
132
121
  }
133
122
  });
134
-
135
123
  if (needEmitManifest) {
136
124
  const manifestSource = new _webpackSources.RawSource(JSON.stringify(manifest));
137
125
  this.emitAsset(compilation, this.i18nManifestFileName, manifestSource, {
@@ -139,45 +127,42 @@ class I18nFilesEmitter {
139
127
  });
140
128
  }
141
129
  }
142
-
143
130
  apply(compiler) {
144
- /*
145
- compiler.hooks.thisCompilation.tap(pluginName, compilation => {
146
- compilation.mainTemplate.hooks.renderManifest.tap(
147
- pluginName,
148
- (result, { chunk }) => {
149
- this.renderChunk(result, compilation, chunk);
150
- }
151
- );
152
- compilation.chunkTemplate.hooks.renderManifest.tap(
153
- pluginName,
154
- (result, { chunk }) => {
155
- this.renderChunk(result, compilation, chunk);
156
- }
157
- );
158
- });
131
+ /*
132
+ compiler.hooks.thisCompilation.tap(pluginName, compilation => {
133
+ compilation.mainTemplate.hooks.renderManifest.tap(
134
+ pluginName,
135
+ (result, { chunk }) => {
136
+ this.renderChunk(result, compilation, chunk);
137
+ }
138
+ );
139
+ compilation.chunkTemplate.hooks.renderManifest.tap(
140
+ pluginName,
141
+ (result, { chunk }) => {
142
+ this.renderChunk(result, compilation, chunk);
143
+ }
144
+ );
145
+ });
159
146
  */
160
147
  // this below hook was tapped for create asssets(file) for chunk specific i18nChunk Files
161
148
  compiler.hooks.emit.tap(pluginName, compilation => {
162
149
  this.emitI18nAssert(compilation);
163
150
  });
164
151
  }
165
- /*
166
- renderChunk(result, compilation, chunk) {
167
- const i18nKeys = getI18nKeysFormModules(chunk.modulesIterable);
168
- // TODO: need to discuss with vimal ji can we chose this place for add i18n locale files ????
169
- // IDEA: we chose this place for add i18n locale files ????
170
- if (i18nKeys.length > 0) {
171
- Object.keys(this.allI18nObject).forEach(locale => {
172
- result.push(
173
- this.renderI18nLocaleChunk(chunk, locale, i18nKeys, compilation)
174
- );
175
- });
176
- }
177
- }
178
- */
179
-
180
152
 
153
+ /*
154
+ renderChunk(result, compilation, chunk) {
155
+ const i18nKeys = getI18nKeysFormModules(chunk.modulesIterable);
156
+ // TODO: need to discuss with vimal ji can we chose this place for add i18n locale files ????
157
+ // IDEA: we chose this place for add i18n locale files ????
158
+ if (i18nKeys.length > 0) {
159
+ Object.keys(this.allI18nObject).forEach(locale => {
160
+ result.push(
161
+ this.renderI18nLocaleChunk(chunk, locale, i18nKeys, compilation)
162
+ );
163
+ });
164
+ }
165
+ }
166
+ */
181
167
  }
182
-
183
168
  exports.default = I18nFilesEmitter;
@@ -4,43 +4,37 @@ 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
8
  var _I18nDependency = require("./I18nDependency");
11
-
12
9
  var _NullFactory = _interopRequireDefault(require("webpack/lib/NullFactory"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  const pluginName = 'I18nKeysIdentifer';
17
- /**
18
- * this plugin search the i18 keys and make it as I18nDependency.
19
- * how it works?
20
- * this plugin get jsResourceI18nKeys in constructor.
21
- * we walk throught the js files AST
22
- * if any string literal in that AST is in jsResourceI18nKeys then we consider that string as I18n key
23
- * after the walk of AST we get some I18n keys
24
- * then we make it as I18nDependency.
25
- */
26
12
 
13
+ /**
14
+ * this plugin search the i18 keys and make it as I18nDependency.
15
+ * how it works?
16
+ * this plugin get jsResourceI18nKeys in constructor.
17
+ * we walk throught the js files AST
18
+ * if any string literal in that AST is in jsResourceI18nKeys then we consider that string as I18n key
19
+ * after the walk of AST we get some I18n keys
20
+ * then we make it as I18nDependency.
21
+ */
27
22
  class I18nKeysIdentifer {
28
23
  constructor(jsResourceI18nKeys) {
29
24
  this.jsResourceI18nKeys = jsResourceI18nKeys;
30
25
  }
31
-
32
26
  defineConfigarationForI18nDependency(compilation) {
33
27
  compilation.dependencyFactories.set(_I18nDependency.I18nDependency, new _NullFactory.default());
34
28
  compilation.dependencyTemplates.set(_I18nDependency.I18nDependency, new _I18nDependency.I18nDependencyTemplate());
35
29
  }
36
-
37
30
  addI18nDependency(module, i18nKeys) {
38
31
  const identifier = `i18n ${module.resource}`;
39
32
  const dep = new _I18nDependency.I18nDependency({
40
33
  identifier,
41
34
  i18nKeys
42
35
  }, module.context, 0);
43
- module.addDependency(dep); // console.log('module', i18nKeys, identifier);
36
+ module.addDependency(dep);
37
+ // console.log('module', i18nKeys, identifier);
44
38
  }
45
39
 
46
40
  apply(compiler) {
@@ -48,23 +42,23 @@ class I18nKeysIdentifer {
48
42
  // this below hook was tapped for we use I18nDependency
49
43
  // so we must define module factory for I18nDependency
50
44
  // and we must define how it import statement look like I18nDependencyTemplate
51
- this.defineConfigarationForI18nDependency(compilation); // handler for parser
45
+ this.defineConfigarationForI18nDependency(compilation);
52
46
 
47
+ // handler for parser
53
48
  let handler = parser => {
54
49
  parser.hooks.program.tap(pluginName, (ast, commmets) => {
55
50
  const {
56
51
  module
57
- } = parser.state; //
58
-
52
+ } = parser.state;
53
+ //
59
54
  if (!(module && /\.jsx?$/.test(module.resource))) {
60
55
  return;
61
- } // i18n grep proper contract regex
62
-
63
-
56
+ }
57
+ // i18n grep proper contract regex
64
58
  let i18nKeys = (0, _utils.collectI18nKeysfromAST)(ast, this.jsResourceI18nKeys);
65
- i18nKeys = i18nKeys.concat( // i18n grep proper contract regex
59
+ i18nKeys = i18nKeys.concat(
60
+ // i18n grep proper contract regex
66
61
  (0, _utils.collectI18nKeysfromComments)(commmets, this.jsResourceI18nKeys));
67
-
68
62
  if (i18nKeys.length) {
69
63
  // console.log(
70
64
  // 'i18nKeys.length',
@@ -74,19 +68,17 @@ class I18nKeysIdentifer {
74
68
  this.addI18nDependency(module, i18nKeys);
75
69
  }
76
70
  });
77
- }; // this below hook was tapped for collect I18n Key from files and add as Deppenensy
71
+ };
78
72
 
73
+ // this below hook was tapped for collect I18n Key from files and add as Deppenensy
79
74
 
80
75
  const factory = params.normalModuleFactory;
81
76
  factory.hooks.parser.for('javascript/auto').tap(pluginName, handler);
82
77
  factory.hooks.parser.for('javascript/dynamic').tap(pluginName, handler);
83
78
  });
84
79
  }
85
-
86
80
  }
87
-
88
81
  exports.default = I18nKeysIdentifer;
89
-
90
82
  I18nKeysIdentifer.isChunkHasI18n = function (chunk) {
91
83
  for (const module of chunk.modulesIterable) {
92
84
  for (const dep of module.dependencies) {
@@ -95,6 +87,5 @@ I18nKeysIdentifer.isChunkHasI18n = function (chunk) {
95
87
  }
96
88
  }
97
89
  }
98
-
99
90
  return false;
100
91
  };
@@ -1,95 +1,95 @@
1
- # I18n Split As Chunks Plugin
2
-
3
- generaly we have manage our all I18n keys and values as language specific i18n files and then we download all i18n in initial page load.
4
-
5
- ### what is the problem with this?.
6
-
7
- the problem is i18n file keep get's grown it will affect the the inital page load and critial rendering path.
8
- So, We have decide to create a plugin for split i18n per chunk's of js vise.
9
-
10
- ### what is i18n split?
11
-
12
- it is like code split for i18n.
13
- we will collect i18n from js chunk and we will create separate i18n chunk per js chunk,
14
- with this we already load Js chunks are on demand and now we also download i18n also ondemand with this the initial and forthere actions.
15
- when js download's we will download i18n with it.
16
-
17
- ### How to we going to i18n split?
18
-
19
- we will read the js chunk and collect I18n keys form it,
20
- then we will create i18n chunk files with these used keys.
21
-
22
- ### how do you collect i18n keys from js files?
23
-
24
- we will traverse the js file's AST (static analysis) and find i18 keys,
25
- we will concider all string which is in jsResource file as i18n keys.
26
- and you can tell dynamic i18n key by js comments,
27
- Like Below:-
28
-
29
- ```js
30
- fetch('tickets?view=view1').then(data => {
31
- // I18n support.ticketsEmpty
32
- // I18n support.viewNotFount
33
- // I18n support.permissionDenied
34
- let text = getI18nValue(data.i18nkey);
35
- });
36
- ```
37
-
38
- ### is there any posiblity for unwanted keys in some chunk?
39
-
40
- Yes, there is two posiblity
41
-
42
- 1. js comment , if you write js comment but it is not needed then it will be add into i18n chunk
43
- `To Resolve` we currently do not have perfect idea for this, But we can check this by chunk size limit.
44
- `idea's will be welcome`
45
- 2. like we said "we will concider all string which is in jsResource file as i18n keys",
46
- So if you use string not for i18n but it was in jsResource then it will be add into i18n chunk.
47
- `To Resolve` this problem we can use some kinda prefix or something.
48
-
49
- ### how do we downlowd and give to app?
50
-
51
- we have over write defualt webpack requireEnsure (every dynamic chunk requests are done by that function) function.
52
- and we parlarly dowload i18n files. and we ask jsonFunction, to our plugin.
53
- So we send i18nkeys , when it was download,
54
- you must store all i18n keys, we give asycrnsly by that function download in that patticular.
55
- so you must store and update (like append or assign) everytime that function call.
56
-
57
- ### how to use this feature?
58
-
59
- to use this feature use have give the below oprtions
60
- `package.json`
61
-
62
- ```json
63
- {
64
- /// ...some things
65
- "react-cli": {
66
- // ...some things
67
- "i18n": {
68
- "chunkSplitEnable": true,
69
- "jsResource": "./deskapp/properties/JSResources.properties",
70
- "localeVarName": "window.userInfo.langCode",
71
- "jsonpFunc": "window.loadI18nChunk",
72
- "templateLabel": "{{--user-locale}}", // this is for html template i18n file path locate template
73
- "propertiesFolder": "./deskapp/properties"
74
- }
75
- // ...some things
76
- }
77
- }
78
- ```
79
-
80
- <!-- not need below -->
81
- <!--we have added new feature for css to write logic to how hover related css work in hoverhover and a
82
-
83
- ### is there any problems with static analysis?
84
- Yes,
85
-
86
- ### how do we use dynamic i18n key?
87
-
88
- and we will download i18n file with
89
-
90
- and when js chunk download's then we will download i18n as need.
91
- we all know in our app we loading i18n as one single big file for each locale(language).
92
- we are going to split i18n as per js chunk, and when js chunk download's then we will download i18n as need.
93
-
94
-
95
- -->
1
+ # I18n Split As Chunks Plugin
2
+
3
+ generaly we have manage our all I18n keys and values as language specific i18n files and then we download all i18n in initial page load.
4
+
5
+ ### what is the problem with this?.
6
+
7
+ the problem is i18n file keep get's grown it will affect the the inital page load and critial rendering path.
8
+ So, We have decide to create a plugin for split i18n per chunk's of js vise.
9
+
10
+ ### what is i18n split?
11
+
12
+ it is like code split for i18n.
13
+ we will collect i18n from js chunk and we will create separate i18n chunk per js chunk,
14
+ with this we already load Js chunks are on demand and now we also download i18n also ondemand with this the initial and forthere actions.
15
+ when js download's we will download i18n with it.
16
+
17
+ ### How to we going to i18n split?
18
+
19
+ we will read the js chunk and collect I18n keys form it,
20
+ then we will create i18n chunk files with these used keys.
21
+
22
+ ### how do you collect i18n keys from js files?
23
+
24
+ we will traverse the js file's AST (static analysis) and find i18 keys,
25
+ we will concider all string which is in jsResource file as i18n keys.
26
+ and you can tell dynamic i18n key by js comments,
27
+ Like Below:-
28
+
29
+ ```js
30
+ fetch('tickets?view=view1').then(data => {
31
+ // I18n support.ticketsEmpty
32
+ // I18n support.viewNotFount
33
+ // I18n support.permissionDenied
34
+ let text = getI18nValue(data.i18nkey);
35
+ });
36
+ ```
37
+
38
+ ### is there any posiblity for unwanted keys in some chunk?
39
+
40
+ Yes, there is two posiblity
41
+
42
+ 1. js comment , if you write js comment but it is not needed then it will be add into i18n chunk
43
+ `To Resolve` we currently do not have perfect idea for this, But we can check this by chunk size limit.
44
+ `idea's will be welcome`
45
+ 2. like we said "we will concider all string which is in jsResource file as i18n keys",
46
+ So if you use string not for i18n but it was in jsResource then it will be add into i18n chunk.
47
+ `To Resolve` this problem we can use some kinda prefix or something.
48
+
49
+ ### how do we downlowd and give to app?
50
+
51
+ we have over write defualt webpack requireEnsure (every dynamic chunk requests are done by that function) function.
52
+ and we parlarly dowload i18n files. and we ask jsonFunction, to our plugin.
53
+ So we send i18nkeys , when it was download,
54
+ you must store all i18n keys, we give asycrnsly by that function download in that patticular.
55
+ so you must store and update (like append or assign) everytime that function call.
56
+
57
+ ### how to use this feature?
58
+
59
+ to use this feature use have give the below oprtions
60
+ `package.json`
61
+
62
+ ```json
63
+ {
64
+ /// ...some things
65
+ "react-cli": {
66
+ // ...some things
67
+ "i18n": {
68
+ "chunkSplitEnable": true,
69
+ "jsResource": "./deskapp/properties/JSResources.properties",
70
+ "localeVarName": "window.userInfo.langCode",
71
+ "jsonpFunc": "window.loadI18nChunk",
72
+ "templateLabel": "{{--user-locale}}", // this is for html template i18n file path locate template
73
+ "propertiesFolder": "./deskapp/properties"
74
+ }
75
+ // ...some things
76
+ }
77
+ }
78
+ ```
79
+
80
+ <!-- not need below -->
81
+ <!--we have added new feature for css to write logic to how hover related css work in hoverhover and a
82
+
83
+ ### is there any problems with static analysis?
84
+ Yes,
85
+
86
+ ### how do we use dynamic i18n key?
87
+
88
+ and we will download i18n file with
89
+
90
+ and when js chunk download's then we will download i18n as need.
91
+ we all know in our app we loading i18n as one single big file for each locale(language).
92
+ we are going to split i18n as per js chunk, and when js chunk download's then we will download i18n as need.
93
+
94
+
95
+ -->
@@ -1,25 +1,25 @@
1
- # I18n Split As Chunks Plugin
2
-
3
- generaly we have manage our all I18n keys and values as language specific i18n files and then we download all i18n in initial page load.
4
-
5
- Ok, what is the problem with this?.
6
- the problem is i18n file keep get's grown it will affect the the inital page load and critial rendering path.
7
- So, We have decide to create a plugin for split i18n per chunk's of js vise, Which mean we diside to create for each js chunk has its own i18n chunks, with this we already load Js chunks are on demand and now we also download i18n also ondemand with this the initial and forthere actions.
8
-
9
- Ok, How to you do this thing?
10
- we have read the js chunk and collect I18n keys what are used in that chunk and we will create i18n chunk files with only used key.
11
-
12
- Ok, How do you collect that keys?
13
- we now have two expremental statrge to collect I18n keys.
14
-
15
- 1. we read jsResource.properties (or all keys I18n file) then we walk this AST of js and we collect all string which is jsResource.properties.
16
- 2. for dynamic we discide to use comment some thing like
17
- `// I18n support.tickekt.email.notvalid`
18
-
19
- ok, how do you downlowd and give to app?
20
- we have over write defualt webpack require ensure function.
21
- So every dynamic chunk requset are done by that function.
22
- So we parlarly dowload i18n files. and we ask jsonFunction, to our plugin.
23
- So we send i18nkeys , when it was download,
24
- you must store all i18n keys, we give asycrnsly by that function download in that patticular.
25
- so you must store and update (like append or assign) everytime that function call.
1
+ # I18n Split As Chunks Plugin
2
+
3
+ generaly we have manage our all I18n keys and values as language specific i18n files and then we download all i18n in initial page load.
4
+
5
+ Ok, what is the problem with this?.
6
+ the problem is i18n file keep get's grown it will affect the the inital page load and critial rendering path.
7
+ So, We have decide to create a plugin for split i18n per chunk's of js vise, Which mean we diside to create for each js chunk has its own i18n chunks, with this we already load Js chunks are on demand and now we also download i18n also ondemand with this the initial and forthere actions.
8
+
9
+ Ok, How to you do this thing?
10
+ we have read the js chunk and collect I18n keys what are used in that chunk and we will create i18n chunk files with only used key.
11
+
12
+ Ok, How do you collect that keys?
13
+ we now have two expremental statrge to collect I18n keys.
14
+
15
+ 1. we read jsResource.properties (or all keys I18n file) then we walk this AST of js and we collect all string which is jsResource.properties.
16
+ 2. for dynamic we discide to use comment some thing like
17
+ `// I18n support.tickekt.email.notvalid`
18
+
19
+ ok, how do you downlowd and give to app?
20
+ we have over write defualt webpack require ensure function.
21
+ So every dynamic chunk requset are done by that function.
22
+ So we parlarly dowload i18n files. and we ask jsonFunction, to our plugin.
23
+ So we send i18nkeys , when it was download,
24
+ you must store all i18n keys, we give asycrnsly by that function download in that patticular.
25
+ so you must store and update (like append or assign) everytime that function call.