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

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 (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,41 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _fs = _interopRequireDefault(require("fs"));
11
-
12
9
  var _webpack = _interopRequireDefault(require("webpack"));
13
-
14
10
  var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
15
-
16
11
  var _webpackBundleAnalyzer = require("webpack-bundle-analyzer");
17
-
18
12
  var _lodashWebpackPlugin = _interopRequireDefault(require("lodash-webpack-plugin"));
19
-
20
13
  var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
21
-
22
14
  var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
23
-
24
- var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
25
-
26
- var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
27
-
28
15
  var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
29
-
30
16
  var _plugins = require("../plugins");
31
-
32
- var _common = require("../common");
33
-
34
17
  var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
35
-
18
+ var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
36
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
-
38
20
  // eslint-disable-next-line no-unused-vars
39
- let getProdPlugins = (options, publicPath = '') => {
21
+ const getProdPlugins = (options, publicPath = '') => {
40
22
  let {
41
- enableChunkHash,
23
+ enableChunkHash
24
+ } = options.app;
25
+ const {
42
26
  manifestFileName,
43
27
  bundleAnalyze,
44
28
  optimize,
@@ -56,13 +40,15 @@ let getProdPlugins = (options, publicPath = '') => {
56
40
  hasShadowDOM,
57
41
  resourceHints,
58
42
  serviceWorker,
59
- htmlTemplate: {
60
- inject
61
- },
43
+ htmlTemplate,
62
44
  tpHashMapping,
63
45
  cdnMapping,
64
46
  crossorigin
65
47
  } = options.app;
48
+ const {
49
+ inject,
50
+ minify: minifyHtmlOptions
51
+ } = htmlTemplate;
66
52
  const {
67
53
  i18n
68
54
  } = options;
@@ -79,9 +65,9 @@ let getProdPlugins = (options, publicPath = '') => {
79
65
  const hashTempalate = enableChunkHash ? '.[chunkhash:20]_' : '';
80
66
  const cssLTRFileNameTempalte = `css/[name]${hashTempalate}${enableRTLSplit ? '.ltr' : ''}.css`;
81
67
  const cssRTLFileNameTempalte = `css/[name]${hashTempalate}.rtl.css`;
82
- let isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
68
+ const isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
83
69
  enableChunkHash = !isDevelopment && enableChunkHash;
84
- let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
70
+ const plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
85
71
  __TEST__: false,
86
72
  __DEVELOPMENT__: false,
87
73
  __LOCAL_PRODUCTION__: isDevelopment,
@@ -95,7 +81,6 @@ let getProdPlugins = (options, publicPath = '') => {
95
81
  filename: cssLTRFileNameTempalte,
96
82
  chunkFilename: cssLTRFileNameTempalte
97
83
  }), new _plugins.ResourceHintsPlugin(), new _plugins.UglifyCSSPlugin()];
98
-
99
84
  if (enableRTLSplit) {
100
85
  plugins.push(new _RtlCssPlugin.RtlCssPlugin({
101
86
  templateLabel: options.css.templateLabel,
@@ -106,17 +91,17 @@ let getProdPlugins = (options, publicPath = '') => {
106
91
  filename: cssRTLFileNameTempalte
107
92
  }));
108
93
  }
109
-
110
94
  const i18nManifestFileName = 'i18n-manifest.json';
111
- /**
112
- * NOTE:
113
- * this file name ext .i18n.js added
114
- * Because, in service worker they maintain cache as file name based
115
- * So, to make differce we added .i18n.js ext.
95
+ /**
96
+ * NOTE:
97
+ * this file name ext .i18n.js added
98
+ * Because, in service worker they maintain cache as file name based
99
+ * So, to make differce we added .i18n.js ext.
116
100
  */
117
101
 
118
102
  const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js';
119
- const i18nPublicPath = Array.isArray(publicPaths) && !cdnMapping.isCdnEnabled ? publicPaths['4'] : ''; // const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[contentHash]_.js';
103
+ const i18nPublicPath = Array.isArray(publicPaths) && !cdnMapping.isCdnEnabled ? publicPaths['4'] : '';
104
+ // const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[contentHash]_.js';
120
105
  // const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name]_.js';
121
106
 
122
107
  if (i18n.chunkSplitEnable) {
@@ -132,8 +117,7 @@ let getProdPlugins = (options, publicPath = '') => {
132
117
  propertiesFolder: i18n.propertiesFolder
133
118
  }));
134
119
  } else {
135
- let i18nPath = _path.default.join(process.cwd(), context, 'i18n');
136
-
120
+ const i18nPath = _path.default.join(process.cwd(), context, 'i18n');
137
121
  if (_fs.default.existsSync(i18nPath)) {
138
122
  plugins.push(new _copyWebpackPlugin.default([{
139
123
  from: `${i18nPath}/`,
@@ -142,27 +126,20 @@ let getProdPlugins = (options, publicPath = '') => {
142
126
  }]));
143
127
  }
144
128
  }
145
-
146
129
  tpFolder && plugins.push(new _copyWebpackPlugin.default([{
147
130
  from: `${_path.default.join(process.cwd(), context, tpFolder)}/`,
148
131
  to: `./${tpFolder}/`,
149
132
  toType: 'dir'
150
133
  }]));
151
-
134
+ (0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(plugins, {
135
+ enableChunkHash,
136
+ folder,
137
+ inject,
138
+ minify: minifyHtmlOptions,
139
+ crossorigin,
140
+ hasEFC
141
+ });
152
142
  if (hasEFC) {
153
- plugins.push(new _htmlWebpackPlugin.default({
154
- chunksSortMode: 'none',
155
- filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
156
- template: _path.default.join(process.cwd(), folder, 'index.html'),
157
- excludeChunks: ['efc', 'widget'],
158
- minify: false,
159
- templateParameters: _common.templateParameters,
160
- scriptLoading: 'defer',
161
- inject: inject
162
- }));
163
- crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
164
- crossorigin: 'anonymous'
165
- }));
166
143
  plugins.push(new _plugins.EFCPlugin({
167
144
  isDevelopment,
168
145
  serverUrl: publicPath,
@@ -175,21 +152,7 @@ let getProdPlugins = (options, publicPath = '') => {
175
152
  localeAttr: efcLocaleAttr,
176
153
  cdnVariableName: cdnMapping.isCdnEnabled ? cdnMapping.variableName : null
177
154
  }));
178
- } else {
179
- plugins.push(new _htmlWebpackPlugin.default({
180
- chunksSortMode: 'none',
181
- filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
182
- template: _path.default.join(process.cwd(), folder, 'index.html'),
183
- minify: false,
184
- templateParameters: _common.templateParameters,
185
- scriptLoading: 'defer',
186
- inject: inject
187
- }));
188
- crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
189
- crossorigin: 'anonymous'
190
- }));
191
155
  }
