@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +183 -183
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +636 -491
  5. package/bin/cli.js +372 -367
  6. package/files/eslintrc.js +57 -0
  7. package/files/prettierrc.js +3 -0
  8. package/lib/babel/cmjs-plugins-presets.js +16 -9
  9. package/lib/babel/es-plugins-presets.js +26 -14
  10. package/lib/common/getEntries.js +31 -22
  11. package/lib/common/getPublicPathConfig.js +27 -13
  12. package/lib/common/index.js +21 -25
  13. package/lib/common/splitChunks.js +62 -53
  14. package/lib/common/templateParameters.js +10 -8
  15. package/lib/configs/jest.config.js +15 -25
  16. package/lib/configs/webpack.component.umd.config.js +31 -37
  17. package/lib/configs/webpack.css.umd.config.js +44 -47
  18. package/lib/configs/webpack.dev.config.js +70 -52
  19. package/lib/configs/webpack.docs.config.js +106 -106
  20. package/lib/configs/webpack.prod.config.js +95 -75
  21. package/lib/hooks/docsProptypeHook.js +32 -38
  22. package/lib/jest/commitedFilesResult.js +103 -74
  23. package/lib/jest/coverageCollector.js +41 -21
  24. package/lib/jest/jsonMaker.js +15 -16
  25. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  26. package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
  27. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  28. package/lib/jest/result.js +90 -45
  29. package/lib/jest/run.js +43 -43
  30. package/lib/jest/setup.js +102 -95
  31. package/lib/loaderUtils/getCSSLoaders.js +21 -22
  32. package/lib/loaderUtils/getDevJsLoaders.js +25 -23
  33. package/lib/loaderUtils/index.js +11 -13
  34. package/lib/loaders/docsLoader.js +15 -15
  35. package/lib/loaders/docsPropsLoader.js +14 -17
  36. package/lib/loaders/fileLoader.js +33 -35
  37. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  38. package/lib/loaders/workerLoader.js +136 -0
  39. package/lib/middlewares/HMRMiddleware.js +54 -45
  40. package/lib/middlewares/SSTMiddleware.js +8 -5
  41. package/lib/pluginUtils/getDevPlugins.js +114 -52
  42. package/lib/pluginUtils/getDocsPlugins.js +25 -29
  43. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  44. package/lib/pluginUtils/getProdPlugins.js +163 -74
  45. package/lib/pluginUtils/getServerPlugins.js +8 -11
  46. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  47. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  48. package/lib/pluginUtils/index.js +36 -43
  49. package/lib/plugins/CdnChangePlugin.js +63 -0
  50. package/lib/plugins/CleanupStatsPlugin.js +18 -32
  51. package/lib/plugins/CustomAttributePlugin.js +79 -0
  52. package/lib/plugins/CustomAttributePlugin.md +35 -0
  53. package/lib/plugins/EFCPlugin.js +185 -0
  54. package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
  55. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  56. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  57. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  58. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  59. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  60. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  61. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  62. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  63. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  64. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  65. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  66. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  67. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  68. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  69. package/lib/plugins/ManifestPlugin.js +52 -63
  70. package/lib/plugins/ModuleStatsPlugin.js +83 -173
  71. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  72. package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
  73. package/lib/plugins/PublicPathChangePlugin.js +175 -284
  74. package/lib/plugins/ReportGeneratePlugin.js +150 -151
  75. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  76. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  77. package/lib/plugins/ServiceWorkerPlugin.js +81 -57
  78. package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
  79. package/lib/plugins/SourceMapHookPlugin.js +21 -33
  80. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  81. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  82. package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
  83. package/lib/plugins/index.js +100 -91
  84. package/lib/plugins/webpackwatchrunplugin.js +18 -30
  85. package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
  86. package/lib/schemas/index.js +336 -81
  87. package/lib/servers/clusterHubServer.js +22 -26
  88. package/lib/servers/docsServer.js +3 -5
  89. package/lib/servers/docsServerCore.js +84 -91
  90. package/lib/servers/helpServer.js +19 -21
  91. package/lib/servers/impactServer.js +99 -92
  92. package/lib/servers/mockserver.js +24 -24
  93. package/lib/servers/scrServer.js +78 -98
  94. package/lib/servers/server.js +101 -122
  95. package/lib/servers/ssServer.js +63 -61
  96. package/lib/sh/pre-commit.sh +34 -34
  97. package/lib/sh/reportPublish.sh +45 -46
  98. package/lib/templates/CoverageScriptTemplate.js +45 -18
  99. package/lib/templates/WMSTemplate.js +17 -18
  100. package/lib/templates/linterConstant.js +6 -4
  101. package/lib/utils/babelPresets.js +12 -5
  102. package/lib/utils/buildstats.html +148 -148
  103. package/lib/utils/clean.js +12 -11
  104. package/lib/utils/copy.js +12 -34
  105. package/lib/utils/copyTimezones.js +9 -16
  106. package/lib/utils/createEventStream.js +24 -19
  107. package/lib/utils/cssClassNameGenerate.js +44 -73
  108. package/lib/utils/cssURLReplacer.js +60 -54
  109. package/lib/utils/dependencyPostPublish.js +20 -19
  110. package/lib/utils/fileUtils.js +66 -54
  111. package/lib/utils/folderIterator.js +20 -21
  112. package/lib/utils/getComponents.js +70 -27
  113. package/lib/utils/getCurrentBranch.js +11 -17
  114. package/lib/utils/getDependenciesImpactList.js +114 -187
  115. package/lib/utils/getHash.js +9 -13
  116. package/lib/utils/getIp.js +9 -9
  117. package/lib/utils/getOptions.js +26 -29
  118. package/lib/utils/getServerURL.js +19 -10
  119. package/lib/utils/index.js +147 -126
  120. package/lib/utils/init.js +2 -2
  121. package/lib/utils/initPreCommitHook.js +40 -32
  122. package/lib/utils/jsonHelper.js +37 -21
  123. package/lib/utils/lint/addScripts.js +27 -0
  124. package/lib/utils/lint/checkExistingConfig.js +67 -0
  125. package/lib/utils/lint/copyConfigs.js +24 -0
  126. package/lib/utils/lint/index.js +54 -0
  127. package/lib/utils/lint/lintScripts.js +11 -0
  128. package/lib/utils/lint/lintSetup.js +31 -0
  129. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  130. package/lib/utils/lint/question.js +30 -0
  131. package/lib/utils/lintReporter.js +70 -56
  132. package/lib/utils/mailSender.js +12 -27
  133. package/lib/utils/pullOrigin.js +21 -18
  134. package/lib/utils/reinstallDependencies.js +76 -85
  135. package/lib/utils/removeAttributes.js +25 -23
  136. package/lib/utils/repoClone.js +47 -45
  137. package/lib/utils/request.js +64 -77
  138. package/lib/utils/resultSchema.json +73 -73
  139. package/lib/utils/rtl.js +22 -29
  140. package/lib/utils/setEnvVariables.js +5 -6
  141. package/lib/utils/ssTestHack.js +21 -19
  142. package/lib/utils/switchBranch.js +21 -20
  143. package/lib/utils/urlConcat.js +22 -0
  144. package/package.json +141 -136
  145. package/templates/app/.eslintrc.js +140 -140
  146. package/templates/app/README.md +12 -12
  147. package/templates/app/app/index.html +24 -24
  148. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  149. package/templates/app/app/properties/i18nkeys.json +3 -3
  150. package/templates/app/docs/all.html +69 -69
  151. package/templates/app/mockapi/index.js +18 -18
  152. package/templates/app/package.json +37 -37
  153. package/templates/app/src/actions/SampleActions/index.js +37 -37
  154. package/templates/app/src/actions/index.js +65 -65
  155. package/templates/app/src/appUrls.js +19 -19
  156. package/templates/app/src/components/Alert/Alert.js +134 -134
  157. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  158. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  159. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  160. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  161. package/templates/app/src/components/Sample/SampleList.js +61 -61
  162. package/templates/app/src/components/Slider/Slider.css +41 -41
  163. package/templates/app/src/components/Slider/Slider.js +55 -55
  164. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  165. package/templates/app/src/containers/AppContainer/index.js +96 -96
  166. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  167. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  168. package/templates/app/src/containers/DevTools/index.js +10 -10
  169. package/templates/app/src/containers/Header/index.js +67 -67
  170. package/templates/app/src/containers/Header/index.module.css +43 -43
  171. package/templates/app/src/containers/Redirect/index.js +63 -63
  172. package/templates/app/src/containers/Redirector/index.js +47 -47
  173. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  174. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  175. package/templates/app/src/historyChange.js +5 -5
  176. package/templates/app/src/index.html +10 -10
  177. package/templates/app/src/index.js +24 -24
  178. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  179. package/templates/app/src/reducers/alertData.js +11 -11
  180. package/templates/app/src/reducers/index.js +6 -6
  181. package/templates/app/src/reducers/samples.js +19 -19
  182. package/templates/app/src/store/configureStore.dev.js +51 -51
  183. package/templates/app/src/store/configureStore.js +5 -5
  184. package/templates/app/src/store/configureStore.prod.js +26 -26
  185. package/templates/app/src/util/Common.js +5 -5
  186. package/templates/app/src/util/RequestAPI.js +132 -132
  187. package/templates/docs/all.html +249 -249
  188. package/templates/docs/component.html +178 -178
  189. package/templates/docs/components.html +221 -221
  190. package/templates/docs/css/b.min.css +6 -6
  191. package/templates/docs/css/component.css +42 -42
  192. package/templates/docs/css/componentTest.css +6 -6
  193. package/templates/docs/css/hopscotch.css +585 -585
  194. package/templates/docs/css/style.css +1022 -1022
  195. package/templates/docs/index.html +1493 -1493
  196. package/templates/docs/js/active-line.js +72 -72
  197. package/templates/docs/js/b.min.js +7 -7
  198. package/templates/docs/js/codemirror.js +9680 -9680
  199. package/templates/docs/js/designTokens.js +334 -334
  200. package/templates/docs/js/j.min.js +4 -4
  201. package/templates/docs/js/javascript.js +874 -874
  202. package/templates/docs/js/matchbrackets.js +145 -145
