@zohodesk/react-cli 0.0.1-beta.98 → 0.0.1-betaa.138.1

Sign up to get free protection for your applications and to get access to all the features.
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,214 +1,124 @@
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
+ var _path = _interopRequireDefault(require("path"));
8
9
 
9
- 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"); } }; }();
10
-
11
- var _path = require('path');
12
-
13
- var _path2 = _interopRequireDefault(_path);
14
-
15
- var _webpackSources = require('webpack-sources');
10
+ var _webpackSources = require("webpack-sources");
16
11
 
17
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
13
 
19
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
-
21
- var isValidModule = function isValidModule(name) {
22
- if (name.includes('node_modules') && (name.includes('@zohodesk' + _path2.default.sep + 'components') || name.includes('@zohodesk' + _path2.default.sep + 'dot')) && !name.endsWith('index.js') && !name.endsWith('docs.js')) {
14
+ let isValidModule = name => {
15
+ if (name.includes('node_modules') && (name.includes(`@zohodesk${_path.default.sep}components`) || name.includes(`@zohodesk${_path.default.sep}dot`)) && !name.endsWith('index.js') && !name.endsWith('docs.js')) {
23
16
  return true;
24
17
  }
25
18
 
26
19
  return !name.includes('index.js') && !name.endsWith('.css') && !name.endsWith('.png') && !name.includes('node_modules') && name.includes('src');
27
20
  };
28
21
 
29
- var getModuleName = function getModuleName(modulePath) {
30
- var _path$parse$name$spli = _path2.default.parse(modulePath).name.split('.'),
31
- _path$parse$name$spli2 = _slicedToArray(_path$parse$name$spli, 1),
32
- name = _path$parse$name$spli2[0];
22
+ let getModuleName = modulePath => {
23
+ let [name] = _path.default.parse(modulePath).name.split('.');
33
24
 
34
- if (modulePath.includes('@zohodesk' + _path2.default.sep + 'components')) {
35
- name = '@zohodesk/components/' + name;
36
- } else if (modulePath.includes('@zohodesk' + _path2.default.sep + 'dot')) {
37
- name = '@zohodesk/dot/' + name;
25
+ if (modulePath.includes(`@zohodesk${_path.default.sep}components`)) {
26
+ name = `@zohodesk/components/${name}`;
27
+ } else if (modulePath.includes(`@zohodesk${_path.default.sep}dot`)) {
28
+ name = `@zohodesk/dot/${name}`;
38
29
  }
30
+
39
31
  return name;
40
32
  };
41
33
 
42
- var ModuleStatsPlugin = function () {
43
- function ModuleStatsPlugin() {
44
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
45
-
46
- _classCallCheck(this, ModuleStatsPlugin);
47
-
34
+ class ModuleStatsPlugin {
35
+ constructor(options = {}) {
48
36
  this.options = options;
49
37
  this.options.filename = options.filename || 'js/moduleStats.js';
50
38
  }
51
39
 
52
- _createClass(ModuleStatsPlugin, [{
53
- key: 'apply',
54
- value: function apply(compiler) {
55
- var _this = this;
56
-
57
- compiler.hooks.emit.tap('ModuleStatsPlugin', function (compilation) {
58
- var stats = compilation.getStats().toJson();
59
- var results = {};
60
- var modules = stats.modules;
61
-
62
- var _loop = function _loop(module) {
63
- var name = module.name,
64
- reasons = module.reasons;
65
-
66
- if (isValidModule(name)) {
67
- var references = new Set();
68
- var referencedby = new Set();
69
- var docsName = void 0;
70
- compilation.modules.forEach(function (module) {
71
- module.reasons.forEach(function (reason) {
72
- var exportedValue = reason.dependency;
73
- if (exportedValue.type === 'harmony export imported specifier') {
74
- if (exportedValue.module.userRequest.includes(name.replace('.', ''))) {
75
- docsName = exportedValue.name;
76
- }
40
+ apply(compiler) {
41
+ compiler.hooks.emit.tap('ModuleStatsPlugin', compilation => {
42
+ let stats = compilation.getStats().toJson();
43
+ let results = {};
44
+ let {
45
+ modules
46
+ } = stats;
47
+
48
+ for (let module of modules) {
49
+ let {
50
+ name,
51
+ reasons
52
+ } = module;
53
+
54
+ if (isValidModule(name)) {
55
+ let references = new Set();
56
+ let referencedby = new Set();
57
+ let docsName;
58
+ let fileName;
59
+ compilation.modules.forEach(module => {
60
+ module.reasons.forEach(reason => {
61
+ let exportedValue = reason.dependency;
62
+
63
+ if (exportedValue.type === 'harmony export imported specifier') {
64
+ if (exportedValue.module.userRequest.includes(name.replace('.', ''))) {
65
+ docsName = exportedValue.name;
77
66
  }
78
- });
67
+ }
79
68
  });
69
+ });
70
+ let currentModuleName = getModuleName(name);
71
+
72
+ if (Array.isArray(reasons)) {
73
+ for (let reason of reasons) {
74
+ let {
75
+ moduleName
76
+ } = reason;
77
+
78
+ if (isValidModule(moduleName)) {
79
+ let reasonedModuleName = getModuleName(moduleName);
80
+ referencedby.add(reasonedModuleName);
81
+ }
82
+ }
83
+ }
80
84
 
81
- var currentModuleName = getModuleName(name);
82
- if (Array.isArray(reasons)) {
83
- var _iteratorNormalCompletion2 = true;
84
- var _didIteratorError2 = false;
85
- var _iteratorError2 = undefined;
85
+ for (let subModule of modules) {
86
+ let {
87
+ name: subModuleName,
88
+ reasons
89
+ } = subModule;
86
90
 
87
- try {
88
- for (var _iterator2 = reasons[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
89
- var reason = _step2.value;
90
- var moduleName = reason.moduleName;
91
+ if (isValidModule(subModuleName)) {
92
+ let currentModuleName = getModuleName(subModuleName);
91
93
 
94
+ if (Array.isArray(reasons)) {
95
+ for (let reason of reasons) {
96
+ let {
97
+ moduleName: reasonedModuleName
98
+ } = reason;
92
99
 
93
- if (isValidModule(moduleName)) {
94
- var reasonedModuleName = getModuleName(moduleName);
95
- referencedby.add(reasonedModuleName);
96
- }
97
- }
98
- } catch (err) {
99
- _didIteratorError2 = true;
100
- _iteratorError2 = err;
101
- } finally {
102
- try {
103
- if (!_iteratorNormalCompletion2 && _iterator2.return) {
104
- _iterator2.return();
105
- }
106
- } finally {
107
- if (_didIteratorError2) {
108
- throw _iteratorError2;
100
+ if (name === reasonedModuleName) {
101
+ references.add(currentModuleName);
109
102
  }
110
103
  }
111
104
  }
112
105
  }
113
- var _iteratorNormalCompletion3 = true;
114
- var _didIteratorError3 = false;
115
- var _iteratorError3 = undefined;
116
-
117
- try {
118
- for (var _iterator3 = modules[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
119
- var subModule = _step3.value;
120
- var subModuleName = subModule.name,
121
- _reasons = subModule.reasons;
122
-
123
- if (isValidModule(subModuleName)) {
124
- var _currentModuleName = getModuleName(subModuleName);
125
- if (Array.isArray(_reasons)) {
126
- var _iteratorNormalCompletion4 = true;
127
- var _didIteratorError4 = false;
128
- var _iteratorError4 = undefined;
129
-
130
- try {
131
- for (var _iterator4 = _reasons[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
132
- var _reason = _step4.value;
133
- var _reasonedModuleName = _reason.moduleName;
134
-
135
- if (name === _reasonedModuleName) {
136
- references.add(_currentModuleName);
137
- }
138
- }
139
- } catch (err) {
140
- _didIteratorError4 = true;
141
- _iteratorError4 = err;
142
- } finally {
143
- try {
144
- if (!_iteratorNormalCompletion4 && _iterator4.return) {
145
- _iterator4.return();
146
- }
147
- } finally {
148
- if (_didIteratorError4) {
149
- throw _iteratorError4;
150
- }
151
- }
152
- }
153
- }
154
- }
155
- }
156
- } catch (err) {
157
- _didIteratorError3 = true;
158
- _iteratorError3 = err;
159
- } finally {
160
- try {
161
- if (!_iteratorNormalCompletion3 && _iterator3.return) {
162
- _iterator3.return();
163
- }
164
- } finally {
165
- if (_didIteratorError3) {
166
- throw _iteratorError3;
167
- }
168
- }
169
- }
170
-
171
- results[currentModuleName] = {
172
- name: currentModuleName,
173
- references: Array.from(references),
174
- referencedby: Array.from(referencedby),
175
- docsName: docsName ? docsName : ''
176
- };
177
106
  }
178
- };
179
-
180
- var _iteratorNormalCompletion = true;
181
- var _didIteratorError = false;
182
- var _iteratorError = undefined;
183
107
 
184
- try {
185
-
186
- for (var _iterator = modules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
187
- var module = _step.value;
188
-
189
- _loop(module);
190
- }
191
- } catch (err) {
192
- _didIteratorError = true;
193
- _iteratorError = err;
194
- } finally {
195
- try {
196
- if (!_iteratorNormalCompletion && _iterator.return) {
197
- _iterator.return();
198
- }
199
- } finally {
200
- if (_didIteratorError) {
201
- throw _iteratorError;
202
- }
203
- }
108
+ results[currentModuleName] = {
109
+ name: currentModuleName,
110
+ references: Array.from(references),
111
+ referencedby: Array.from(referencedby),
112
+ docsName: docsName ? docsName : '',
113
+ fileName: name ? name : currentModuleName
114
+ };
204
115
  }
116
+ }
205
117
 
206
- compilation.assets[_this.options.filename] = new _webpackSources.RawSource(JSON.stringify(results));
207
- });
208
- }
209
- }]);
118
+ compilation.assets[this.options.filename] = new _webpackSources.RawSource(JSON.stringify(results));
119
+ });
120
+ }
210
121
 
211
- return ModuleStatsPlugin;
212
- }();
122
+ }
213
123
 
214
124
  exports.default = ModuleStatsPlugin;
@@ -1,58 +1,41 @@
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
+ var _optimizeJs = _interopRequireDefault(require("optimize-js"));
8
9
 
9
- var _optimizeJs = require('optimize-js');
10
-
11
- var _optimizeJs2 = _interopRequireDefault(_optimizeJs);
12
-
13
- var _webpackSources = require('webpack-sources');
10
+ var _webpackSources = require("webpack-sources");
14
11
 
15
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
13
 
17
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
-
19
- var OptimizeJSPlugin = function () {
20
- function OptimizeJSPlugin() {
21
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
22
-
23
- _classCallCheck(this, OptimizeJSPlugin);
24
-
14
+ class OptimizeJSPlugin {
15
+ constructor(options = {}) {
25
16
  this.optimize = options.optimize;
26
17
  }
27
18
 
28
- _createClass(OptimizeJSPlugin, [{
29
- key: 'apply',
30
- value: function apply(compiler) {
31
- compiler.hooks.compilation.tap('OptimizeJSPlugin', function (compilation) {
32
- compilation.hooks.afterOptimizeChunks.tap('OptimizeJSPlugin', function (chunks) {
33
- chunks.forEach(function (chunk) {
34
- var files = chunk.files.map(function (file) {
35
- return file;
36
- });
37
- files.filter(function (file) {
38
- return (/\.js$/.test(file)
39
- );
40
- }).forEach(function (file) {
41
- try {
42
- var asset = compilation.assets[file].source();
43
- var result = (0, _optimizeJs2.default)(asset);
44
- compilation.assets[file] = new _webpackSources.RawSource(result);
45
- } catch (e) {
46
- compilation.errors.push(e);
47
- }
48
- });
19
+ apply(compiler) {
20
+ compiler.hooks.compilation.tap('OptimizeJSPlugin', compilation => {
21
+ compilation.hooks.afterOptimizeChunks.tap('OptimizeJSPlugin', chunks => {
22
+ chunks.forEach(chunk => {
23
+ const files = chunk.files.map(file => file);
24
+ files.filter(file => /\.js$/.test(file)).forEach(file => {
25
+ try {
26
+ const asset = compilation.assets[file].source();
27
+ const result = (0, _optimizeJs.default)(asset);
28
+ compilation.assets[file] = new _webpackSources.RawSource(result);
29
+ } catch (e) {
30
+ compilation.errors.push(e);
31
+ }
49
32
  });
50
33
  });
51
34
  });
52
- }
53
- }]);
35
+ });
36
+ }
54
37
 
55
- return OptimizeJSPlugin;
56
- }();
38
+ }
57
39
 
58
- exports.default = OptimizeJSPlugin;
40
+ var _default = OptimizeJSPlugin;
41
+ exports.default = _default;
@@ -1,137 +1,63 @@
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;
7
+ const MODULE_TYPE = 'css/mini-extract';
6
8
 
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 MODULE_TYPE = 'css/mini-extract';
12
-
13
- var PublicPathCallbackPlugin = function () {
14
- function PublicPathCallbackPlugin(_ref) {
15
- var callback = _ref.callback;
16
-
17
- _classCallCheck(this, PublicPathCallbackPlugin);
18
-
9
+ class PublicPathCallbackPlugin {
10
+ constructor({
11
+ callback
12
+ }) {
19
13
  this.publicPathCallback = callback;
20
14
  }
21
15
 
22
- _createClass(PublicPathCallbackPlugin, [{
23
- key: 'getCssChunkObject',
24
- value: function getCssChunkObject(mainChunk) {
25
- var obj = {};
26
- var _iteratorNormalCompletion = true;
27
- var _didIteratorError = false;
28
- var _iteratorError = undefined;
29
-
30
- try {
31
- for (var _iterator = mainChunk.getAllAsyncChunks()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
32
- var chunk = _step.value;
33
- var _iteratorNormalCompletion2 = true;
34
- var _didIteratorError2 = false;
35
- var _iteratorError2 = undefined;
16
+ getCssChunkObject(mainChunk) {
17
+ const obj = {};
36
18
 
37
- try {
38
- for (var _iterator2 = chunk.modulesIterable[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
39
- var module = _step2.value;
40
-
41
- if (module.type === MODULE_TYPE) {
42
- obj[chunk.id] = 1;
43
- break;
44
- }
45
- }
46
- } catch (err) {
47
- _didIteratorError2 = true;
48
- _iteratorError2 = err;
49
- } finally {
50
- try {
51
- if (!_iteratorNormalCompletion2 && _iterator2.return) {
52
- _iterator2.return();
53
- }
54
- } finally {
55
- if (_didIteratorError2) {
56
- throw _iteratorError2;
57
- }
58
- }
59
- }
60
- }
61
- } catch (err) {
62
- _didIteratorError = true;
63
- _iteratorError = err;
64
- } finally {
65
- try {
66
- if (!_iteratorNormalCompletion && _iterator.return) {
67
- _iterator.return();
68
- }
69
- } finally {
70
- if (_didIteratorError) {
71
- throw _iteratorError;
72
- }
19
+ for (const chunk of mainChunk.getAllAsyncChunks()) {
20
+ for (const module of chunk.modulesIterable) {
21
+ if (module.type === MODULE_TYPE) {
22
+ obj[chunk.id] = 1;
23
+ break;
73
24
  }
74
25
  }
75
-
76
- return obj;
77
26
  }
78
- }, {
79
- key: 'needChunkOnDemandLoadingCode',
80
- value: function needChunkOnDemandLoadingCode(chunk) {
81
- var _iteratorNormalCompletion3 = true;
82
- var _didIteratorError3 = false;
83
- var _iteratorError3 = undefined;
84
27
 
85
- try {
86
- for (var _iterator3 = chunk.groupsIterable[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
87
- var chunkGroup = _step3.value;
28
+ return obj;
29
+ }
88
30
 
89
- if (chunkGroup.getNumberOfChildren() > 0) {
90
- return true;
91
- }
92
- }
93
- } catch (err) {
94
- _didIteratorError3 = true;
95
- _iteratorError3 = err;
96
- } finally {
97
- try {
98
- if (!_iteratorNormalCompletion3 && _iterator3.return) {
99
- _iterator3.return();
100
- }
101
- } finally {
102
- if (_didIteratorError3) {
103
- throw _iteratorError3;
104
- }
105
- }
31
+ needChunkOnDemandLoadingCode(chunk) {
32
+ for (const chunkGroup of chunk.groupsIterable) {
33
+ if (chunkGroup.getNumberOfChildren() > 0) {
34
+ return true;
106
35
  }
107
-
108
- return false;
109
36
  }
110
- }, {
111
- key: 'apply',
112
- value: function apply(compiler) {
113
- var _this = this;
114
37
 
115
- compiler.hooks.thisCompilation.tap('PublicPathCallbackPlugin', function (compilation) {
116
- compilation.mainTemplate.hooks.requireEnsure.tap('PublicPathCallbackPlugin', function (source, chunk) {
117
- var chunkMap = _this.getCssChunkObject(chunk);
118
- if (Object.keys(chunkMap).length > 0) {
119
- return source.replace('__webpack_require__.p', _this.publicPathCallback + '("css")');
120
- }
121
- });
122
- });
38
+ return false;
39
+ }
40
+
41
+ apply(compiler) {
42
+ compiler.hooks.thisCompilation.tap('PublicPathCallbackPlugin', compilation => {
43
+ compilation.mainTemplate.hooks.requireEnsure.tap('PublicPathCallbackPlugin', (source, chunk) => {
44
+ const chunkMap = this.getCssChunkObject(chunk);
123
45
 
124
- compiler.hooks.compilation.tap('PublicPathCallbackPlugin', function (compilation) {
125
- compilation.mainTemplate.hooks.localVars.tap('PublicPathCallbackPlugin', function (source, chunk) {
126
- if (_this.needChunkOnDemandLoadingCode(chunk)) {
127
- return source.replace('__webpack_require__.p', _this.publicPathCallback + '("js")');
128
- }
129
- });
46
+ if (Object.keys(chunkMap).length > 0) {
47
+ return source.replace('__webpack_require__.p', `${this.publicPathCallback}("css")`);
48
+ }
130
49
  });
131
- }
132
- }]);
50
+ });
51
+ compiler.hooks.compilation.tap('PublicPathCallbackPlugin', compilation => {
52
+ compilation.mainTemplate.hooks.localVars.tap('PublicPathCallbackPlugin', (source, chunk) => {
53
+ if (this.needChunkOnDemandLoadingCode(chunk)) {
54
+ return source.replace('__webpack_require__.p', `${this.publicPathCallback}("js")`);
55
+ }
56
+ });
57
+ });
58
+ }
133
59
 
134
- return PublicPathCallbackPlugin;
135
- }();
60
+ }
136
61
 
137
- exports.default = PublicPathCallbackPlugin;
62
+ var _default = PublicPathCallbackPlugin;
63
+ exports.default = _default;