192
-
193
156
  plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
194
157
  // Because we will handle cdn url in CdnChangePlugin
195
158
  publicPath: cdnMapping.isCdnEnabled ? '' : i18nPublicPath,
@@ -199,9 +162,8 @@ let getProdPlugins = (options, publicPath = '') => {
199
162
  i18nManifestFileName,
200
163
  mainChunkName: 'main'
201
164
  }));
202
-
203
165
  if (publicPaths && !isDevelopment && !cdnMapping.isCdnEnabled) {
204
- let {
166
+ const {
205
167
  callback
206
168
  } = publicPaths;
207
169
  plugins.push(callback ? new _plugins.PublicPathCallbackPlugin({
@@ -211,24 +173,20 @@ let getProdPlugins = (options, publicPath = '') => {
211
173
  resourceHints
212
174
  }));
213
175
  }
214
-
215
176
  if (cdnMapping.isCdnEnabled) {
216
177
  plugins.push(new _plugins.CdnChangePlugin(cdnMapping));
217
178
  }
218
-
219
179
  plugins.push(new _lodashWebpackPlugin.default({
220
180
  collections: true,
221
181
  shorthands: true
222
182
  }));
223
183
  hasShadowDOM && plugins.push(new _plugins.ShadowDOMSupportPlugin());
224
-
225
184
  if (!isDevelopment) {
226
185
  enableSMap && enableSMapHook && plugins.push(new _plugins.SourceMapHookPlugin());
227
186
  optimize && plugins.push(new _plugins.OptimizeJSPlugin());
228
187
  plugins.push(new _plugins.ManifestPlugin({
229
188
  fileName: manifestFileName
230
189
  }));
231
-
232
190
  if (bundleAnalyze) {
233
191
  plugins.push(new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
234
192
  analyzerMode: 'static',
@@ -243,7 +201,8 @@ let getProdPlugins = (options, publicPath = '') => {
243
201
  assets: true,
244
202
  assetsSort: 'name'
245
203
  }
246
- })); // plugins.push(new ReportGeneratePlugin());
204
+ }));
205
+ // plugins.push(new ReportGeneratePlugin());
247
206
  }
