@zohodesk/react-cli 0.0.1-beta.98 → 0.0.1-betaa.138.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 (139) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +149 -0
  3. package/bin/cli.js +34 -29
  4. package/files/eslintrc.js +57 -0
  5. package/files/prettierrc.js +3 -0
  6. package/lib/babel/cmjs-plugins-presets.js +16 -9
  7. package/lib/babel/es-plugins-presets.js +26 -14
  8. package/lib/common/getEntries.js +31 -22
  9. package/lib/common/getPublicPathConfig.js +27 -13
  10. package/lib/common/index.js +21 -25
  11. package/lib/common/splitChunks.js +62 -53
  12. package/lib/common/templateParameters.js +10 -8
  13. package/lib/configs/jest.config.js +15 -25
  14. package/lib/configs/webpack.component.umd.config.js +31 -37
  15. package/lib/configs/webpack.css.umd.config.js +44 -47
  16. package/lib/configs/webpack.dev.config.js +70 -52
  17. package/lib/configs/webpack.docs.config.js +106 -106
  18. package/lib/configs/webpack.prod.config.js +95 -75
  19. package/lib/hooks/docsProptypeHook.js +32 -38
  20. package/lib/jest/commitedFilesResult.js +103 -74
  21. package/lib/jest/coverageCollector.js +41 -21
  22. package/lib/jest/jsonMaker.js +15 -16
  23. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  24. package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
  25. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  26. package/lib/jest/result.js +90 -45
  27. package/lib/jest/run.js +43 -43
  28. package/lib/jest/setup.js +102 -95
  29. package/lib/loaderUtils/getCSSLoaders.js +21 -22
  30. package/lib/loaderUtils/getDevJsLoaders.js +25 -23
  31. package/lib/loaderUtils/index.js +11 -13
  32. package/lib/loaders/docsLoader.js +15 -15
  33. package/lib/loaders/docsPropsLoader.js +14 -17
  34. package/lib/loaders/fileLoader.js +33 -35
  35. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  36. package/lib/loaders/workerLoader.js +136 -0
  37. package/lib/middlewares/HMRMiddleware.js +54 -45
  38. package/lib/middlewares/SSTMiddleware.js +8 -5
  39. package/lib/pluginUtils/getDevPlugins.js +114 -52
  40. package/lib/pluginUtils/getDocsPlugins.js +25 -29
  41. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  42. package/lib/pluginUtils/getProdPlugins.js +163 -74
  43. package/lib/pluginUtils/getServerPlugins.js +8 -11
  44. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  45. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  46. package/lib/pluginUtils/index.js +36 -43
  47. package/lib/plugins/CdnChangePlugin.js +63 -0
  48. package/lib/plugins/CleanupStatsPlugin.js +18 -32
  49. package/lib/plugins/CustomAttributePlugin.js +79 -0
  50. package/lib/plugins/CustomAttributePlugin.md +35 -0
  51. package/lib/plugins/EFCPlugin.js +185 -0
  52. package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
  53. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  54. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  55. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  56. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  57. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  58. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  59. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  60. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  61. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  62. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  63. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  64. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  65. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  66. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  67. package/lib/plugins/ManifestPlugin.js +52 -63
  68. package/lib/plugins/ModuleStatsPlugin.js +83 -173
  69. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  70. package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
  71. package/lib/plugins/PublicPathChangePlugin.js +175 -284
  72. package/lib/plugins/ReportGeneratePlugin.js +150 -151
  73. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  74. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  75. package/lib/plugins/ServiceWorkerPlugin.js +81 -57
  76. package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
  77. package/lib/plugins/SourceMapHookPlugin.js +21 -33
  78. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  79. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  80. package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
  81. package/lib/plugins/index.js +100 -91
  82. package/lib/plugins/webpackwatchrunplugin.js +18 -30
  83. package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
  84. package/lib/schemas/index.js +336 -81
  85. package/lib/servers/clusterHubServer.js +22 -26
  86. package/lib/servers/docsServer.js +3 -5
  87. package/lib/servers/docsServerCore.js +84 -91
  88. package/lib/servers/helpServer.js +19 -21
  89. package/lib/servers/impactServer.js +99 -92
  90. package/lib/servers/mockserver.js +24 -24
  91. package/lib/servers/scrServer.js +78 -98
  92. package/lib/servers/server.js +101 -122
  93. package/lib/servers/ssServer.js +63 -61
  94. package/lib/sh/reportPublish.sh +1 -2
  95. package/lib/templates/CoverageScriptTemplate.js +45 -18
  96. package/lib/templates/WMSTemplate.js +17 -18
  97. package/lib/templates/linterConstant.js +6 -4
  98. package/lib/utils/babelPresets.js +12 -5
  99. package/lib/utils/clean.js +12 -11
  100. package/lib/utils/copy.js +12 -34
  101. package/lib/utils/copyTimezones.js +9 -16
  102. package/lib/utils/createEventStream.js +24 -19
  103. package/lib/utils/cssClassNameGenerate.js +44 -73
  104. package/lib/utils/cssURLReplacer.js +62 -56
  105. package/lib/utils/dependencyPostPublish.js +20 -19
  106. package/lib/utils/fileUtils.js +66 -54
  107. package/lib/utils/folderIterator.js +20 -21
  108. package/lib/utils/getComponents.js +70 -27
  109. package/lib/utils/getCurrentBranch.js +11 -17
  110. package/lib/utils/getDependenciesImpactList.js +114 -187
  111. package/lib/utils/getHash.js +9 -13
  112. package/lib/utils/getIp.js +9 -9
  113. package/lib/utils/getOptions.js +26 -29
  114. package/lib/utils/getServerURL.js +19 -10
  115. package/lib/utils/index.js +147 -126
  116. package/lib/utils/init.js +2 -2
  117. package/lib/utils/initPreCommitHook.js +40 -32
  118. package/lib/utils/jsonHelper.js +37 -21
  119. package/lib/utils/lint/addScripts.js +27 -0
  120. package/lib/utils/lint/checkExistingConfig.js +67 -0
  121. package/lib/utils/lint/copyConfigs.js +24 -0
  122. package/lib/utils/lint/index.js +54 -0
  123. package/lib/utils/lint/lintScripts.js +11 -0
  124. package/lib/utils/lint/lintSetup.js +31 -0
  125. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  126. package/lib/utils/lint/question.js +30 -0
  127. package/lib/utils/lintReporter.js +70 -56
  128. package/lib/utils/mailSender.js +12 -27
  129. package/lib/utils/pullOrigin.js +21 -18
  130. package/lib/utils/reinstallDependencies.js +76 -85
  131. package/lib/utils/removeAttributes.js +25 -23
  132. package/lib/utils/repoClone.js +47 -45
  133. package/lib/utils/request.js +64 -77
  134. package/lib/utils/rtl.js +22 -29
  135. package/lib/utils/setEnvVariables.js +5 -6
  136. package/lib/utils/ssTestHack.js +21 -19
  137. package/lib/utils/switchBranch.js +21 -20
  138. package/lib/utils/urlConcat.js +22 -0
  139. package/package.json +72 -67
