@zohodesk/react-cli 0.0.1-beta.16 → 0.0.1-beta.160

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 (226) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +46 -3
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +650 -0
  5. package/bin/cli.js +134 -27
  6. package/cert/cert.pem +37 -129
  7. package/cert/key.pem +27 -27
  8. package/cert/passphrase.pem +1 -0
  9. package/files/eslintrc.js +62 -0
  10. package/files/prettierrc.js +3 -0
  11. package/lib/babel/cmjs-plugins-presets.js +16 -9
  12. package/lib/babel/es-plugins-presets.js +26 -14
  13. package/lib/common/getEntries.js +33 -24
  14. package/lib/common/getPublicPathConfig.js +40 -0
  15. package/lib/common/index.js +27 -13
  16. package/lib/common/splitChunks.js +64 -26
  17. package/lib/common/sslcertUpdater.js +59 -0
  18. package/lib/common/templateParameters.js +25 -0
  19. package/lib/configs/jest.config.js +18 -28
  20. package/lib/configs/webpack.component.umd.config.js +31 -37
  21. package/lib/configs/webpack.css.umd.config.js +44 -44
  22. package/lib/configs/webpack.dev.config.js +113 -57
  23. package/lib/configs/webpack.docs.config.js +104 -98
  24. package/lib/configs/webpack.impact.config.js +116 -0
  25. package/lib/configs/webpack.prod.config.js +154 -86
  26. package/lib/hooks/docsProptypeHook.js +32 -38
  27. package/lib/jest/commitedFilesResult.js +144 -71
  28. package/lib/jest/coverageCollector.js +62 -29
  29. package/lib/jest/jsonMaker.js +54 -0
  30. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  31. package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
  32. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  33. package/lib/jest/result.js +91 -41
  34. package/lib/jest/run.js +74 -27
  35. package/lib/jest/setup.js +103 -102
  36. package/lib/loaderUtils/getCSSLoaders.js +77 -0
  37. package/lib/loaderUtils/getDevJsLoaders.js +30 -23
  38. package/lib/loaderUtils/index.js +14 -7
  39. package/lib/loaders/docsLoader.js +15 -15
  40. package/lib/loaders/docsPropsLoader.js +14 -17
  41. package/lib/loaders/fileBountryLoader.js +17 -0
  42. package/lib/loaders/fileLoader.js +47 -38
  43. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  44. package/lib/loaders/selectorMappingLoader.js +75 -0
  45. package/lib/loaders/workerLoader.js +136 -0
  46. package/lib/middlewares/HMRMiddleware.js +59 -41
  47. package/lib/middlewares/SSTMiddleware.js +21 -0
  48. package/lib/pluginUtils/getDevPlugins.js +173 -26
  49. package/lib/pluginUtils/getDocsPlugins.js +32 -17
  50. package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
  51. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  52. package/lib/pluginUtils/getProdPlugins.js +238 -37
  53. package/lib/pluginUtils/getServerPlugins.js +8 -11
  54. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  55. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  56. package/lib/pluginUtils/index.js +36 -43
  57. package/lib/plugins/CdnChangePlugin.js +77 -0
  58. package/lib/plugins/CleanupStatsPlugin.js +28 -0
  59. package/lib/plugins/EFCPlugin.js +211 -0
  60. package/lib/plugins/EFCPlugin.md +6 -0
  61. package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
  62. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  63. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  64. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  65. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  66. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  67. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  68. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  69. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  70. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  71. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  72. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  73. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  74. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  75. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  76. package/lib/plugins/ManifestPlugin.js +52 -63
  77. package/lib/plugins/ModuleStatsPlugin.js +98 -97
  78. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  79. package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
  80. package/lib/plugins/PublicPathChangePlugin.js +187 -174
  81. package/lib/plugins/ReportGeneratePlugin.js +181 -0
  82. package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
  83. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  84. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
  85. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
  86. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
  87. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
  88. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  89. package/lib/plugins/ServiceWorkerPlugin.js +107 -0
  90. package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
  91. package/lib/plugins/SourceMapHookPlugin.js +25 -31
  92. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  93. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  94. package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
  95. package/lib/plugins/index.js +118 -55
  96. package/lib/plugins/libraryImpactPlugin.js +190 -0
  97. package/lib/plugins/webpackwatchrunplugin.js +26 -0
  98. package/lib/postcss-plugins/ExcludeRTLPlugin.js +23 -0
  99. package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
  100. package/lib/schemas/index.js +463 -52
  101. package/lib/servers/clusterHubServer.js +22 -26
  102. package/lib/servers/docsServer.js +3 -5
  103. package/lib/servers/docsServerCore.js +93 -85
  104. package/lib/servers/helpServer.js +19 -21
  105. package/lib/servers/httpsOptions.js +19 -0
  106. package/lib/servers/impactServer.js +99 -92
  107. package/lib/servers/mockserver.js +44 -0
  108. package/lib/servers/nowatchserver.js +275 -0
  109. package/lib/servers/scrServer.js +147 -0
  110. package/lib/servers/server.js +118 -124
  111. package/lib/servers/ssServer.js +107 -65
  112. package/lib/sh/reportPublish.sh +16 -10
  113. package/lib/templates/CoverageScriptTemplate.js +45 -18
  114. package/lib/templates/WMSTemplate.js +17 -18
  115. package/lib/templates/linterConstant.js +10 -0
  116. package/lib/utils/babelPresets.js +12 -5
  117. package/lib/utils/buildstats.html +148 -0
  118. package/lib/utils/clean.js +12 -11
  119. package/lib/utils/copy.js +13 -127
  120. package/lib/utils/copyTimezones.js +21 -0
  121. package/lib/utils/createEventStream.js +24 -19
  122. package/lib/utils/cssClassNameGenerate.js +70 -0
  123. package/lib/utils/cssURLReplacer.js +67 -54
  124. package/lib/utils/dependencyPostPublish.js +42 -0
  125. package/lib/utils/fileUtils.js +125 -0
  126. package/lib/utils/folderIterator.js +47 -0
  127. package/lib/utils/getComponents.js +126 -0
  128. package/lib/utils/getCurrentBranch.js +11 -17
  129. package/lib/utils/getDependenciesImpactList.js +151 -0
  130. package/lib/utils/getHash.js +26 -0
  131. package/lib/utils/getIp.js +20 -0
  132. package/lib/utils/getOptions.js +55 -30
  133. package/lib/utils/getServerURL.js +25 -8
  134. package/lib/utils/index.js +259 -82
  135. package/lib/utils/init.js +2 -2
  136. package/lib/utils/initPreCommitHook.js +40 -31
  137. package/lib/utils/jsonHelper.js +97 -0
  138. package/lib/utils/libraryImpactConfig.js +63 -0
  139. package/lib/utils/lint/addScripts.js +27 -0
  140. package/lib/utils/lint/checkExistingConfig.js +67 -0
  141. package/lib/utils/lint/copyConfigs.js +24 -0
  142. package/lib/utils/lint/index.js +54 -0
  143. package/lib/utils/lint/lintScripts.js +11 -0
  144. package/lib/utils/lint/lintSetup.js +31 -0
  145. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  146. package/lib/utils/lint/question.js +30 -0
  147. package/lib/utils/lintReporter.js +142 -0
  148. package/lib/utils/mailSender.js +16 -25
  149. package/lib/utils/pullOrigin.js +28 -0
  150. package/lib/utils/reinstallDependencies.js +133 -0
  151. package/lib/utils/removeAttributes.js +25 -23
  152. package/lib/utils/repoClone.js +56 -63
  153. package/lib/utils/request.js +64 -77
  154. package/lib/utils/resultSchema.json +73 -0
  155. package/lib/utils/rtl.js +42 -0
  156. package/lib/utils/setEnvVariables.js +5 -6
  157. package/lib/utils/ssTestHack.js +48 -0
  158. package/lib/utils/switchBranch.js +28 -0
  159. package/lib/utils/urlConcat.js +22 -0
  160. package/package.json +92 -64
  161. package/templates/app/.eslintrc.js +140 -0
  162. package/templates/app/README.md +12 -12
  163. package/templates/app/app/index.html +24 -8
  164. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  165. package/templates/app/app/properties/i18nkeys.json +3 -3
  166. package/templates/app/docs/all.html +69 -69
  167. package/templates/app/mockapi/index.js +18 -13
  168. package/templates/app/package.json +37 -17
  169. package/templates/app/src/actions/SampleActions/index.js +37 -0
  170. package/templates/app/src/actions/index.js +65 -0
  171. package/templates/app/src/appUrls.js +19 -0
  172. package/templates/app/src/components/Alert/Alert.js +134 -0
  173. package/templates/app/src/components/Alert/Alert.module.css +79 -0
  174. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
  175. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
  176. package/templates/app/src/components/Sample/Sample.module.css +11 -0
  177. package/templates/app/src/components/Sample/SampleList.js +61 -0
  178. package/templates/app/src/components/Slider/Slider.css +41 -0
  179. package/templates/app/src/components/Slider/Slider.js +55 -0
  180. package/templates/app/src/containers/AlertContainer/index.js +15 -0
  181. package/templates/app/src/containers/AppContainer/index.js +96 -0
  182. package/templates/app/src/containers/AppContainer/index.module.css +27 -0
  183. package/templates/app/src/containers/CustomMatch/index.js +65 -0
  184. package/templates/app/src/containers/DevTools/index.js +10 -0
  185. package/templates/app/src/containers/Header/index.js +67 -0
  186. package/templates/app/src/containers/Header/index.module.css +43 -0
  187. package/templates/app/src/containers/Redirect/index.js +63 -0
  188. package/templates/app/src/containers/Redirector/index.js +47 -0
  189. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
  190. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
  191. package/templates/app/src/historyChange.js +5 -0
  192. package/templates/app/src/index.html +10 -0
  193. package/templates/app/src/index.js +24 -0
  194. package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
  195. package/templates/app/src/reducers/alertData.js +11 -0
  196. package/templates/app/src/reducers/index.js +6 -0
  197. package/templates/app/src/reducers/samples.js +19 -0
  198. package/templates/app/src/store/configureStore.dev.js +51 -0
  199. package/templates/app/src/store/configureStore.js +5 -0
  200. package/templates/app/src/store/configureStore.prod.js +26 -0
  201. package/templates/app/src/util/Common.js +5 -0
  202. package/templates/app/src/util/RequestAPI.js +132 -0
  203. package/templates/appold/README.md +12 -0
  204. package/templates/appold/app/index.html +8 -0
  205. package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
  206. package/templates/appold/app/properties/i18nkeys.json +3 -0
  207. package/templates/appold/docs/all.html +69 -0
  208. package/templates/appold/mockapi/index.js +13 -0
  209. package/templates/{app → appold}/mockapi/tickets.json +0 -0
  210. package/templates/appold/package.json +17 -0
  211. package/templates/appold/src/components/Text/Text.css +0 -0
  212. package/templates/appold/src/components/Text/Text.js +23 -0
  213. package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
  214. package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
  215. package/templates/appold/src/components/docs.js +1 -0
  216. package/templates/appold/src/components/index.js +5 -0
  217. package/templates/appold/src/index.js +13 -0
  218. package/templates/docs/all.html +1 -1
  219. package/templates/docs/component.html +110 -69
  220. package/templates/docs/components.html +221 -0
  221. package/templates/docs/css/component.css +12 -14
  222. package/templates/docs/css/componentTest.css +7 -0
  223. package/templates/docs/css/style.css +150 -206
  224. package/templates/docs/impactReportTemplate.html +154 -0
  225. package/templates/docs/index.html +1482 -1336
  226. package/templates/library/src/index.js +0 -0
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = loader;
7
+ exports.pitch = pitch;
8
+
9
+ var _path = _interopRequireDefault(require("path"));
10
+
11
+ var _loaderUtils = require("loader-utils");
12
+
13
+ var _schemaUtils = _interopRequireDefault(require("schema-utils"));
14
+
15
+ var _SingleEntryPlugin = _interopRequireDefault(require("webpack/lib/SingleEntryPlugin"));
16
+
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+
19
+ /* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
20
+ import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
21
+ const schema = {
22
+ 'type': 'object',
23
+ 'properties': {
24
+ 'publicPath': {
25
+ 'anyOf': [{
26
+ 'type': 'string'
27
+ }, {
28
+ 'instanceof': 'Function'
29
+ }]
30
+ },
31
+ 'filename': {
32
+ 'anyOf': [{
33
+ 'type': 'string',
34
+ 'minLength': 1
35
+ }, {
36
+ 'instanceof': 'Function'
37
+ }]
38
+ },
39
+ 'chunkFilename': {
40
+ 'type': 'string',
41
+ 'minLength': 1
42
+ },
43
+ 'esModule': {
44
+ 'type': 'boolean'
45
+ }
46
+ },
47
+ 'additionalProperties': false
48
+ }; // eslint-disable-next-line
49
+
50
+ function loader() {}
51
+
52
+ function getDefaultFilename(filename) {
53
+ if (typeof filename === 'function') {
54
+ return filename;
55
+ }
56
+
57
+ return filename.replace(/\.([a-z]+)(\?.+)?$/i, '.worker.$1$2');
58
+ }
59
+
60
+ function getDefaultChunkFilename(chunkFilename) {
61
+ return chunkFilename.replace(/\.([a-z]+)(\?.+)?$/i, '.worker.$1$2');
62
+ }
63
+
64
+ function pitch(request) {
65
+ this.cacheable(false);
66
+ const options = (0, _loaderUtils.getOptions)(this);
67
+ (0, _schemaUtils.default)(schema, options, {
68
+ name: 'Worker Loader',
69
+ baseDataPath: 'options'
70
+ });
71
+ const workerContext = {};
72
+ const compilerOptions = this._compiler.options || {};
73
+ const filename = options.filename ? options.filename : getDefaultFilename(compilerOptions.output.filename);
74
+ const chunkFilename = options.chunkFilename ? options.chunkFilename : getDefaultChunkFilename(compilerOptions.output.chunkFilename);
75
+ const publicPath = options.publicPath ? options.publicPath : compilerOptions.output.publicPath;
76
+ workerContext.options = {
77
+ filename,
78
+ chunkFilename,
79
+ publicPath,
80
+ globalObject: 'self'
81
+ };
82
+ workerContext.compiler = this._compilation.createChildCompiler(`worker-loader ${request}`, workerContext.options);
83
+ /*
84
+ new WebWorkerTemplatePlugin().apply(workerContext.compiler);
85
+
86
+ if (compilerOptions.externals) {
87
+ new ExternalsPlugin(
88
+ getExternalsType(compilerOptions),
89
+ compilerOptions.externals
90
+ ).apply(workerContext.compiler);
91
+ } */
92
+
93
+ new _SingleEntryPlugin.default(this.context, `!!${request}`, _path.default.parse(this.resourcePath).name).apply(workerContext.compiler);
94
+ workerContext.request = request;
95
+ const cb = this.async();
96
+ workerContext.compiler.runAsChild((errorArg, entries, compilation) => {
97
+ let error = errorArg;
98
+
99
+ if (!error && compilation.errors && compilation.errors.length) {
100
+ // eslint-disable-next-line
101
+ error = compilation.errors[0];
102
+ }
103
+
104
+ const entry = entries && entries[0] && entries[0].files.values().next().value;
105
+
106
+ if (!error && !entry) {
107
+ error = Error(`WorkerPlugin: no entry for ${request}`);
108
+ }
109
+
110
+ if (error) {
111
+ return cb(error);
112
+ }
113
+
114
+ function workerCode() {
115
+ let blob;
116
+
117
+ try {
118
+ blob = new Blob([`importScripts('${this.workerUrl}');`], {
119
+ 'type': 'application/javascript'
120
+ });
121
+ } catch (e1) {
122
+ throw new Error(e1);
123
+ }
124
+
125
+ let url = window.URL || window.webkitURL;
126
+ let blobUrl = url.createObjectURL(blob);
127
+ let worker = new Worker(blobUrl);
128
+ return worker;
129
+ }
130
+
131
+ return cb(null, `${options.esModule ? 'export default' : 'module.exports ='} {\n
132
+ workerUrl: __webpack_public_path__ + ${JSON.stringify(entry)}, \n
133
+ getInstance: ${workerCode} \n
134
+ }`);
135
+ });
136
+ }
@@ -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,47 +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;
128
+ let eventStream = createEventStream(opts.heartbeat);
129
+ let latestStats = null;
130
+ let loggedInfo = false;
131
+ compiler.hooks.beforeCompile.tap('HMRMiddleware', (c, callback) => {
132
+ if (opts.log && !loggedInfo) {
133
+ opts.log('webpack compilation starts...');
134
+ loggedInfo = true;
135
+ }
120
136
 
121
- var eventStream = createEventStream(opts.heartbeat);
122
- var latestStats = null;
123
-
124
- compiler.plugin('compile', function () {
137
+ callback && callback();
138
+ });
139
+ compiler.hooks.compile.tap('HMRMiddleware', () => {
125
140
  latestStats = null;
141
+
126
142
  if (opts.log) {
127
143
  opts.log('webpack building...');
128
144
  }
129
- eventStream.publish({ type: 'building' });
145
+
146
+ eventStream.publish({
147
+ type: 'building'
148
+ });
130
149
  });
131
- compiler.plugin('done', function (statsResult) {
150
+ compiler.hooks.done.tap('HMRMiddleware', statsResult => {
132
151
  // Keep hold of latest stats so they can be propagated to new clients
133
152
  latestStats = statsResult;
134
-
135
153
  publishStats('built', latestStats, eventStream, opts.log);
136
154
  });
137
- var middleware = function middleware(req, res, next) {
155
+
156
+ let middleware = function (req, res, next) {
138
157
  if (!pathMatch(req.url, opts.path)) {
139
158
  return next();
140
159
  }
141
- eventStream.handler(req, res);
142
- // if (latestStats) {
160
+
161
+ eventStream.handler(req, res); // if (latestStats) {
143
162
  // // Explicitly not passing in `log` fn as we don't want to log again on
144
163
  // // the server
145
164
  // // publishStats('sync', latestStats, eventStream);
146
165
  // }
147
166
  };
167
+
148
168
  middleware.publish = eventStream.publish;
149
169
  return middleware;
150
- }
151
-
152
- // function buildModuleMap(modules) {
170
+ } // function buildModuleMap(modules) {
153
171
  // let map = {};
154
172
  // modules.forEach(function(module) {
155
173
  // map[module.id] = module.name;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("../utils");
9
+
10
+ function SSTMiddleware(compiler, callback) {
11
+ compiler.hooks.done.tap('SSTMiddleware', stats => {
12
+ (0, _utils.log)('Compilation finished!');
13
+ callback(stats.compilation.assets['js/moduleStats.js'].source());
14
+ });
15
+ return (res, req, next) => {
16
+ next();
17
+ };
18
+ }
19
+
20
+ var _default = SSTMiddleware;
21
+ exports.default = _default;
@@ -1,60 +1,207 @@
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 _miniCssExtractPlugin = require('mini-css-extract-plugin');
16
+ var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
16
17
 
17
- var _miniCssExtractPlugin2 = _interopRequireDefault(_miniCssExtractPlugin);
18
+ var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
18
19
 
19
- var _webpack = require('webpack');
20
+ var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
20
21
 
21
- var _webpack2 = _interopRequireDefault(_webpack);
22
+ var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
22
23
 
23
- var _plugins = require('../plugins');
24
+ var _RequireVariablePublicPlugin = _interopRequireDefault(require("../plugins/RequireVariablePublicPlugin"));
24
25
 
25
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+ var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
27
+
28
+ var _webpack = _interopRequireDefault(require("webpack"));
29
+
30
+ var _plugins = require("../plugins");
26
31
 
27
- var getDevPlugins = function getDevPlugins(options) {
28
- var _options$app = options.app,
29
- folder = _options$app.folder,
30
- instrumentScript = _options$app.instrumentScript,
31
- unusedFiles = options.unusedFiles;
32
+ var _common = require("../common");
32
33
 
34
+ var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
33
35
 
34
- var plugins = [new _caseSensitivePathsWebpackPlugin2.default(), new _webpack2.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack2.default.DefinePlugin({
36
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
+
38
+ let getDevPlugins = (options, publicPath) => {
39
+ let {
40
+ app: {
41
+ tpFolder,
42
+ folder,
43
+ instrumentScript,
44
+ devCssFileBountry,
45
+ context,
46
+ hasEFC: prevOptionForEnableEFC,
47
+ hasShadowDOM,
48
+ server: {
49
+ mode
50
+ },
51
+ htmlTemplate: {
52
+ inject
53
+ },
54
+ crossorigin
55
+ },
56
+ efc: {
57
+ hasEFC: newOptionForEnableEFC,
58
+ nameScope: efcNameSpace,
59
+ localeAttr: efcLocaleAttr
60
+ },
61
+ css: {
62
+ enableRTLSplit
63
+ },
64
+ i18n,
65
+ unusedFiles
66
+ } = options;
67
+ const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
68
+ const cssLTRFileNameTempalte = enableRTLSplit ? 'css/[name].ltr.css' : 'css/[name].css';
69
+ const cssRTLFileNameTempalte = 'css/[name].rtl.css';
70
+ let plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
35
71
  __CLIENT__: true,
36
72
  __TEST__: false,
37
73
  __SERVER__: false,
38
74
  __DEVELOPMENT__: true,
39
75
  __LOCAL_PRODUCTION__: false,
40
76
  __DEVTOOLS__: true,
41
- __DOCS__: false
42
- }), new _miniCssExtractPlugin2.default({
43
- filename: 'css/[name].css',
44
- chunkFilename: 'css/[name].css'
77
+ __DOCS__: false,
78
+ 'process.env': {
79
+ NODE_ENV: JSON.stringify(mode === 'dev-no-warn' ? 'production' : 'development')
80
+ }
81
+ }), new _miniCssExtractPlugin.default({
82
+ filename: cssLTRFileNameTempalte,
83
+ // ignoreOrder: true,
84
+ chunkFilename: cssLTRFileNameTempalte
45
85
  }), new _plugins.ResourceHintsPlugin()];
46
86
 
87
+ if (enableRTLSplit) {
88
+ plugins.push(new _RtlCssPlugin.RtlCssPlugin({
89
+ templateLabel: options.css.templateLabel,
90
+ dirVarName: options.css.dirVarName,
91
+ disableMiniFiySelector: options.css.disableMiniFiySelector,
92
+ // config: {},
93
+ // sourcemap: true,
94
+ filename: cssRTLFileNameTempalte
95
+ }));
96
+ }
97
+
47
98
  if (unusedFiles.enable) {
48
99
  plugins.push(new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
49
- origin: _path2.default.join(process.cwd(), folder)
100
+ origin: _path.default.join(process.cwd(), folder)
50
101
  })));
51
102
  }
52
103
 
53
- if (instrumentScript) {
54
- plugins.push(new _plugins.ScriptInstrumentPlugin());
104
+ const i18nManifestFileName = 'i18n-manifest.json';
105
+ /**
106
+ * NOTE:
107
+ * this file name ext .i18n.js added
108
+ * Because, in service worker they maintain cache as file name based
109
+ * So, to make differce we added .i18n.js ext.
110
+ */
111
+
112
+ const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].i18n.js';
113
+ const i18nPublicPath = publicPath || '';
114
+
115
+ if (i18n.chunkSplitEnable) {
116
+ plugins.push(new _I18nSplitPlugin.default({
117
+ jsResource: i18n.jsResource,
118
+ localeVarName: i18n.localeVarName,
119
+ jsonpFunc: i18n.jsonpFunc,
120
+ disableDefault: i18n.disableDefault,
121
+ publicPath: i18nPublicPath,
122
+ i18nManifestFileName,
123
+ // template: (object, locale) => `window.loadI18n(${JSON.stringify(object)}, ${JSON.stringify(locale)})`,
124
+ filenameTemplate: i18nFileNameTemplate,
125
+ propertiesFolder: i18n.propertiesFolder
126
+ }));
127
+ } else {
128
+ let i18nPath = _path.default.join(process.cwd(), context, 'i18n');
129
+
130
+ if (_fs.default.existsSync(i18nPath)) {
131
+ plugins.push(new _copyWebpackPlugin.default([{
132
+ from: `${i18nPath}/`,
133
+ to: './i18n/[name].[ext]',
134
+ toType: 'template'
135
+ }]));
136
+ }
137
+ }
138
+
139
+ tpFolder && plugins.push(new _copyWebpackPlugin.default([{
140
+ from: `${_path.default.join(process.cwd(), context, tpFolder)}/`,
141
+ to: `./${tpFolder}/`,
142
+ toType: 'dir'
143
+ }]));
144
+ plugins.push(new _lodashWebpackPlugin.default({
145
+ collections: true,
146
+ shorthands: true
147
+ }));
148
+
149
+ if (hasEFC) {
150
+ plugins.push(new _htmlWebpackPlugin.default({
151
+ chunksSortMode: 'none',
152
+ filename: 'index.html',
153
+ template: _path.default.join(process.cwd(), folder, 'index.html'),
154
+ excludeChunks: ['efc', 'widget'],
155
+ templateParameters: _common.templateParameters,
156
+ scriptLoading: 'defer',
157
+ inject: inject
158
+ }));
159
+ crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
160
+ crossorigin: 'anonymous'
161
+ }));
162
+ plugins.push(new _plugins.EFCPlugin({
163
+ isDevelopment: true,
164
+ i18nManifestFileName,
165
+ i18nFileNameTemplate,
166
+ serverUrl: publicPath,
167
+ entryPointName: 'efc',
168
+ nameScope: efcNameSpace,
169
+ localeAttr: efcLocaleAttr // outputFile: 'zohodesk-efc-sdk-latest.js',
170
+
171
+ }));
172
+ } else {
173
+ plugins.push(new _htmlWebpackPlugin.default({
174
+ chunksSortMode: 'none',
175
+ filename: 'index.html',
176
+ template: _path.default.join(process.cwd(), folder, 'index.html'),
177
+ templateParameters: _common.templateParameters,
178
+ scriptLoading: 'defer',
179
+ inject: inject
180
+ }));
181
+ crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
182
+ crossorigin: 'anonymous'
183
+ }));
184
+ }
185
+
186
+ plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
187
+ publicPath: i18nPublicPath,
188
+ isDevelopment: true,
189
+ templateLabel: i18n.templateLabel || '{{--user-locale}}',
190
+ i18nFileNameTemplate,
191
+ i18nManifestFileName,
192
+ mainChunkName: 'main'
193
+ }));
194
+ instrumentScript && plugins.push(new _plugins.ScriptInstrumentPlugin());
195
+ hasShadowDOM && plugins.push(new _plugins.ShadowDOMSupportPlugin());
196
+
197
+ if (devCssFileBountry) {
198
+ plugins.push(new _RequireVariablePublicPlugin.default({
199
+ requireFuncName: 'require'
200
+ }));
55
201
  }
