@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,35 +1,43 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = HMRMiddleware;
7
+
7
8
  function pathMatch(url, path) {
8
9
  if (url === path) {
9
10
  return true;
10
11
  }
11
- var q = url.indexOf('?');
12
+
13
+ let q = url.indexOf('?');
14
+
12
15
  if (q === -1) {
13
16
  return false;
14
17
  }
18
+
15
19
  return url.substring(0, q) === path;
16
20
  }
17
21
 
18
22
  function createEventStream(heartbeat) {
19
- var clientId = 0;
20
- var clients = {};
23
+ let clientId = 0;
24
+ let clients = {};
25
+
21
26
  function everyClient(fn) {
22
- Object.keys(clients).forEach(function (id) {
27
+ Object.keys(clients).forEach(id => {
23
28
  fn(clients[id]);
24
29
  });
25
30
  }
26
- setInterval(function () {
27
- everyClient(function (client) {
28
- client.write('data: ' + JSON.stringify({ type: 'heartbeat' }) + '\n\n');
31
+
32
+ setInterval(() => {
33
+ everyClient(client => {
34
+ client.write(`data: ${JSON.stringify({
35
+ type: 'heartbeat'
36
+ })}\n\n`);
29
37
  });
30
38
  }, heartbeat).unref();
31
39
  return {
32
- handler: function handler(req, res) {
40
+ handler: function (req, res) {
33
41
  req.socket.setKeepAlive(true);
34
42
  res.writeHead(200, {
35
43
  'Access-Control-Allow-Origin': '*',
@@ -38,15 +46,15 @@ function createEventStream(heartbeat) {
38
46
  Connection: 'keep-alive'
39
47
  });
40
48
  res.write('\n');
41
- var id = clientId++;
49
+ let id = clientId++;
42
50
  clients[id] = res;
43
- req.on('close', function () {
51
+ req.on('close', () => {
44
52
  delete clients[id];
45
53
  });
46
54
  },
47
- publish: function publish(payload) {
48
- everyClient(function (client) {
49
- client.write('data: ' + JSON.stringify(payload) + '\n\n');
55
+ publish: function (payload) {
56
+ everyClient(client => {
57
+ client.write(`data: ${JSON.stringify(payload)}\n\n`);
50
58
  });
51
59
  }
52
60
  };
@@ -56,25 +64,26 @@ function extractBundles(stats) {
56
64
  // Stats has modules, single bundle
57
65
  if (stats.modules) {
58
66
  return [stats];
59
- }
67
+ } // Stats has children, multiple bundles
68
+
60
69
 
61
- // Stats has children, multiple bundles
62
70
  if (stats.children && stats.children.length) {
63
71
  return stats.children;
64
- }
72
+ } // Not sure, assume single
73
+
65
74
 
66
- // Not sure, assume single
67
75
  return [stats];
68
76
  }
69
77
 
70
78
  function publishStats(action, statsResult, eventStream, log) {
71
79
  // For multi-compiler, stats will be an object with a 'children' array of stats
72
- var bundles = extractBundles(statsResult.toJson({ errorDetails: false }));
73
- bundles.forEach(function (stats) {
80
+ let bundles = extractBundles(statsResult.toJson({
81
+ errorDetails: false
82
+ }));
83
+ bundles.forEach(stats => {
74
84
  if (log) {
75
- log('webpack built ' + (stats.name ? stats.name + ' ' : '') + stats.hash + ' in ' + stats.time + 'ms');
76
- }
77
- // if (
85
+ log(`webpack built ${stats.name ? `${stats.name} ` : ''}${stats.hash} in ${stats.time}ms`);
86
+ } // if (
78
87
  // // !force &&
79
88
  // action !== 'sync' &&
80
89
  // stats &&
@@ -86,6 +95,8 @@ function publishStats(action, statsResult, eventStream, log) {
86
95
  // type: 'still-ok'
87
96
  // });
88
97
  // }
98
+
99
+
89
100
  eventStream.publish({
90
101
  type: 'hash',
91
102
  data: stats.hash
@@ -109,56 +120,54 @@ function publishStats(action, statsResult, eventStream, log) {
109
120
  });
110
121
  }
111
122
 
112
- function HMRMiddleware(compiler) {
113
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
114
-
115
- opts.log =
116
- // eslint-disable-next-line no-console
123
+ function HMRMiddleware(compiler, opts = {}) {
124
+ opts.log = // eslint-disable-next-line no-console
117
125
  typeof opts.log === 'undefined' ? console.log.bind(console) : opts.log;
118
126
  opts.path = opts.path || '/__webpack_hmr';
119
127
  opts.heartbeat = opts.heartbeat || 10 * 1000;
120
-
121
- var eventStream = createEventStream(opts.heartbeat);
122
- var latestStats = null;
123
- var loggedInfo = false;
124
-
125
- compiler.hooks.beforeCompile.tap('HMRMiddleware', function (c, callback) {
128
+ let eventStream = createEventStream(opts.heartbeat);
129
+ let latestStats = null;
130
+ let loggedInfo = false;
131
+ compiler.hooks.beforeCompile.tap('HMRMiddleware', (c, callback) => {
126
132
  if (opts.log && !loggedInfo) {
127
133
  opts.log('webpack compilation starts...');
128
134
  loggedInfo = true;
129
135
  }
136
+
130
137
  callback && callback();
131
138
  });
132
-
133
- compiler.hooks.compile.tap('HMRMiddleware', function () {
139
+ compiler.hooks.compile.tap('HMRMiddleware', () => {
134
140
  latestStats = null;
141
+
135
142
  if (opts.log) {
136
143
  opts.log('webpack building...');
137
144
  }
138
- eventStream.publish({ type: 'building' });
145
+
146
+ eventStream.publish({
147
+ type: 'building'
148
+ });
139
149
  });
140
- compiler.hooks.done.tap('HMRMiddleware', function (statsResult) {
150
+ compiler.hooks.done.tap('HMRMiddleware', statsResult => {
141
151
  // Keep hold of latest stats so they can be propagated to new clients
142
152
  latestStats = statsResult;
143
-
144
153
  publishStats('built', latestStats, eventStream, opts.log);
145
154
  });
146
- var middleware = function middleware(req, res, next) {
155
+
156
+ let middleware = function (req, res, next) {
147
157
  if (!pathMatch(req.url, opts.path)) {
148
158
  return next();
149
159
  }
150
- eventStream.handler(req, res);
151
- // if (latestStats) {
160
+
161
+ eventStream.handler(req, res); // if (latestStats) {
152
162
  // // Explicitly not passing in `log` fn as we don't want to log again on
153
163
  // // the server
154
164
  // // publishStats('sync', latestStats, eventStream);
155
165
  // }
156
166
  };
167
+
157
168
  middleware.publish = eventStream.publish;
158
169
  return middleware;
159
- }
160
-
161
- // function buildModuleMap(modules) {
170
+ } // function buildModuleMap(modules) {
162
171
  // let map = {};
163
172
  // modules.forEach(function(module) {
164
173
  // map[module.id] = module.name;
@@ -1,18 +1,21 @@
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 _utils = require('../utils');
8
+ var _utils = require("../utils");
8
9
 
9
10
  function SSTMiddleware(compiler, callback) {
10
- compiler.hooks.done.tap('SSTMiddleware', function (stats) {
11
+ compiler.hooks.done.tap('SSTMiddleware', stats => {
11
12
  (0, _utils.log)('Compilation finished!');
12
13
  callback(stats.compilation.assets['js/moduleStats.js'].source());
13
14
  });
14
- return function (res, req, next) {
15
+ return (res, req, next) => {
15
16
  next();
16
17
  };
17
18
  }
18
- exports.default = SSTMiddleware;
19
+
20
+ var _default = SSTMiddleware;
21
+ exports.default = _default;
@@ -1,60 +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;
6
7
 
7
- var _path = require('path');
8
+ var _path = _interopRequireDefault(require("path"));
8
9
 
9
- var _path2 = _interopRequireDefault(_path);
10
+ var _fs = _interopRequireDefault(require("fs"));
10
11
 
11
- var _caseSensitivePathsWebpackPlugin = require('case-sensitive-paths-webpack-plugin');
12
+ var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
12
13
 
13
- var _caseSensitivePathsWebpackPlugin2 = _interopRequireDefault(_caseSensitivePathsWebpackPlugin);
14
+ var _lodashWebpackPlugin = _interopRequireDefault(require("lodash-webpack-plugin"));
14
15
 
15
- var _lodashWebpackPlugin = require('lodash-webpack-plugin');
16
+ var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
16
17
 
17
- var _lodashWebpackPlugin2 = _interopRequireDefault(_lodashWebpackPlugin);
18
+ var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
18
19
 
19
- var _miniCssExtractPlugin = require('mini-css-extract-plugin');
20
+ var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
20
21
 
21
- var _miniCssExtractPlugin2 = _interopRequireDefault(_miniCssExtractPlugin);
22
+ var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
22
23
 
23
- var _htmlWebpackPlugin = require('html-webpack-plugin');
24
+ var _webpack = _interopRequireDefault(require("webpack"));
24
25
 
25
- var _htmlWebpackPlugin2 = _interopRequireDefault(_htmlWebpackPlugin);
26
+ var _plugins = require("../plugins");
26
27
 
27
- var _copyWebpackPlugin = require('copy-webpack-plugin');
28
+ var _common = require("../common");
28
29
 
29
- var _copyWebpackPlugin2 = _interopRequireDefault(_copyWebpackPlugin);
30
-
31
- var _webpack = require('webpack');
32
-
33
- var _webpack2 = _interopRequireDefault(_webpack);
34
-
35
- var _plugins = require('../plugins');
36
-
37
- var _common = require('../common');
30
+ var _CustomAttributePlugin = require("../plugins/CustomAttributePlugin");
38
31
 
39
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
33
 
41
- var getDevPlugins = function getDevPlugins(options, publicPath) {
42
- var _options$app = options.app,
43
- folder = _options$app.folder,
44
- instrumentScript = _options$app.instrumentScript,
45
- context = _options$app.context,
46
- hasEFC = _options$app.hasEFC,
47
- hasShadowDOM = _options$app.hasShadowDOM,
48
- mode = _options$app.server.mode,
49
- inject = _options$app.htmlTemplate.inject,
50
- unusedFiles = options.unusedFiles;
51
-
52
-
53
- var plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin2.default(), new _copyWebpackPlugin2.default([{
54
- from: _path2.default.join(process.cwd(), context, 'i18n') + '/',
55
- to: './i18n/[name].[ext]',
56
- toType: 'template'
57
- }]), new _webpack2.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack2.default.DefinePlugin({
34
+ let getDevPlugins = (options, publicPath) => {
35
+ let {
36
+ app: {
37
+ tpFolder,
38
+ folder,
39
+ instrumentScript,
40
+ customAttributes,
41
+ context,
42
+ hasEFC: prevOptionForEnableEFC,
43
+ hasShadowDOM,
44
+ server: {
45
+ mode
46
+ },
47
+ htmlTemplate: {
48
+ inject
49
+ }
50
+ },
51
+ efc: {
52
+ hasEFC: newOptionForEnableEFC,
53
+ nameScope: efcNameSpace,
54
+ localeAttr: efcLocaleAttr
55
+ },
56
+ i18n,
57
+ unusedFiles
58
+ } = options;
59
+ const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
60
+ let plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
58
61
  __CLIENT__: true,
59
62
  __TEST__: false,
60
63
  __SERVER__: false,
@@ -65,49 +68,108 @@ var getDevPlugins = function getDevPlugins(options, publicPath) {
65
68
  'process.env': {
66
69
  NODE_ENV: JSON.stringify(mode === 'dev-no-warn' ? 'production' : 'development')
67
70
  }
68
- }), new _miniCssExtractPlugin2.default({
71
+ }), new _miniCssExtractPlugin.default({
72
+ attributes: customAttributes.cssAttributes,
69
73
  filename: 'css/[name].css',
70
- chunkFilename: 'css/[name].css'
74
+ chunkFilename: 'css/[name].css',
75
+ ignoreOrder: true
71
76
  }), new _plugins.ResourceHintsPlugin()];
72
77
 
73
78
  if (unusedFiles.enable) {
74
79
  plugins.push(new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
75
- origin: _path2.default.join(process.cwd(), folder)
80
+ origin: _path.default.join(process.cwd(), folder)
76
81
  })));
77
82
  }
78
- plugins.push(new _lodashWebpackPlugin2.default({
83
+
84
+ const i18nManifestFileName = 'i18n-manifest.json';
85
+ /**
86
+ * NOTE:
87
+ * this file name ext .i18n.js added
88
+ * Because, in service worker they maintain cache as file name based
89
+ * So, to make differce we added .i18n.js ext.
90
+ */
91
+
92
+ const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].i18n.js';
93
+ const i18nPublicPath = publicPath || '';
94
+
95
+ if (i18n.chunkSplitEnable) {
96
+ plugins.push(new _I18nSplitPlugin.default({
97
+ jsResource: i18n.jsResource,
98
+ localeVarName: i18n.localeVarName,
99
+ jsonpFunc: i18n.jsonpFunc,
100
+ disableDefault: i18n.disableDefault,
101
+ publicPath: i18nPublicPath,
102
+ i18nManifestFileName,
103
+ // template: (object, locale) => `window.loadI18n(${JSON.stringify(object)}, ${JSON.stringify(locale)})`,
104
+ filenameTemplate: i18nFileNameTemplate,
105
+ propertiesFolder: i18n.propertiesFolder
106
+ }));
107
+ } else {
108
+ plugins.push(new _copyWebpackPlugin.default({
109
+ patterns: [{
110
+ from: `${_path.default.join(process.cwd(), context, 'i18n')}/`,
111
+ to: './i18n/[name].[ext]',
112
+ toType: 'template'
113
+ }]
114
+ }));
115
+ }
116
+
117
+ tpFolder && plugins.push(new _copyWebpackPlugin.default({
118
+ patterns: [{
119
+ from: `${_path.default.join(process.cwd(), context, tpFolder)}/`,
120
+ to: `./${tpFolder}/`,
121
+ toType: 'dir'
122
+ }]
123
+ }));
124
+ plugins.push(new _lodashWebpackPlugin.default({
79
125
  collections: true,
80
126
  shorthands: true
81
127
  }));
128
+
82
129
  if (hasEFC) {
83
- plugins.push(new _htmlWebpackPlugin2.default({
130
+ plugins.push(new _htmlWebpackPlugin.default({
84
131
  chunksSortMode: 'none',
85
132
  filename: 'index.html',
86
- template: _path2.default.join(process.cwd(), folder, 'index.html'),
133
+ template: _path.default.join(process.cwd(), folder, 'index.html'),
87
134
  excludeChunks: ['efc', 'widget'],
88
135
  templateParameters: _common.templateParameters,
89
136
  scriptLoading: 'defer',
90
137
  inject: inject
138
+ }));
139
+ plugins.push(new _plugins.EFCPlugin({
140
+ isDevelopment: true,
141
+ i18nManifestFileName,
142
+ i18nFileNameTemplate,
143
+ serverUrl: publicPath,
144
+ entryPointName: 'efc',
145
+ nameScope: efcNameSpace,
146
+ localeAttr: efcLocaleAttr // outputFile: 'zohodesk-efc-sdk-latest.js',
91
147
 
92
148
  }));
93
149
  } else {
94
- plugins.push(new _htmlWebpackPlugin2.default({
150
+ plugins.push(new _htmlWebpackPlugin.default({
95
151
  chunksSortMode: 'none',
96
152
  filename: 'index.html',
97
- template: _path2.default.join(process.cwd(), folder, 'index.html'),
153
+ template: _path.default.join(process.cwd(), folder, 'index.html'),
98
154
  templateParameters: _common.templateParameters,
99
155
  scriptLoading: 'defer',
100
156
  inject: inject
101
157
  }));
102
158
  }
103
159
 
104
- plugins.push(new _plugins.I18NInjectIntoIndexPlugin({ publicPath: publicPath, mode: 'dev' }));
105
-
160
+ plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
161
+ publicPath: i18nPublicPath,
162
+ isDevelopment: true,
163
+ templateLabel: i18n.templateLabel || '{{--user-locale}}',
164
+ i18nFileNameTemplate,
165
+ i18nManifestFileName,
166
+ mainChunkName: 'main'
167
+ }));
106
168
  instrumentScript && plugins.push(new _plugins.ScriptInstrumentPlugin());
107
-
169
+ customAttributes.enable && plugins.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
108
170
  hasShadowDOM && plugins.push(new _plugins.ShadowDOMSupportPlugin());
109
-
110
- return plugins;
171
+ return plugins.filter(Boolean);
111
172
  };
112
173
 
113
- exports.default = getDevPlugins;
174
+ var _default = getDevPlugins;
175
+ exports.default = _default;
@@ -1,58 +1,54 @@
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 _webpack = _interopRequireDefault(require("webpack"));
12
13
 
13
- var _miniCssExtractPlugin2 = _interopRequireDefault(_miniCssExtractPlugin);
14
+ var _path = _interopRequireDefault(require("path"));
14
15
 
15
- var _webpack = require('webpack');
16
-
17
- var _webpack2 = _interopRequireDefault(_webpack);
18
-
19
- var _path = require('path');
20
-
21
- var _path2 = _interopRequireDefault(_path);
22
-
23
- var _ModuleStatsPlugin = require('../plugins/ModuleStatsPlugin');
24
-
25
- var _ModuleStatsPlugin2 = _interopRequireDefault(_ModuleStatsPlugin);
26
-
27
- var _plugins = require('../plugins');
16
+ var _plugins = require("../plugins");
28
17
 
29
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
19
 
31
- var getDocsPlugins = function getDocsPlugins(isSSTest, options) {
32
- var folder = options.app.folder,
33
- unusedFiles = options.unusedFiles;
34
-
35
-
36
- var plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin2.default(), new _webpack2.default.ProvidePlugin({
20
+ let getDocsPlugins = (isSSTest, options) => {
21
+ let {
22
+ app: {
23
+ folder
24
+ },
25
+ unusedFiles
26
+ } = options;
27
+ let plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.ProvidePlugin({
37
28
  React: 'react'
38
- }), new _webpack2.default.DefinePlugin({
29
+ }), new _webpack.default.DefinePlugin({
39
30
  __TEST__: false,
40
31
  __DEVELOPMENT__: true,
41
32
  __DOCS__: true
42
- }), new _ModuleStatsPlugin2.default({ filename: 'js/moduleStats.js' }), new _miniCssExtractPlugin2.default({
33
+ }), new _plugins.ModuleStatsPlugin({
34
+ filename: 'js/moduleStats.js'
35
+ }), new _miniCssExtractPlugin.default({
43
36
  filename: 'css/[name].css',
44
37
  chunkFilename: 'css/[name].css'
45
- })].filter(Boolean);
38
+ }), new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
39
+ origin: _path.default.join(process.cwd(), folder)
40
+ }))].filter(Boolean);
46
41
 
47
42
  if (unusedFiles.enable) {
48
43
  plugins.push(new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
49
44
  docsFilename: 'Undocsfiles.json',
50
45
  ssTest: true,
51
- origin: _path2.default.join(process.cwd(), folder)
46
+ origin: _path.default.join(process.cwd(), folder)
52
47
  })));
53
48
  }
54
49
 
55
50
  return plugins;
56
51
  };
57
52
 
58
- exports.default = getDocsPlugins;
53
+ var _default = getDocsPlugins;
54
+ exports.default = _default;
@@ -1,21 +1,18 @@
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
-
11
- var _webpack = require('webpack');
12
-
13
- var _webpack2 = _interopRequireDefault(_webpack);
10
+ var _webpack = _interopRequireDefault(require("webpack"));
14
11
 
15
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
13
 
17
- var getLibraryPlugins = function getLibraryPlugins() {
18
- var plugins = [new _caseSensitivePathsWebpackPlugin2.default(), new _webpack2.default.DefinePlugin({
14
+ let getLibraryPlugins = () => {
15
+ let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.DefinePlugin({
19
16
  __TEST__: false,
20
17
  __DEVELOPMENT__: false,
21
18
  __DOCS__: false,
@@ -27,4 +24,5 @@ var getLibraryPlugins = function getLibraryPlugins() {
27
24
  return plugins;
28
25
  };
29
26
 
30
- exports.default = getLibraryPlugins;
27
+ var _default = getLibraryPlugins;
28
+ exports.default = _default;