248
207
 
249
208
  if (tpHashMapping && tpHashMapping.length > 0) {
@@ -253,19 +212,16 @@ let getProdPlugins = (options, publicPath = '') => {
253
212
  }));
254
213
  }
255
214
  }
256
-
257
215
  if (!isDevelopment && serviceWorker.enableSw) {
258
- let {
216
+ const {
259
217
  filePath,
260
218
  fileName = 'sw.js',
261
219
  exitPath = '/',
262
220
  replaceText = '@@'
263
221
  } = serviceWorker;
264
-
265
222
  if (!filePath) {
266
223
  throw new Error('File Path required for service worker plugin');
267
224
  }
268
-
269
225
  plugins.push(new _plugins.ServiceWorkerPlugin({
270
226
  filePath: _path.default.join(process.cwd(), filePath),
271
227
  i18nFileNameTemplate,
@@ -275,9 +231,7 @@ let getProdPlugins = (options, publicPath = '') => {
275
231
  publicPaths
276
232
  }));
277
233
  }
278
-
279
234
  return plugins;
280
235
  };
281
-
282
236
  var _default = getProdPlugins;
283
237
  exports.default = _default;
@@ -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 = _interopRequireDefault(require("webpack"));
9
-
10
8
  var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  let getProdPlugins = () => {
15
11
  let plugins = [new _webpack.default.optimize.ModuleConcatenationPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
16
12
  __TEST__: false,
@@ -20,6 +16,5 @@ let getProdPlugins = () => {
20
16
  })];
21
17
  return plugins;
22
18
  };
23
-
24
19
  var _default = getProdPlugins;
25
20
  exports.default = _default;
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
9
-
10
8
  var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
11
-
12
9
  var _plugins = require("../plugins");
13
-
14
10
  var _webpack = _interopRequireDefault(require("webpack"));
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  let getUMDCSSPlugins = () => {
19
13
  let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.DefinePlugin({
20
14
  __TEST__: false,
@@ -30,6 +24,5 @@ let getUMDCSSPlugins = () => {
30
24
  }), new _plugins.UglifyCSSPlugin()];
31
25
  return plugins;
32
26
  };
33
-
34
27
  var _default = getUMDCSSPlugins;
35
28
  exports.default = _default;
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
9
-
10
8
  var _webpack = _interopRequireDefault(require("webpack"));
11
-
12
9
  var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
13
-
14
10
  var _plugins = require("../plugins");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  let getUMDComponentPlugins = isDocs => {
19
13
  let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.DefinePlugin({
20
14
  __TEST__: false,
@@ -30,6 +24,5 @@ let getUMDComponentPlugins = isDocs => {
30
24
  }), new _plugins.UglifyCSSPlugin()];
31
25
  return plugins;
32
26
  };
33
-
34
27
  var _default = getUMDComponentPlugins;
35
28
  exports.default = _default;
@@ -45,19 +45,11 @@ Object.defineProperty(exports, "getUMDComponentPlugins", {
45
45
  return _getUMDComponentPlugins.default;
46
46
  }
47
47
  });
48
-
49
48
  var _getDevPlugins = _interopRequireDefault(require("./getDevPlugins"));
50
-
51
49
  var _getProdPlugins = _interopRequireDefault(require("./getProdPlugins"));
52
-
53
50
  var _getDocsPlugins = _interopRequireDefault(require("./getDocsPlugins"));
54
-
55
51
  var _getServerPlugins = _interopRequireDefault(require("./getServerPlugins"));
56
-
57
52
  var _getLibraryPlugins = _interopRequireDefault(require("./getLibraryPlugins"));
58
-
59
53
  var _getUMDComponentPlugins = _interopRequireDefault(require("./getUMDComponentPlugins"));
60
-
61
54
  var _getUMDCSSPlugins = _interopRequireDefault(require("./getUMDCSSPlugins"));
62
-
63
55
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4,23 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
9
-
10
8
  var _utils = require("../utils");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  const MODULE_TYPE = 'css/mini-extract';
15
-
16
11
  const isI18nFile = url => url.endsWith('.i18n.js');
17
-
18
12
  const {
19
13
  app: {
20
14
  enableSMap
21
15
  }
22
16
  } = (0, _utils.getOptions)();