@@ -1,28 +1,25 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _webpack = require('webpack');
8
+ var _webpack = _interopRequireDefault(require("webpack"));
8
9
 
9
- var _webpack2 = _interopRequireDefault(_webpack);
10
-
11
- var _caseSensitivePathsWebpackPlugin = require('case-sensitive-paths-webpack-plugin');
12
-
13
- var _caseSensitivePathsWebpackPlugin2 = _interopRequireDefault(_caseSensitivePathsWebpackPlugin);
10
+ var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
14
11
 
15
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
13
 
17
- var getProdPlugins = function getProdPlugins() {
18
- var plugins = [new _webpack2.default.optimize.ModuleConcatenationPlugin(), new _caseSensitivePathsWebpackPlugin2.default(), new _webpack2.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack2.default.DefinePlugin({
14
+ let getProdPlugins = () => {
15
+ let plugins = [new _webpack.default.optimize.ModuleConcatenationPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
19
16
  __TEST__: false,
20
17
  __DEVELOPMENT__: true,
21
18
  __DOCS__: false,
22
19
  __SERVER__: true
23
20
  })];
24
-
25
21
  return plugins;
26
22
  };
27
23
 
28
- exports.default = getProdPlugins;
24
+ var _default = getProdPlugins;
25
+ exports.default = _default;
@@ -1,27 +1,22 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _caseSensitivePathsWebpackPlugin = require('case-sensitive-paths-webpack-plugin');
8
+ var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
8
9
 
9
- var _caseSensitivePathsWebpackPlugin2 = _interopRequireDefault(_caseSensitivePathsWebpackPlugin);
10
+ var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
10
11
 
11
- var _miniCssExtractPlugin = require('mini-css-extract-plugin');
12
+ var _plugins = require("../plugins");
12
13
 
13
- var _miniCssExtractPlugin2 = _interopRequireDefault(_miniCssExtractPlugin);
14
-
15
- var _plugins = require('../plugins');
16
-
17
- var _webpack = require('webpack');
18
-
19
- var _webpack2 = _interopRequireDefault(_webpack);
14
+ var _webpack = _interopRequireDefault(require("webpack"));
20
15
 
21
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
17
 
23
- var getUMDCSSPlugins = function getUMDCSSPlugins() {
24
- var plugins = [new _caseSensitivePathsWebpackPlugin2.default(), new _webpack2.default.DefinePlugin({
18
+ let getUMDCSSPlugins = () => {
19
+ let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.DefinePlugin({
25
20
  __TEST__: false,
26
21
  __DEVELOPMENT__: false,
27
22
  __DOCS__: false,
@@ -29,11 +24,12 @@ var getUMDCSSPlugins = function getUMDCSSPlugins() {
29
24
  NODE_ENV: JSON.stringify('production')
30
25
  },
31
26
  __SERVER__: false
32
- }), new _miniCssExtractPlugin2.default({
27
+ }), new _miniCssExtractPlugin.default({
33
28
  filename: 'css/[name].css',
34
29
  chunkFilename: 'css/[id].css'
35
30
  }), new _plugins.UglifyCSSPlugin()];
36
31
  return plugins;
37
32
  };
38
33
 
39
- exports.default = getUMDCSSPlugins;
34
+ var _default = getUMDCSSPlugins;
35
+ exports.default = _default;
@@ -1,27 +1,22 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _caseSensitivePathsWebpackPlugin = require('case-sensitive-paths-webpack-plugin');
8
+ var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
8
9
 
9
- var _caseSensitivePathsWebpackPlugin2 = _interopRequireDefault(_caseSensitivePathsWebpackPlugin);
10
+ var _webpack = _interopRequireDefault(require("webpack"));
10
11
 
11
- var _webpack = require('webpack');
12
+ var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
12
13
 
13
- var _webpack2 = _interopRequireDefault(_webpack);
14
-
15
- var _miniCssExtractPlugin = require('mini-css-extract-plugin');
16
-
17
- var _miniCssExtractPlugin2 = _interopRequireDefault(_miniCssExtractPlugin);
18
-
19
- var _plugins = require('../plugins');
14
+ var _plugins = require("../plugins");
20
15
 
21
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
17
 
23
- var getUMDComponentPlugins = function getUMDComponentPlugins(isDocs) {
24
- var plugins = [new _caseSensitivePathsWebpackPlugin2.default(), new _webpack2.default.DefinePlugin({
18
+ let getUMDComponentPlugins = isDocs => {
19
+ let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.DefinePlugin({
25
20
  __TEST__: false,
26
21
  __DEVELOPMENT__: false,
27
22
  __DOCS__: isDocs ? true : false,
@@ -29,11 +24,12 @@ var getUMDComponentPlugins = function getUMDComponentPlugins(isDocs) {
29
24
  NODE_ENV: JSON.stringify('production')
30
25
  },
31
26
  __SERVER__: false
32
- }), new _miniCssExtractPlugin2.default({
27
+ }), new _miniCssExtractPlugin.default({
33
28
  filename: 'css/[name].css',
34
29
  chunkFilename: 'css/[name].css'
35
30
  }), new _plugins.UglifyCSSPlugin()];
36
31
  return plugins;
37
32
  };
38
33
 
39
- exports.default = getUMDComponentPlugins;
34
+ var _default = getUMDComponentPlugins;
35
+ exports.default = _default;
@@ -1,70 +1,63 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
- var _getDevPlugins = require('./getDevPlugins');
8
-
9
- Object.defineProperty(exports, 'getDevPlugins', {
6
+ Object.defineProperty(exports, "getDevPlugins", {
10
7
  enumerable: true,
11
- get: function get() {
12
- return _interopRequireDefault(_getDevPlugins).default;
8
+ get: function () {
9
+ return _getDevPlugins.default;
13
10
  }
14
11
  });
15
-
16
- var _getProdPlugins = require('./getProdPlugins');
17
-
18
- Object.defineProperty(exports, 'getProdPlugins', {
12
+ Object.defineProperty(exports, "getDocsPlugins", {
19
13
  enumerable: true,
20
- get: function get() {
21
- return _interopRequireDefault(_getProdPlugins).default;
14
+ get: function () {
15
+ return _getDocsPlugins.default;
22
16
  }
23
17
  });
24
-
25
- var _getDocsPlugins = require('./getDocsPlugins');
26
-
27
- Object.defineProperty(exports, 'getDocsPlugins', {
18
+ Object.defineProperty(exports, "getLibraryPlugins", {
28
19
  enumerable: true,
29
- get: function get() {
30
- return _interopRequireDefault(_getDocsPlugins).default;
20
+ get: function () {
21
+ return _getLibraryPlugins.default;
31
22
  }
32
23
  });
33
-
34
- var _getServerPlugins = require('./getServerPlugins');
35
-
36
- Object.defineProperty(exports, 'getServerPlugins', {
24
+ Object.defineProperty(exports, "getProdPlugins", {
37
25
  enumerable: true,
38
- get: function get() {
39
- return _interopRequireDefault(_getServerPlugins).default;
26
+ get: function () {
27
+ return _getProdPlugins.default;
40
28
  }
41
29
  });
42
-
43
- var _getLibraryPlugins = require('./getLibraryPlugins');
44
-
45
- Object.defineProperty(exports, 'getLibraryPlugins', {
30
+ Object.defineProperty(exports, "getServerPlugins", {
46
31
  enumerable: true,
47
- get: function get() {
48
- return _interopRequireDefault(_getLibraryPlugins).default;
32
+ get: function () {
33
+ return _getServerPlugins.default;
49
34
  }
50
35
  });
51
-
52
- var _getUMDComponentPlugins = require('./getUMDComponentPlugins');
53
-
54
- Object.defineProperty(exports, 'getUMDComponentPlugins', {
36
+ Object.defineProperty(exports, "getUMDCSSPlugins", {
55
37
  enumerable: true,
56
- get: function get() {
57
- return _interopRequireDefault(_getUMDComponentPlugins).default;
38
+ get: function () {
39
+ return _getUMDCSSPlugins.default;
58
40
  }
59
41
  });
60
-
61
- var _getUMDCSSPlugins = require('./getUMDCSSPlugins');
62
-
63
- Object.defineProperty(exports, 'getUMDCSSPlugins', {
42
+ Object.defineProperty(exports, "getUMDComponentPlugins", {
64
43
  enumerable: true,
65
- get: function get() {
66
- return _interopRequireDefault(_getUMDCSSPlugins).default;
44
+ get: function () {
45
+ return _getUMDComponentPlugins.default;
67
46
  }
68
47
  });
69
48
 
49
+ var _getDevPlugins = _interopRequireDefault(require("./getDevPlugins"));
50
+
51
+ var _getProdPlugins = _interopRequireDefault(require("./getProdPlugins"));
52
+
53
+ var _getDocsPlugins = _interopRequireDefault(require("./getDocsPlugins"));
54
+
55
+ var _getServerPlugins = _interopRequireDefault(require("./getServerPlugins"));
56
+
57
+ var _getLibraryPlugins = _interopRequireDefault(require("./getLibraryPlugins"));
58
+
59
+ var _getUMDComponentPlugins = _interopRequireDefault(require("./getUMDComponentPlugins"));
60
+
61
+ var _getUMDCSSPlugins = _interopRequireDefault(require("./getUMDCSSPlugins"));
62
+
70
63
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const MODULE_TYPE = 'css/mini-extract';
13
+
14
+ const isI18nFile = url => url.endsWith(".i18n.js");
15
+
16
+ class CdnChangePlugin {
17
+ constructor(options) {
18
+ this.i18nTemplate = options.i18nTemplate || '{{__I18N_CDN__}}';
19
+ this.variableName = options.variableName || '__CSS_CDN__';
20
+ this.cssTemplate = options.cssTemplate || '{{__CSS_CDN__}}';
21
+ this.jsTemplate = options.jsTemplate || '{{__JS_CDN__}}';
22
+ }
23
+
24
+ getCssChunkObject(mainChunk) {
25
+ const obj = {};
26
+
27
+ for (const chunk of mainChunk.getAllAsyncChunks()) {
28
+ for (const module of chunk.modulesIterable) {
29
+ if (module.type === MODULE_TYPE) {
30
+ obj[chunk.id] = 1;
31
+ break;
32
+ }
33
+ }
34
+ }
35
+
36
+ return obj;
37
+ }
38
+
39
+ apply(compiler) {
40
+ compiler.hooks.thisCompilation.tap('CdnChangePlugin', compilation => {
41
+ compilation.mainTemplate.hooks.requireEnsure.tap('CdnChangePlugin', (source, chunk) => {
42
+ const chunkMap = this.getCssChunkObject(chunk);
43
+
44
+ if (Object.keys(chunkMap).length > 0) {
45
+ return source.replace('__webpack_require__.p', `window['${this.variableName}']`);
46
+ }
47
+ });
48
+ });
49
+ compiler.hooks.make.tap('CdnChangePlugin', compilation => {
50
+ _htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tapAsync('CdnChangePlugin', (data, cb) => {
51
+ data.assets = Object.assign({}, data.assets, {
52
+ css: data.assets.css.map(css => `${this.cssTemplate}${css}`),
53
+ js: data.assets.js.map(js => `${isI18nFile(js) ? this.i18nTemplate : this.jsTemplate}${js}`)
54
+ });
55
+ cb(null, data);
56
+ });
57
+ });
58
+ }
59
+
60
+ }
61
+
62
+ var _default = CdnChangePlugin;
63
+ exports.default = _default;
@@ -1,42 +1,28 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
-
11
- var CleanUpStatsPlugin = function () {
12
- function CleanUpStatsPlugin() {
13
- _classCallCheck(this, CleanUpStatsPlugin);
8
+ class CleanUpStatsPlugin {
9
+ shouldPickStatChild(child) {
10
+ return child.name.indexOf('mini-css-extract-plugin') !== 0;
14
11
  }
15
12
 
16
- _createClass(CleanUpStatsPlugin, [{
17
- key: 'shouldPickStatChild',
18
- value: function shouldPickStatChild(child) {
19
- return child.name.indexOf('mini-css-extract-plugin') !== 0;
20
- }
21
- }, {
22
- key: 'apply',
23
- value: function apply(compiler) {
24
- var _this = this;
25
-
26
- compiler.hooks.done.tap('CleanUpStatsPlugin', function (stats) {
27
- var children = stats.compilation.children;
28
-
29
- if (Array.isArray(children)) {
30
- // eslint-disable-next-line no-param-reassign
31
- stats.compilation.children = children.filter(function (child) {
32
- return _this.shouldPickStatChild(child);
33
- });
34
- }
35
- });
36
- }
37
- }]);
13
+ apply(compiler) {
14
+ compiler.hooks.done.tap('CleanUpStatsPlugin', stats => {
15
+ const {
16
+ children
17
+ } = stats.compilation;
18
+
19
+ if (Array.isArray(children)) {
20
+ // eslint-disable-next-line no-param-reassign
21
+ stats.compilation.children = children.filter(child => this.shouldPickStatChild(child));
22
+ }
23
+ });
24
+ }
38
25
 
39
- return CleanUpStatsPlugin;
40
- }();
26
+ }
41
27
 
42
28
  exports.default = CleanUpStatsPlugin;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CustomAttributePlugin = void 0;
7
+
8
+ var _Template = _interopRequireDefault(require("webpack/lib/Template"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ /* eslint-disable no-use-before-define */
13
+ class CustomAttributePlugin {
14
+ constructor(options) {
15
+ this.options = {
16
+ jsAttributes: options.jsAttributes || options.attributes || {},
17
+ cssAttributes: options.cssAttributes || options.attributes || {},
18
+ i18nAttributes: options.i18nAttributes || options.attributes || {}
19
+ };
20
+ }
21
+
22
+ addCustomAttributeToDynamicScriptTags(mainTemplate) {
23
+ const {
24
+ jsAttributes,
25
+ cssAttributes,
26
+ i18nAttributes
27
+ } = this.options; // NOTE: To add custom Attributes to js Script tags
28
+
29
+ mainTemplate.hooks.jsonpScript.tap('CustomAttributePlugin', source => {
30
+ const str = attributeSetTemplate(jsAttributes, 'script');
31
+ return _Template.default.asString([source, ...str]);
32
+ }); // NOTE: To add custom Attributes to css link tags
33
+
34
+ mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
35
+ const str = attributeSetTemplate(cssAttributes, 'linkTag');
36
+ const replacedStr = source.replace('head.appendChild(linkTag);', `${str.join('')}head.appendChild(linkTag);`);
37
+ console.log({
38
+ s: source,
39
+ r: replacedStr
40
+ });
41
+ return replacedStr;
42
+ }); // NOTE: To add custom Attributes to i18n split js Script tags
43
+
44
+ mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
45
+ const str = attributeSetTemplate(i18nAttributes, 'scriptTag');
46
+ const replacedStr = source.replace('document.body.appendChild(scriptTag);', `${str.join('')}document.body.appendChild(scriptTag);`);
47
+ console.log({
48
+ s: source,
49
+ r: replacedStr
50
+ });
51
+ return replacedStr;
52
+ });
53
+ }
54
+
55
+ apply(compiler) {
56
+ compiler.hooks.thisCompilation.tap({
57
+ name: 'CustomAttributePlugin',
58
+ stage: 1,
59
+ fn: compilation => {
60
+ this.addCustomAttributeToDynamicScriptTags(compilation.mainTemplate);
61
+ }
62
+ });
63
+ }
64
+
65
+ }
66
+
67
+ exports.CustomAttributePlugin = CustomAttributePlugin;
68
+
69
+ function attributeSetTemplate(jsAttributes, variableName) {
70
+ let str = [];
71
+ Object.keys(jsAttributes).forEach(key => {
72
+ const val = jsAttributes[key];
73
+ str.push(`${variableName}.setAttribute(${JSON.stringify(key)}, ${JSON.stringify(val)});`);
74
+ });
75
+ console.log({
76
+ str
77
+ });
78
+ return str;
79
+ }
@@ -0,0 +1,35 @@
1
+ # CustomAttributePlugin
2
+ In this plugin we added all dynamic chunks tags (like js script tags , css script tags, i18n split script tags) to extra custom attribute
3
+
4
+ ## Options
5
+
6
+ ```json
7
+ {
8
+ "name": "some",
9
+ "react-cli": {
10
+ "app": {
11
+ "customAttributes": {// this is the all options
12
+ "enable": false,
13
+ "attributes": null,
14
+ "jsAttributes": null,
15
+ "cssAttributes": null,
16
+ "i18nAttributes": null
17
+ }
18
+ }
19
+ }
20
+ ```
21
+
22
+ ### enable [Boolean]
23
+ this decides is this plugin or feature needs to be enabled of not.
24
+
25
+
26
+ ### attributes [Object]
27
+ It was object of key value pairs Example Given Option {"data-app-name":"myapp"}
28
+ Then all dynamically (js script tags , css script tags, i18n split script tags) added tags via webpack
29
+
30
+ ### jsAttributes [Object]
31
+ same as [attributes] but only for js script tags
32
+ ### cssAttributes [Object]
33
+ same as [attributes] but only for css script tags
34
+ ### i18nAttributes [Object]
35
+ same as [attributes] but only for i18n split script tags
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _webpackSources = require("webpack-sources");
9
+
10
+ var _utils = require("../utils");
11
+
12
+ var _path = _interopRequireDefault(require("path"));
13
+
14
+ var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
19
+ const cliOptions = (0, _utils.getOptions)();
20
+ const {
21
+ app: {
22
+ publicPaths
23
+ },
24
+ i18n: {
25
+ chunkSplitEnable
26
+ },
27
+ efc: efcOptios
28
+ } = cliOptions;
29
+ const {
30
+ createSDkFile
31
+ } = efcOptios;
32
+
33
+ class EFCPlugin {
34
+ constructor(options = {}) {
35
+ this.isDevelopment = options.isDevelopment;
36
+ this.serverUrl = options.serverUrl;
37
+ this.i18nFileNameTemplate = options.i18nFileNameTemplate; // this.i18nManifestFileName = options.i18nManifestFileName;
38
+
39
+ this.options = Object.assign({}, options); // this.options.i18nManifestFileName = options.i18nManifestFileName;
40
+
41
+ this.options.entryPointName = options.entryPointName || 'efc';
42
+ this.options.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
43
+ this.options.nameScope = options.nameScope || 'EFComponents';
44
+ this.options.localeAttr = options.localeAttr || 'efc-locale';
45
+ } // NOTE: this logic may be needed for contenthash cases
46
+ // getI18nManifest(compilation) {
47
+ // const i18nManifestFile =
48
+ // compilation.assets[this.options.i18nManifestFileName];
49
+ // if (i18nManifestFile) {
50
+ // const manifest = JSON.parse(i18nManifestFile.source());
51
+ // return manifest;
52
+ // }
53
+ // return {};
54
+ // }
55
+
56
+
57
+ getI18nAssetsStr(entryPoint, compilation) {
58
+ if (!chunkSplitEnable) {
59
+ let i18nAsstes = {};
60
+ let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
61
+
62
+ i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
63
+ let fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
64
+ let splittedFileName = fileName.split('.');
65
+ res[splittedFileName[0]] = i18nFilePath;
66
+ return res;
67
+ }, {});
68
+ return `[${JSON.stringify(i18nAsstes)}[lang]]`;
69
+ }
70
+
71
+ let initalI18nAssets = entryPoint.chunks.map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
72
+ return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
73
+ }
74
+
75
+ createFileContent(compilation) {
76
+ const {
77
+ entryPointName,
78
+ localeAttr,
79
+ nameScope,
80
+ cdnVariableName = null
81
+ } = this.options;
82
+ const {
83
+ serverUrl
84
+ } = this; // const i18nManifest = this.getI18nManifest(compilation);
85
+
86
+ const entryPoint = compilation.entrypoints.get(entryPointName); // const chunk = compilation.namedChunks.get(entryPointName);
87
+
88
+ const [jsPath, cssPath,,, i18nJsPath] = !this.isDevelopment ? publicPaths : [];
89
+ const initialFiles = entryPoint.getFiles();
90
+ const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file)); // const i18nAssets = getShortI18nAssets(
91
+ // entryPoint.chunks,
92
+ // i18nManifest,
93
+ // i18nJsPath
94
+ // );
95
+
96
+ const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, i18nJsPath);
97
+ return `(() => {
98
+ let langEle = document.querySelector("[${localeAttr}]");
99
+ let lang = langEle ? langEle.getAttribute('${localeAttr}') : 'en_US';
100
+ let prod = !${this.isDevelopment};
101
+ let cdnVariableName = "${cdnVariableName}";
102
+ let assetURLs = {
103
+ //hook
104
+ js: ${JSON.stringify(jsPath || serverUrl)},
105
+ css: ${JSON.stringify(cssPath || serverUrl)},
106
+ i18n: ${JSON.stringify(i18nJsPath || serverUrl)}
107
+ };
108
+
109
+ window.desk_urls={}
110
+ window.desk_urls.staticDomain = 'https:' + assetURLs.js + '/';
111
+ if (prod && cdnVariableName) {
112
+ window["${cdnVariableName}"] = 'https:' + assetURLs.css + '/';
113
+ }
114
+
115
+ let initalI18nAssets = ${initalI18nAssets}.map(urlpath => "${i18nJsPath}/"+ urlpath);
116
+ let initialAssets = initalI18nAssets.concat(${JSON.stringify(filteredInitialFiles)});
117
+
118
+ let loadAsset = (id, type, url) => {
119
+ return new Promise((res, rej) => {
120
+ let el = document.createElement(type);
121
+ // el.id = id;
122
+ el.onload = res;
123
+ el.error = rej;
124
+ switch(type) {
125
+ case 'script':
126
+ case 'i18n':
127
+ el.src = (type === 'i18n'? assetURLs.i18n : assetURLs.js)+'/'+url
128
+ el.defer = 'defer';
129
+ document.body.appendChild(el);
130
+ break;
131
+ case 'link':
132
+ el.href = assetURLs.css+'/'+url
133
+ el.rel = 'stylesheet';
134
+ document.head.appendChild(el);
135
+ break;
136
+ }
137
+ });
138
+ };
139
+
140
+ let memorizedPromise = null;
141
+ ${nameScope}.onload = (cb, err) => {
142
+ if(!memorizedPromise) {
143
+ memorizedPromise = Promise.all(
144
+ initialAssets.map(
145
+ (url, index) => loadAsset(
146
+ "${nameScope}-" + (url.endsWith("js") ? "js" : "css") +"-"+index,
147
+ url.endsWith("js") ? url.endsWith(".i18n.js") ? "i18n" : 'script' : 'link',
148
+ url
149
+ )
150
+ )
151
+ ).then(() => ${nameScope}.onBasicLoad(cb));
152
+ }
153
+ return memorizedPromise;
154
+ };
155
+
156
+ })();
157
+ `;
158
+ }
159
+
160
+ apply(compiler) {
161
+ if (!createSDkFile) {
162
+ return;
163
+ }
164
+
165
+ compiler.hooks.emit.tap('EFCPlugin', compilation => {
166
+ const {
167
+ entryPointName,
168
+ outputFile
169
+ } = this.options;
170
+ const entryPoint = compilation.entrypoints.get(entryPointName);
171
+
172
+ if (!entryPoint) {
173
+ return;
174
+ }
175
+
176
+ const source = new _webpackSources.RawSource(this.createFileContent(compilation));
177
+ compilation.assets[outputFile] = source; // eslint-disable-next-line no-console
178
+
179
+ console.log('The EFC embedded code was created successfully..!!!');
180
+ });
181
+ }
182
+
183
+ }
184
+
185
+ exports.default = EFCPlugin;