@@ -1,29 +1,29 @@
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 _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
8
+ var _fs = _interopRequireDefault(require("fs"));
8
9
 
9
- 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; }; }();
10
+ var _path = _interopRequireDefault(require("path"));
10
11
 
11
- var _fs = require('fs');
12
+ var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
12
13
 
13
- var _fs2 = _interopRequireDefault(_fs);
14
-
15
- var _path = require('path');
16
-
17
- var _path2 = _interopRequireDefault(_path);
14
+ var _utils = require("../utils");
18
15
 
19
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
17
 
21
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
-
23
- var ServiceWorkerPlugin = function () {
24
- function ServiceWorkerPlugin(options) {
25
- _classCallCheck(this, ServiceWorkerPlugin);
18
+ const {
19
+ i18n: {
20
+ chunkSplitEnable
21
+ }
22
+ } = (0, _utils.getOptions)();
26
23
 
24
+ class ServiceWorkerPlugin {
25
+ constructor(options) {
26
+ this.i18nFileNameTemplate = options.i18nFileNameTemplate;
27
27
  this.fileName = options.fileName;
28
28
  this.serviceWorkerPath = options.filePath;
29
29
  this.writePath = options.exitPath;
@@ -31,54 +31,78 @@ var ServiceWorkerPlugin = function () {
31
31
  this.publicPaths = options.publicPaths;
32
32
  }
33
33
 
34
- _createClass(ServiceWorkerPlugin, [{
35
- key: 'apply',
36
- value: function apply(compiler) {
37
- var _this = this;
38
-
39
- compiler.hooks.emit.tap('ServiceWorkerPlugin', function (compilation) {
40
- _fs2.default.readFile(_this.serviceWorkerPath, 'utf-8', function (err, data) {
41
- if (err) {
42
- throw new Error(err);
43
- } else {
44
- var extractedChunks = compilation.chunks.filter(function (chunk) {
45
- if ('canBeInitial' in chunk) {
46
- return chunk.canBeInitial();
47
- }
48
- return chunk.isInitial();
49
- });
50
-
51
- var _publicPaths = _slicedToArray(_this.publicPaths, 2),
52
- js = _publicPaths[0],
53
- css = _publicPaths[1];
54
-
55
- var allFiles = [];
56
- extractedChunks.forEach(function (chunk) {
57
- chunk.files.forEach(function (fileName) {
58
- var chunkUrl = '';
59
- if (/\.css$/g.test(fileName)) {
60
- chunkUrl += css + '/' + fileName;
61
- } else if (/\.js$/g.test(fileName)) {
62
- chunkUrl += js + '/' + fileName;
63
- }
64
- allFiles.push(chunkUrl);
65
- });
66
- });
34
+ isInitialChunk(chunk) {
35
+ if ('canBeInitial' in chunk) {
36
+ return chunk.canBeInitial();
37
+ }
67
38
 
68
- var mod = data.replace(_this.replaceText, 'self.assets = ' + JSON.stringify(allFiles));
39
+ return chunk.isInitial();
40
+ }
69
41
 
70
- if (!_fs2.default.existsSync(_this.writePath)) {
71
- _fs2.default.mkdirSync(_this.writePath);
42
+ apply(compiler) {
43
+ compiler.hooks.emit.tap('ServiceWorkerPlugin', compilation => {
44
+ _fs.default.readFile(this.serviceWorkerPath, 'utf-8', (err, data) => {
45
+ if (err) {
46
+ throw new Error(err);
47
+ } else {
48
+ /* const extractedChunks = compilation.chunks.filter(chunk => {
49
+ if ('canBeInitial' in chunk) {
50
+ return chunk.canBeInitial();
72
51
  }
73
-
74
- _fs2.default.writeFileSync(_path2.default.join(_this.writePath, _this.fileName), mod);
52
+ return chunk.isInitial();
53
+ }); */
54
+ let [js, css,,, i18nPublicPath] = this.publicPaths; // let initialChunkUrls = [];
55
+
56
+ let allChunkUrls = [];
57
+ let allI18nAssets = [];
58
+ let entrypoint = compilation.entrypoints.get('main');
59
+ let initialChunkUrls = entrypoint.getFiles();
60
+ /**
61
+ * NOTE:
62
+ * if chunkSplitEnable is false means,
63
+ * serviceWorker will get i18n files path for html
64
+ */
65
+
66
+ let initalI18nAssets = chunkSplitEnable ? entrypoint.chunks.map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')) : [];
67
+ compilation.chunks.filter(c => !this.isInitialChunk(c)).forEach(chunk => {
68
+ // let isInitial = this.isInitialChunk(chunk);
69
+ allChunkUrls = allChunkUrls.concat(chunk.files);
70
+ chunkSplitEnable && allI18nAssets.push((0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')); // chunk.files.forEach(fileName => {
71
+ // let chunkUrl = '';
72
+ // if (/\.css$/g.test(fileName)) {
73
+ // chunkUrl += `${css}${fileName}`;
74
+ // } else if (/\.js$/g.test(fileName)) {
75
+ // chunkUrl += `${js}${fileName}`;
76
+ // }
77
+ // // isInitial ? initialChunkUrls.push(chunkUrl) :
78
+ // allChunkUrls.push(chunkUrl);
79
+ // });
80
+ });
81
+ let mod = data.replace(this.replaceText, `
82
+ function addPublicPath(url) {
83
+ if (/\\.css$/g.test(url)) {
84
+ return '${css}'+url;
85
+ } else if (/\\.js$/g.test(url)) {
86
+ return '${js}'+url;
87
+ }
88
+ }
89
+ self.initalI18nAssets = ${JSON.stringify(initalI18nAssets)}.map(up => "${i18nPublicPath}/" + up);
90
+ self.allI18nAssets = ${JSON.stringify(allI18nAssets)}.map(up => "${i18nPublicPath}/" + up);
91
+ self.assets = ${JSON.stringify(initialChunkUrls)}.map(addPublicPath);
92
+ self.allChunks = ${JSON.stringify(allChunkUrls)}.map(addPublicPath);`);
93
+
94
+ if (!_fs.default.existsSync(this.writePath)) {
95
+ _fs.default.mkdirSync(this.writePath, {
96
+ recursive: true
97
+ });
75
98
  }
76
- });
99
+
100
+ _fs.default.writeFileSync(_path.default.join(this.writePath, this.fileName), mod);
101
+ }
77
102
  });
78
- }
79
- }]);
103
+ });
104
+ }
80
105
 
81
- return ServiceWorkerPlugin;
82
- }();
106
+ }
83
107
 
84
108
  exports.default = ServiceWorkerPlugin;