23
-
24
17
  class CdnChangePlugin {
25
18
  constructor(options) {
26
19
  this.i18nTemplate = options.i18nTemplate || '{{__I18N_CDN__}}';
@@ -28,10 +21,8 @@ class CdnChangePlugin {
28
21
  this.cssTemplate = options.cssTemplate || '{{__CSS_CDN__}}';
29
22
  this.jsTemplate = options.jsTemplate || '{{__JS_CDN__}}';
30
23
  }
31
-
32
24
  getCssChunkObject(mainChunk) {
33
25
  const obj = {};
34
-
35
26
  for (const chunk of mainChunk.getAllAsyncChunks()) {
36
27
  for (const module of chunk.modulesIterable) {
37
28
  if (module.type === MODULE_TYPE) {
@@ -40,15 +31,12 @@ class CdnChangePlugin {
40
31
  }
41
32
  }
42
33
  }
43
-
44
34
  return obj;
45
35
  }
46
-
47
36
  apply(compiler) {
48
37
  compiler.hooks.thisCompilation.tap('CdnChangePlugin', compilation => {
49
38
  compilation.mainTemplate.hooks.requireEnsure.tap('CdnChangePlugin', (source, chunk) => {
50
39
  const chunkMap = this.getCssChunkObject(chunk);
51
-
52
40
  if (Object.keys(chunkMap).length > 0) {
53
41
  return source.replace('__webpack_require__.p', `window['${this.variableName}']`);
54
42
  }
@@ -70,8 +58,6 @@ class CdnChangePlugin {
70
58
  });
71
59
  });
72
60
  }
73
-
74
61
  }
75
-
76
62
  var _default = CdnChangePlugin;
77
63
  exports.default = _default;
@@ -4,25 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  class CleanUpStatsPlugin {
9
8
  shouldPickStatChild(child) {
10
9
  return child.name.indexOf('mini-css-extract-plugin') !== 0;
11
10
  }
12
-
13
11
  apply(compiler) {
14
12
  compiler.hooks.done.tap('CleanUpStatsPlugin', stats => {
15
13
  const {
16
14
  children
17
15
  } = stats.compilation;
18
-
19
16
  if (Array.isArray(children)) {
20
17
  // eslint-disable-next-line no-param-reassign
21
18
  stats.compilation.children = children.filter(child => this.shouldPickStatChild(child));
22
19
  }
23
20
  });
24
21
  }
25
-
26
22
  }
27
-
28
23
  exports.default = CleanUpStatsPlugin;
@@ -4,24 +4,16 @@ 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 _path = _interopRequireDefault(require("path"));
13
-
14
10
  var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
15
-
16
11
  var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
17
-
18
12
  var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
19
-
20
13
  var _EFCTemplatePlugin = _interopRequireDefault(require("./EFCTemplatePlugin"));
21
-
22
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
15
  // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
16
+
25
17
  const cliOptions = (0, _utils.getOptions)();
26
18
  const {
27
19
  app: {
@@ -39,17 +31,18 @@ const {
39
31
  createSDkFile,
40
32
  cdnStatement
41
33
  } = efcOptios;
42
-
43
34
  class EFCPlugin {
44
35
  constructor(options = {}) {
45
36
  this.isDevelopment = options.isDevelopment;
46
37
  this.templateFilePath = options.templateFilePath;
47
38
  this.serverUrl = options.serverUrl;
48
- this.i18nFileNameTemplate = options.i18nFileNameTemplate; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
39
+ this.i18nFileNameTemplate = options.i18nFileNameTemplate;
40
+
41
+ // NOTE: this logic may be needed for i18n splited file name with contenthash cases
49
42
  // this.i18nManifestFileName = options.i18nManifestFileName;
43
+
50
44
  // IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
51
45
  // So when debugging consider this as well
52
-
53
46
  this.options = Object.assign({}, efcOptios, options);
54
47
  this.options.entryPointName = options.entryPointName || 'efc';
55
48
  this.options.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
@@ -58,7 +51,8 @@ class EFCPlugin {
58
51
  const cssDirAttr = this.options.cssDirAttr || 'data-efc-dir';
59
52
  const localeDefaultValue = this.options.localeDefaultValue || 'en_US';
60
53
  const cssDirDefaultValue = this.options.cssDirDefaultValue || 'ltr';
61
- this.options.localeStatement = options.localeStatement || // Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
54
+ this.options.localeStatement = options.localeStatement ||
55
+ // Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
62
56
  // Statment 2: return langEle ? langEle.getAttribute('${localeAttr}') : 'en_US';
63
57
  // We are using statement1 not statment2,
64
58
  // Because even that attribute doesn't have value, We need default value
@@ -70,7 +64,9 @@ class EFCPlugin {
70
64
  let dirEle = document.querySelector('[${cssDirAttr}]');
71
65
  return dirEle && dirEle.getAttribute('${cssDirAttr}') || '${cssDirDefaultValue}';
72
66
  })();`;
73
- } // NOTE: this logic may be needed for i18n splited file name with contenthash cases
67
+ }
68
+
69
+ // NOTE: this logic may be needed for i18n splited file name with contenthash cases
74
70
  // getI18nManifest(compilation) {
75
71
  // const i18nManifestFile =
76
72
  // compilation.assets[this.options.i18nManifestFileName];
@@ -81,12 +77,11 @@ class EFCPlugin {
81
77
  // return {};
82
78
  // }
83
79
 
84
-
85
80
  getI18nAssetsStr(entryPoint, compilation) {
86
81
  if (!chunkSplitEnable) {
87
82
  let i18nAsstes = {};
88
- let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
89
-
83
+ let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1);
84
+ //hook for i18n url contains i18n/ may cause problem
90
85
  i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
91
86
  let fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
92
87
  let splittedFileName = fileName.split('.');
@@ -95,11 +90,9 @@ class EFCPlugin {
95
90
  }, {});
96
91
  return `[${JSON.stringify(i18nAsstes)}[lang]]`;
97
92
  }
98
-
99
93
  let initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
100
94
  return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
101
95
  }
102
-
103
96
  createFileContent(compilation) {
104
97
  const {
105
98
  entryPointName,
@@ -111,18 +104,19 @@ class EFCPlugin {
111
104
  const {
112
105
  serverUrl
113
106
  } = this;
114
- const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
115
-
116
- const entryPoint = compilation.entrypoints.get(entryPointName); // const chunk = compilation.namedChunks.get(entryPointName);
117
-
107
+ const cssDirTemplate = '@dir@';
108
+ // const i18nManifest = this.getI18nManifest(compilation);
109
+ const entryPoint = compilation.entrypoints.get(entryPointName);
110
+ // const chunk = compilation.namedChunks.get(entryPointName);
118
111
  const [jsPath, cssPath,,, i18nJsPath] = !this.isDevelopment ? publicPaths : [];
119
112
  const initialFiles = entryPoint.getFiles();
120
- const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file)); // const i18nAssets = getShortI18nAssets(
113
+ const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
114
+
115
+ // const i18nAssets = getShortI18nAssets(
121
116
  // entryPoint.chunks,
122
117
  // i18nManifest,
123
118
  // i18nJsPath
124
119
  // );
125
-
126
120
  const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, i18nJsPath);
127
121
  return `(() => {
128
122
  const lang = ${localeStatement};
@@ -201,12 +195,12 @@ class EFCPlugin {
201
195
  })();
202
196
  `;
203
197
  }
204
-
205
198
  apply(compiler) {
206
199
  if (!createSDkFile) {
207
200
  return;
208
- } //console.log('this.templateFilePath', this.templateFilePath, this.options);
201
+ }
209
202
 
203
+ //console.log('this.templateFilePath', this.templateFilePath, this.options);
210
204
 
211
205
  if (this.templateFilePath) {
212
206
  new _EFCTemplatePlugin.default({
@@ -217,25 +211,20 @@ class EFCPlugin {
217
211
  }).apply(compiler);
218
212
  return;
219
213
  }
220
-
221
214
  compiler.hooks.emit.tap('EFCPlugin', compilation => {
222
215
  const {
223
216
  entryPointName,
224
217
  outputFile
225
218
  } = this.options;
226
219
  const entryPoint = compilation.entrypoints.get(entryPointName);
227
-
228
220
  if (!entryPoint) {
229
221
  return;
230
222
  }
231
-
232
223
  const source = new _webpackSources.RawSource(this.createFileContent(compilation));
233
- compilation.assets[outputFile] = source; // eslint-disable-next-line no-console
234
-
224
+ compilation.assets[outputFile] = source;
225
+ // eslint-disable-next-line no-console
235
226
  console.log('The EFC embedded code was created successfully..!!!');
236
227
  });
237
228
  }
238
-
239
229
  }
240
-
241
230
  exports.default = EFCPlugin;
@@ -1,6 +1,6 @@
1
- # EFC Plugin
2
-
3
- In EFC plugin we are create sdk file for efc related purpose
4
-
5
-
6
- # document will be soon
1
+ # EFC Plugin
2
+
3
+ In EFC plugin we are create sdk file for efc related purpose
4
+
5
+
6
+ # document will be soon