@zohodesk/react-cli 1.1.0 → 1.1.2-9.exp.3

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 (80) hide show
  1. package/.vscode/settings.json +25 -0
  2. package/README.md +453 -34
  3. package/bin/cli.js +25 -52
  4. package/docs/CustomChunks.md +12 -9
  5. package/docs/MarkdownParser.md +18 -0
  6. package/docs/ReactLive.md +8 -0
  7. package/docs/ValueReplacer.md +27 -0
  8. package/lib/babel/babel-option-utils/babel-preset-react-option.js +22 -0
  9. package/lib/babel/cmjs-plugins-presets.js +36 -7
  10. package/lib/babel/es-plugins-presets.js +45 -16
  11. package/lib/common/runPreProcess.js +71 -0
  12. package/lib/common/splitChunks.js +65 -45
  13. package/lib/common/testPattern.js +9 -9
  14. package/lib/configs/jest.config.js +4 -4
  15. package/lib/configs/libAlias.js +36 -2
  16. package/lib/configs/resolvers.js +7 -4
  17. package/lib/configs/webpack.css.umd.config.js +3 -2
  18. package/lib/configs/webpack.dev.config.js +28 -8
  19. package/lib/configs/webpack.docs.config.js +11 -5
  20. package/lib/configs/webpack.impact.config.js +9 -4
  21. package/lib/configs/webpack.prod.config.js +32 -10
  22. package/lib/constants.js +3 -3
  23. package/lib/deprecationLogger.js +40 -0
  24. package/lib/jest/preProcessors/jsPreprocessor.js +27 -2
  25. package/lib/loaderUtils/configsAssetsLoaders.js +1 -1
  26. package/lib/loaderUtils/getCSSLoaders.js +32 -8
  27. package/lib/loaderUtils/getDevJsLoaders.js +8 -2
  28. package/lib/loaders/__test__/markdownLoader.spec.js +145 -0
  29. package/lib/loaders/composeLoader.js +140 -14
  30. package/lib/loaders/docsLoader.js +5 -2
  31. package/lib/loaders/enhancedReactLiveConverter.js +151 -0
  32. package/lib/loaders/markdownLoader.js +71 -0
  33. package/lib/loaders/reactLiveConvertor.js +64 -66
  34. package/lib/loaders/workerLoader.js +37 -22
  35. package/lib/logger.js +7 -0
  36. package/lib/pluginUtils/configHtmlWebpackPlugins.js +62 -2
  37. package/lib/pluginUtils/getDevPlugins.js +24 -8
  38. package/lib/pluginUtils/getProdPlugins.js +34 -6
  39. package/lib/plugins/CssOrderControlPlugin.js +36 -0
  40. package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +109 -0
  41. package/lib/plugins/EfcResourceCleanupPlugin.js +43 -0
  42. package/lib/plugins/EventsHandlingPlugin.js +34 -0
  43. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +5 -1
  44. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +4 -1
  45. package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +14 -0
  46. package/lib/plugins/ReportGeneratePlugin.js +8 -6
  47. package/lib/plugins/ResourceHintsPlugin.js +13 -3
  48. package/lib/plugins/StatsPlugin.js +82 -0
  49. package/lib/plugins/UnusedFilesFindPlugin.js +7 -5
  50. package/lib/plugins/utils/fileHandling.js +36 -51
  51. package/lib/plugins/variableConvertorUtils.js +4 -2
  52. package/lib/postcss-plugins/ValueReplacer.js +7 -17
  53. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +43 -0
  54. package/lib/postcss-plugins/variableModificationPlugin/index.js +70 -18
  55. package/lib/schemas/index.js +96 -27
  56. package/lib/servers/getCliPath.js +3 -5
  57. package/lib/servers/requireLocalOrGlobal.js +1 -1
  58. package/lib/utils/cssClassNameGenerate.js +43 -5
  59. package/lib/utils/deprecationSupport.js +134 -0
  60. package/lib/utils/getFileType.js +1 -1
  61. package/lib/utils/getOptions.js +34 -43
  62. package/lib/utils/getServerURL.js +7 -2
  63. package/lib/utils/index.js +27 -11
  64. package/lib/utils/initPreCommitHook.js +5 -5
  65. package/lib/utils/log.js +11 -0
  66. package/lib/utils/object-manipulation.js +88 -0
  67. package/lib/utils/pullOrigin.js +3 -3
  68. package/lib/utils/reinstallDependencies.js +3 -3
  69. package/lib/utils/selectorReplacer.js +47 -0
  70. package/lib/utils/switchBranch.js +4 -2
  71. package/lib/utils/typeCheck.js +10 -0
  72. package/lib/utils/variableConverter.js +26 -11
  73. package/npm-shrinkwrap.json +1001 -106
  74. package/package.json +12 -4
  75. package/templates/docs/all.html +1 -0
  76. package/templates/docs/component.html +1 -0
  77. package/templates/docs/components.html +1 -0
  78. package/templates/docs/css/markdown.css +202 -0
  79. package/templates/docs/css/style.css +136 -169
  80. package/templates/docs/index.html +796 -632