56
202
 
57
- return plugins;
203
+ return plugins.filter(Boolean);
58
204
  };
59
205
 
60
- exports.default = getDevPlugins;
206
+ var _default = getDevPlugins;
207
+ exports.default = _default;
@@ -1,39 +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 _ModuleStatsPlugin = require('../plugins/ModuleStatsPlugin');
20
-
21
- var _ModuleStatsPlugin2 = _interopRequireDefault(_ModuleStatsPlugin);
16
+ var _plugins = require("../plugins");
22
17
 
23
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
19
 
25
- var getDocsPlugins = function getDocsPlugins(isSSTest) {
26
- var plugins = [new _caseSensitivePathsWebpackPlugin2.default(), new _webpack2.default.ProvidePlugin({
20
+ // isForLibraryImpact this variable for now only used in getLibraryImactPlugins.
21
+ // So you gona use it please check with that function as well
22
+ let getDocsPlugins = (isSSTest, options, isForLibraryImpact = false) => {
23
+ let {
24
+ app: {
25
+ folder
26
+ },
27
+ unusedFiles
28
+ } = options;
29
+ let plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.ProvidePlugin({
27
30
  React: 'react'
28
- }), new _webpack2.default.DefinePlugin({
31
+ }), new _webpack.default.DefinePlugin({
29
32
  __TEST__: false,
30
33
  __DEVELOPMENT__: true,
31
34
  __DOCS__: true
32
- }), isSSTest && new _ModuleStatsPlugin2.default({ filename: 'moduleStats.js' }), new _miniCssExtractPlugin2.default({
35
+ }), !isForLibraryImpact && new _plugins.ModuleStatsPlugin({
36
+ filename: 'js/moduleStats.js'
37
+ }), new _miniCssExtractPlugin.default({
33
38
  filename: 'css/[name].css',
34
39
  chunkFilename: 'css/[name].css'
35
40
  })].filter(Boolean);
41
+
42
+ if (unusedFiles.enable) {
43
+ plugins.push(new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
44
+ docsFilename: 'Undocsfiles.json',
45
+ ssTest: true,
46
+ origin: _path.default.join(process.cwd(), folder)
47
+ })));
48
+ }
49
+
36
50
  return plugins;
37
51
  };
38
52
 
39
- exports.default = getDocsPlugins;
53
+ var _default = getDocsPlugins;
54
+ exports.default = _default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = getLibraryImactPlugins;
7
+
8
+ var _libraryImpactPlugin = _interopRequireDefault(require("../plugins/libraryImpactPlugin"));
9
+
10
+ var _getDocsPlugins = _interopRequireDefault(require("./getDocsPlugins"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ // import ModuleStatsPlugin from '../plugins/ModuleStatsPlugin';
15
+ function getLibraryImactPlugins(options) {
16
+ let plugins = (0, _getDocsPlugins.default)(false, options, true); // for performance But for furture maintanablity we adding isForLibraryImpact in getDocsPlugin
17
+ // plugins.filter(plugin => !(plugin instanceof ModuleStatsPlugin));
18
+
19
+ plugins.push(new _libraryImpactPlugin.default({
20
+ filename: 'js/libraryImpact.js'
21
+ }));
22
+ return plugins;
23
+ }