@@ -11,74 +11,76 @@ const traverse = require('@babel/traverse').default;
11
11
 
12
12
  const path = require('path');
13
13
 
14
+ function getFilename(originalFilePath) {
15
+ const [fileName] = path.basename(originalFilePath).split('.');
16
+ return fileName;
17
+ }
18
+
14
19
  function reactLiveConvertor(source, originalFilePath) {
15
- let stringifyPath = JSON.stringify(originalFilePath);
16
- var fileName = stringifyPath.substring(stringifyPath.lastIndexOf("/") + 1, stringifyPath.length).split('.')[0];
17
-
18
- if (source) {
19
- let importBlock = '';
20
- let docCode = '';
21
- let packages = new Set();
22
- const fileContent = source.replace(/[\s\r\n]*$/, '');
23
- const ast = parser.parse(fileContent, {
24
- sourceType: 'module',
25
- plugins: ['jsx', 'classProperties']
26
- }); // Traverse the AST and find the import and export blocks
27
-
28
- let remainingCode = ast.program.body.filter(node => {
29
- return node.type !== "ImportDeclaration";
30
- }).map(node => {
31
- return fileContent.substring(node.start, node.end);
32
- }).join("").replace(/export default/, '').replace(/export /, '').trim();
33
- traverse(ast, {
34
- ImportDeclaration(path) {
35
- importBlock += fileContent.slice(path.node.start, path.node.end) + '\n';
36
- path.node.specifiers.forEach(specifier => {
37
- if (specifier.type === 'ImportSpecifier') {
38
- packages.add(specifier.imported.name);
39
- }
40
-
41
- if (specifier.local.type == 'Identifier') {
42
- packages.add(specifier.local.name);
43
- }
44
- });
45
- },
46
-
47
- ExpressionStatement(path) {
48
- if (path.node.type == 'ExpressionStatement') {
49
- if (path.node.expression.type == 'AssignmentExpression') {
50
- if (path.node.expression.left.type == 'MemberExpression') {
51
- let docCheck = fileContent.slice(path.node.expression.left.start, path.node.expression.left.end);
52
-
53
- if (docCheck == `${fileName}.docs`) {
54
- docCode = fileContent.slice(path.node.expression.start, path.node.expression.end);
55
- }
56
- }
57
- }
20
+ const fileName = getFilename(originalFilePath);
21
+
22
+ if (!source) {
23
+ return '';
24
+ }
25
+
26
+ let importBlock = '';
27
+ let docCode = '';
28
+ const packages = new Set();
29
+ const fileContent = source.replace(/[\s\r\n]*$/, '');
30
+ const ast = parser.parse(fileContent, {
31
+ sourceType: 'module',
32
+ plugins: ['jsx', 'classProperties']
33
+ }); // Traverse the AST and find the import and export blocks
34
+
35
+ let remainingCode = ast.program.body.filter(node => node.type !== 'ImportDeclaration').map(node => fileContent.substring(node.start, node.end)).join('').replace(/export default/, '').replace(/export /, '').trim();
36
+ traverse(ast, {
37
+ ImportDeclaration(path) {
38
+ importBlock += `${fileContent.slice(path.node.start, path.node.end)}\n`;
39
+ path.node.specifiers.forEach(specifier => {
40
+ if (specifier.type === 'ImportSpecifier') {
41
+ packages.add(specifier.imported.name);
42
+ }
43
+
44
+ if (specifier.local.type === 'Identifier') {
45
+ packages.add(specifier.local.name);
46
+ }
47
+ });
48
+ },
49
+
50
+ ExpressionStatement(path) {
51
+ const expression = path.get('expression');
52
+ const expressionLeft = expression.get('left');
53
+
54
+ if (path.isExpressionStatement() && expression.isAssignmentExpression() && expressionLeft.isMemberExpression()) {
55
+ const docCheck = expressionLeft.toString();
56
+
57
+ if (docCheck === `${fileName}.docs`) {
58
+ docCode = expression.toString();
58
59
  }
59
- } // IfStatement(path){
60
- // if(path.node.type == 'IfStatement'){
61
- // if(path.node.test.name == '__DOCS__'){
62
- // let final = fileContent.slice(path.node.start,path.node.end)
63
- // fileContent = fileContent.replace(final,'')
64
- // console.log(fileContent);
65
- // }
66
- // }
67
- // }
68
-
69
-
70
- });
71
- remainingCode = remainingCode.replace(/__DOCS__/, true);
72
- remainingCode = remainingCode.replace(/`/g, '\\`').replace(/\$\{/g, '$\\{');
73
- let brcklets = `(function () {
60
+ }
61
+ } // IfStatement(path){
62
+ // if(path.node.type == 'IfStatement'){
63
+ // if(path.node.test.name == '__DOCS__'){
64
+ // let final = fileContent.slice(path.node.start,path.node.end)
65
+ // fileContent = fileContent.replace(final,'')
66
+ // console.log(fileContent);
67
+ // }
68
+ // }
69
+ // }
70
+
71
+
72
+ });
73
+ remainingCode = remainingCode.replace(/__DOCS__/, true);
74
+ remainingCode = remainingCode.replace(/`/g, '\\`').replace(/\$\{/g, '$\\{');
75
+ const brcklets = `(function () {
74
76
 
75
77
  ${remainingCode}
76
78
 
77
79
  return <${fileName} />
78
80
 
79
81
  }) ()`;
80
- let addBractick = '`' + brcklets + '`';
81
- let template = `
82
+ const addBractick = `\`${brcklets}\``;
83
+ const template = `
82
84
 
83
85
  ${importBlock}
84
86
 
@@ -98,10 +100,6 @@ function reactLiveConvertor(source, originalFilePath) {
98
100
  }
99
101
 
100
102
  ${docCode}
101
- `; // fileName == 'CustomLookup__default' && console.log(docCode);
102
-
103
- return template;
104
- }
105
-
106
- ;
103
+ `;
104
+ return template;
107
105
  }
@@ -19,32 +19,32 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
19
19
  /* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
20
20
  import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
21
21
  const schema = {
22
- 'type': 'object',
23
- 'properties': {
24
- 'publicPath': {
25
- 'anyOf': [{
26
- 'type': 'string'
22
+ type: 'object',
23
+ properties: {
24
+ publicPath: {
25
+ anyOf: [{
26
+ type: 'string'
27
27
  }, {
28
- 'instanceof': 'Function'
28
+ instanceof: 'Function'
29
29
  }]
30
30
  },
31
- 'filename': {
32
- 'anyOf': [{
33
- 'type': 'string',
34
- 'minLength': 1
31
+ filename: {
32
+ anyOf: [{
33
+ type: 'string',
34
+ minLength: 1
35
35
  }, {
36
- 'instanceof': 'Function'
36
+ instanceof: 'Function'
37
37
  }]
38
38
  },
39
- 'chunkFilename': {
40
- 'type': 'string',
41
- 'minLength': 1
39
+ chunkFilename: {
40
+ type: 'string',
41
+ minLength: 1
42
42
  },
43
- 'esModule': {
44
- 'type': 'boolean'
43
+ esModule: {
44
+ type: 'boolean'
45
45
  }
46
46
  },
47
- 'additionalProperties': false
47
+ additionalProperties: false
48
48
  }; // eslint-disable-next-line
49
49
 
50
50
  function loader() {}
@@ -112,25 +112,40 @@ function pitch(request) {
112
112
  }
113
113
 
114
114
  function workerCode() {
115
+ // if (this.workerInstance) {
116
+ // return this.workerInstance;
117
+ // }
115
118
  let blob;
116
119
 
117
120
  try {
118
121
  blob = new Blob([`importScripts('${this.workerUrl}');`], {
119
- 'type': 'application/javascript'
122
+ type: 'application/javascript'
120
123
  });
121
124
  } catch (e1) {
122
125
  throw new Error(e1);
123
126
  }
124
127
 
125
- let url = window.URL || window.webkitURL;
126
- let blobUrl = url.createObjectURL(blob);
128
+ const url = window.URL || window.webkitURL;
129
+ const blobUrl = url.createObjectURL(blob); // this.workerInstance = new Worker(blobUrl);
130
+ // return this.workerInstance;
131
+
127
132
  let worker = new Worker(blobUrl);
128
133
  return worker;
129
134
  }
130
135
 
131
- return cb(null, `${options.esModule ? 'export default' : 'module.exports ='} {\n
136
+ return cb(null, `const workerObj ={\n
137
+ workerInstance: null, \n
132
138
  workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
133
139
  getInstance: ${workerCode} \n
134
- }`);
140
+ };\n
141
+ ${options.esModule ? 'export default' : 'module.exports ='} workerObj;
142
+ `); // return cb(
143
+ // null,
144
+ // `${options.esModule ? 'export default' : 'module.exports ='} {\n
145
+ // workerInstance: null, \n
146
+ // workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
147
+ // getInstance: ${workerCode} \n
148
+ // }`
149
+ // );
135
150
  });
136
151
  }
package/lib/logger.js CHANGED
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.errorLogger = errorLogger;
7
7
  exports.messageLogger = messageLogger;
8
+ exports.verboseLogger = verboseLogger;
8
9
  exports.warnLogger = warnLogger;
9
10
 
11
+ /* eslint-disable no-console */
10
12
  function messageLogger(...args) {
11
13
  console.log(...args);
12
14
  }
@@ -17,4 +19,9 @@ function errorLogger(...args) {
17
19
 
18
20
  function warnLogger(...args) {
19
21
  console.warn(...args);
22
+ }
23
+
24
+ function verboseLogger(...args) {
25
+ // TODO: need to be remove when publish happens
26
+ process.env.VERBOSE === 'true' && console.log('\x1b[33m [verbose] \x1b[0m', ...args);
20
27
  }
@@ -13,6 +13,10 @@ var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-we
13
13
 
14
14
  var _common = require("../common");
15
15
 
16
+ var _utils = require("../utils");
17
+
18
+ var _CustomScriptLoadingStrategyPlugin = _interopRequireDefault(require("../plugins/CustomScriptLoadingStrategyPlugin"));
19
+
16
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
21
 
18
22
  const defaultHTMLMiniFyOption = {
@@ -26,6 +30,51 @@ const defaultHTMLMiniFyOption = {
26
30
  removeStyleLinkTypeAttributes: true,
27
31
  useShortDoctype: true
28
32
  };
33
+ const defaultScriptLoadingStrategy = 'defer';
34
+ const allowedScriptLoadingStrategies = ['blocking', 'defer', 'async', 'module'];
35
+
36
+ function isAllowedScriptLoadingStrategyUsed(scriptLoadingStategey) {
37
+ return allowedScriptLoadingStrategies.includes(scriptLoadingStategey);
38
+ }
39
+
40
+ function getScriptLoadingStrategyForStringType(scriptLoadingStategey) {
41
+ if (isAllowedScriptLoadingStrategyUsed(scriptLoadingStategey)) {
42
+ return scriptLoadingStategey;
43
+ }
44
+
45
+ return defaultScriptLoadingStrategy;
46
+ }
47
+
48
+ function getScriptLoadingStrategyForObject(scriptLoadingStategey) {
49
+ if (Object.keys(scriptLoadingStategey).length === 0) {
50
+ return defaultScriptLoadingStrategy;
51
+ }
52
+
53
+ const isAllowedScriptLoadingStrategy = Object.keys(scriptLoadingStategey).every(key => isAllowedScriptLoadingStrategyUsed(key));
54
+
55
+ if (isAllowedScriptLoadingStrategy) {
56
+ return Object.assign({}, scriptLoadingStategey);
57
+ }
58
+
59
+ console.warn('un supported script loading strategy used', scriptLoadingStategey);
60
+ return defaultScriptLoadingStrategy;
61
+ }
62
+
63
+ function getScriptLoadingStrategy(scriptLoadingStategey) {
64
+ if ((0, _utils.getTypeOf)(scriptLoadingStategey) === 'string') {
65
+ return {
66
+ [getScriptLoadingStrategyForStringType(scriptLoadingStategey)]: [/.*/]
67
+ };
68
+ }
69
+
70
+ if ((0, _utils.getTypeOf)(scriptLoadingStategey) === 'object') {
71
+ return getScriptLoadingStrategyForObject(scriptLoadingStategey);
72
+ }
73
+
74
+ return {
75
+ [defaultScriptLoadingStrategy]: [/.*/]
76
+ };
77
+ }
29
78
 
30
79
  function configHtmlWebpackPlugins(plugins, {
31
80
  enableChunkHash = false,
@@ -33,7 +82,8 @@ function configHtmlWebpackPlugins(plugins, {
33
82
  inject,
34
83
  crossorigin,
35
84
  hasEFC,
36
- minify: minifyHtmlOptions = false
85
+ minify: minifyHtmlOptions = false,
86
+ customScriptLoadingStrategey = {}
37
87
  }) {
38
88
  const optionsHtmlWebpack = {
39
89
  chunksSortMode: 'none',
@@ -44,7 +94,7 @@ function configHtmlWebpackPlugins(plugins, {
44
94
  // ? minifyHtmlOptions
45
95
  // : minifyHtmlOptions,,
46
96
  templateParameters: _common.templateParameters,
47
- scriptLoading: 'defer',
97
+ scriptLoading: defaultScriptLoadingStrategy,
48
98
  inject: inject
49
99
  };
50
100
 
@@ -56,4 +106,14 @@ function configHtmlWebpackPlugins(plugins, {
56
106
  crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
57
107
  crossorigin: 'anonymous'
58
108
  }));
109
+
110
+ if (customScriptLoadingStrategey.enable) {
111
+ const currentScriptLoadingStrategy = getScriptLoadingStrategy(customScriptLoadingStrategey.options);
112
+
113
+ if ((0, _utils.getTypeOf)(currentScriptLoadingStrategy) === 'object') {
114
+ plugins.push(new _CustomScriptLoadingStrategyPlugin.default({
115
+ scriptLoadingStategey: currentScriptLoadingStrategy
116
+ }));
117
+ }
118
+ }
59
119
  }
@@ -19,6 +19,8 @@ var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugi
19
19
 
20
20
  var _RequireVariablePublicPlugin = _interopRequireDefault(require("../plugins/RequireVariablePublicPlugin"));
21
21
 
22
+ var _CssOrderControlPlugin = _interopRequireDefault(require("../plugins/CssOrderControlPlugin"));
23
+
22
24
  var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
23
25
 
24
26
  var _webpack = _interopRequireDefault(require("webpack"));
@@ -35,12 +37,17 @@ var _SelectorPlugin = _interopRequireDefault(require("../plugins/SelectorPlugin"
35
37
 
36
38
  var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
37
39
 
40
+ var _EfcResourceCleanupPlugin = _interopRequireDefault(require("../plugins/EfcResourceCleanupPlugin"));
41
+
42
+ var _EventsHandlingPlugin = require("../plugins/EventsHandlingPlugin");
43
+
38
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
45
 
40
46
  // import { windowsModification } from '../loaderUtils/windowsModification';
41
47
  const getDevPlugins = (options, publicPath) => {
42
48
  const {
43
49
  app: {
50
+ generateHtml,
44
51
  tpFolder,
45
52
  folder,
46
53
  instrumentScript,
@@ -58,7 +65,8 @@ const getDevPlugins = (options, publicPath) => {
58
65
  mode
59
66
  },
60
67
  htmlTemplate: {
61
- inject
68
+ inject,
69
+ customScriptLoadingStrategey
62
70
  },
63
71
  crossorigin
64
72
  },
@@ -69,10 +77,12 @@ const getDevPlugins = (options, publicPath) => {
69
77
  localeAttr: efcLocaleAttr
70
78
  },
71
79
  css: {
72
- enableRTLSplit
80
+ enableRTLSplit,
81
+ cssOrderControler
73
82
  },
74
83
  i18n,
75
- unusedFiles
84
+ unusedFiles,
85
+ resourceHints
76
86
  } = options;
77
87
  const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
78
88
  const cssLTRFileNameTempalte = enableRTLSplit ? 'css/[name].ltr.css' : 'css/[name].css';
@@ -94,7 +104,7 @@ const getDevPlugins = (options, publicPath) => {
94
104
  filename: cssLTRFileNameTempalte,
95
105
  // ignoreOrder: true,
96
106
  chunkFilename: cssLTRFileNameTempalte
97
- }), new _plugins.ResourceHintsPlugin()];
107
+ }), new _plugins.ResourceHintsPlugin(resourceHints)];
98
108
 
99
109
  if (enableRTLSplit) {
100
110
  pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
@@ -157,13 +167,14 @@ const getDevPlugins = (options, publicPath) => {
157
167
  collections: true,
158
168
  shorthands: true
159
169
  }));
160
- (0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(pluginsArr, {
170
+ generateHtml && (0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(pluginsArr, {
161
171
  enableChunkHash: false,
162
172
  folder,
163
173
  minify: false,
164
174
  inject,
165
175
  crossorigin,
166
- hasEFC
176
+ hasEFC,
177
+ customScriptLoadingStrategey
167
178
  });
168
179
 
169
180
  if (hasEFC) {
@@ -189,7 +200,11 @@ const getDevPlugins = (options, publicPath) => {
189
200
  mainChunkName: 'main'
190
201
  }));
191
202
  instrumentScript && pluginsArr.push(new _plugins.ScriptInstrumentPlugin());
203
+ cssOrderControler.enable && pluginsArr.push(new _CssOrderControlPlugin.default(cssOrderControler));
192
204
  customAttributes.enable && pluginsArr.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
205
+ customAttributes.enable && pluginsArr.push(new _EfcResourceCleanupPlugin.default(Object.assign({}, customAttributes, {
206
+ globalCacheObj: context
207
+ })));
193
208
  hasShadowDOM && pluginsArr.push(new _plugins.ShadowDOMSupportPlugin());
194
209
 
195
210
  if (devCssFileBountry) {
@@ -211,12 +226,13 @@ const getDevPlugins = (options, publicPath) => {
211
226
  exclude: exclude.selectorWeight,
212
227
  patterns
213
228
  }));
214
- } // if (pluginObject.minifier) {
229
+ }
230
+
231
+ pluginsArr.push(new _EventsHandlingPlugin.EventsHandlingPlugin()); // if (pluginObject.minifier) {
215
232
  // // console.log('minifier active');
216
233
  // pluginsArr.push(new MinifierPlugin());
217
234
  // }
218
235
 
219
-
220
236
  return pluginsArr.filter(Boolean);
221
237
  };
222
238
 
@@ -27,14 +27,22 @@ var _VariableConversionCollector = _interopRequireDefault(require("../plugins/Va
27
27
 
28
28
  var _SelectorPlugin = _interopRequireDefault(require("../plugins/SelectorPlugin"));
29
29
 
30
+ var _EventsHandlingPlugin = require("../plugins/EventsHandlingPlugin");
31
+
30
32
  var _plugins = require("../plugins");
31
33
 
32
34
  var _CustomAttributePlugin = require("../plugins/CustomAttributePlugin");
33
35
 
34
36
  var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
35
37
 
38
+ var _CssOrderControlPlugin = _interopRequireDefault(require("../plugins/CssOrderControlPlugin"));
39
+
36
40
  var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
37
41
 
42
+ var _StatsPlugin = _interopRequireDefault(require("../plugins/StatsPlugin"));
43
+
44
+ var _EfcResourceCleanupPlugin = _interopRequireDefault(require("../plugins/EfcResourceCleanupPlugin"));
45
+
38
46
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
47
 
40
48
  // eslint-disable-next-line no-unused-vars
@@ -43,6 +51,7 @@ const getProdPlugins = (options, publicPath = '') => {
43
51
  enableChunkHash
44
52
  } = options.app;
45
53
  const {
54
+ generateHtml,
46
55
  manifestFileName,
47
56
  bundleAnalyze,
48
57
  optimize,
@@ -74,13 +83,15 @@ const getProdPlugins = (options, publicPath = '') => {
74
83
  } = options.app;
75
84
  const {
76
85
  inject,
77
- minify: minifyHtmlOptions
86
+ minify: minifyHtmlOptions,
87
+ customScriptLoadingStrategey
78
88
  } = htmlTemplate;
79
89
  const {
80
90
  i18n
81
91
  } = options;
82
92
  const {
83
- enableRTLSplit
93
+ enableRTLSplit,
94
+ cssOrderControler
84
95
  } = options.css;
85
96
  const {
86
97
  hasEFC: newOptionForEnableEFC,
@@ -88,6 +99,12 @@ const getProdPlugins = (options, publicPath = '') => {
88
99
  templateFilePath,
89
100
  localeAttr: efcLocaleAttr
90
101
  } = options.efc;
102
+ const {
103
+ enable: enableStats,
104
+ options: statsOptions,
105
+ excludeKeys: statsOutputExcludeKeys,
106
+ fileName: statsFileName
107
+ } = options.stats;
91
108
  const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
92
109
  const hashTempalate = enableChunkHash ? '.[chunkhash:20]_' : '';
93
110
  const cssLTRFileNameTempalte = `css/[name]${hashTempalate}${enableRTLSplit ? '.ltr' : ''}.css`;
@@ -107,7 +124,7 @@ const getProdPlugins = (options, publicPath = '') => {
107
124
  // ignoreOrder: true,
108
125
  filename: cssLTRFileNameTempalte,
109
126
  chunkFilename: cssLTRFileNameTempalte
110
- }), new _plugins.ResourceHintsPlugin(), new _plugins.MinifyPlugin()];
127
+ }), new _plugins.ResourceHintsPlugin(options.resourceHints), new _plugins.MinifyPlugin()];
111
128
 
112
129
  if (enableRTLSplit) {
113
130
  pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
@@ -161,11 +178,12 @@ const getProdPlugins = (options, publicPath = '') => {
161
178
  to: `./${tpFolder}/`,
162
179
  toType: 'dir'
163
180
  }]));
164
- (0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(pluginsArr, {
181
+ generateHtml && (0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(pluginsArr, {
165
182
  enableChunkHash,
166
183
  folder,
167
184
  inject,
168
185
  minify: minifyHtmlOptions,
186
+ customScriptLoadingStrategey,
169
187
  crossorigin,
170
188
  hasEFC
171
189
  });
@@ -227,9 +245,9 @@ const getProdPlugins = (options, publicPath = '') => {
227
245
  if (bundleAnalyze) {
228
246
  pluginsArr.push(new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
229
247
  analyzerMode: 'static',
230
- generateStatsFile: true,
248
+ generateStatsFile: false,
231
249
  openAnalyzer: false,
232
- statsOptions: {
250
+ statsOptions: enableStats ? null : {
233
251
  source: false,
234
252
  normal: true,
235
253
  chunks: false,
@@ -287,7 +305,17 @@ const getProdPlugins = (options, publicPath = '') => {
287
305
  } // plugins.push(new VariableConversionCollector({}));
288
306
 
289
307
 
308
+ cssOrderControler.enable && pluginsArr.push(new _CssOrderControlPlugin.default(cssOrderControler));
290
309
  customAttributes.enable && pluginsArr.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
310
+ customAttributes.enable && pluginsArr.push(new _EfcResourceCleanupPlugin.default(Object.assign({}, customAttributes, {
311
+ globalCacheObj: context
312
+ })));
313
+ enableStats && pluginsArr.push(new _StatsPlugin.default({
314
+ statsOptions,
315
+ statsOutputExcludeKeys,
316
+ statsFileName
317
+ }));
318
+ pluginsArr.push(new _EventsHandlingPlugin.EventsHandlingPlugin());
291
319
  return pluginsArr;
292
320
  };
293
321
 
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ class CssOrderControlPlugin {
9
+ constructor(options) {
10
+ this.options = {
11
+ className: options.className
12
+ };
13
+ }
14
+
15
+ apply(compiler) {
16
+ // NOTE: we not using this, Reason currently this option is only need for EFC,
17
+ // So it do not needed.
18
+ const className = this.options.className;
19
+ compiler.hooks.thisCompilation.tap({
20
+ name: 'CssOrderControlPlugin',
21
+ stage: 1,
22
+ fn: compilation => {
23
+ compilation.mainTemplate.hooks.requireEnsure.tap('CssOrderControlPlugin', source => {
24
+ // const str = attributeSetTemplate(cssAttributes, 'linkTag');
25
+ const replacedStr = source.replace('head.appendChild(linkTag);', `var referenceTag = document.getElementById('${className}');
26
+ head.insertBefore(linkTag, referenceTag);`); // console.log({ s: source, r: replacedStr });
27
+
28
+ return replacedStr;
29
+ });
30
+ }
31
+ });
32
+ }
33
+
34
+ }
35
+
36
+ exports.default = CssOrderControlPlugin;