@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.2

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 (202) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +183 -183
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +636 -491
  5. package/bin/cli.js +372 -367
  6. package/files/eslintrc.js +57 -0
  7. package/files/prettierrc.js +3 -0
  8. package/lib/babel/cmjs-plugins-presets.js +16 -9
  9. package/lib/babel/es-plugins-presets.js +26 -14
  10. package/lib/common/getEntries.js +31 -22
  11. package/lib/common/getPublicPathConfig.js +27 -13
  12. package/lib/common/index.js +21 -25
  13. package/lib/common/splitChunks.js +62 -53
  14. package/lib/common/templateParameters.js +10 -8
  15. package/lib/configs/jest.config.js +15 -25
  16. package/lib/configs/webpack.component.umd.config.js +31 -37
  17. package/lib/configs/webpack.css.umd.config.js +44 -47
  18. package/lib/configs/webpack.dev.config.js +70 -52
  19. package/lib/configs/webpack.docs.config.js +106 -106
  20. package/lib/configs/webpack.prod.config.js +95 -75
  21. package/lib/hooks/docsProptypeHook.js +32 -38
  22. package/lib/jest/commitedFilesResult.js +103 -74
  23. package/lib/jest/coverageCollector.js +41 -21
  24. package/lib/jest/jsonMaker.js +15 -16
  25. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  26. package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
  27. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  28. package/lib/jest/result.js +90 -45
  29. package/lib/jest/run.js +43 -43
  30. package/lib/jest/setup.js +102 -95
  31. package/lib/loaderUtils/getCSSLoaders.js +21 -22
  32. package/lib/loaderUtils/getDevJsLoaders.js +25 -23
  33. package/lib/loaderUtils/index.js +11 -13
  34. package/lib/loaders/docsLoader.js +15 -15
  35. package/lib/loaders/docsPropsLoader.js +14 -17
  36. package/lib/loaders/fileLoader.js +33 -35
  37. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  38. package/lib/loaders/workerLoader.js +136 -0
  39. package/lib/middlewares/HMRMiddleware.js +54 -45
  40. package/lib/middlewares/SSTMiddleware.js +8 -5
  41. package/lib/pluginUtils/getDevPlugins.js +114 -52
  42. package/lib/pluginUtils/getDocsPlugins.js +25 -29
  43. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  44. package/lib/pluginUtils/getProdPlugins.js +163 -74
  45. package/lib/pluginUtils/getServerPlugins.js +8 -11
  46. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  47. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  48. package/lib/pluginUtils/index.js +36 -43
  49. package/lib/plugins/CdnChangePlugin.js +63 -0
  50. package/lib/plugins/CleanupStatsPlugin.js +18 -32
  51. package/lib/plugins/CustomAttributePlugin.js +79 -0
  52. package/lib/plugins/CustomAttributePlugin.md +35 -0
  53. package/lib/plugins/EFCPlugin.js +185 -0
  54. package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
  55. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  56. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  57. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  58. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  59. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  60. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  61. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  62. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  63. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  64. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  65. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  66. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  67. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  68. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  69. package/lib/plugins/ManifestPlugin.js +52 -63
  70. package/lib/plugins/ModuleStatsPlugin.js +83 -173
  71. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  72. package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
  73. package/lib/plugins/PublicPathChangePlugin.js +175 -284
  74. package/lib/plugins/ReportGeneratePlugin.js +150 -151
  75. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  76. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  77. package/lib/plugins/ServiceWorkerPlugin.js +81 -57
  78. package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
  79. package/lib/plugins/SourceMapHookPlugin.js +21 -33
  80. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  81. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  82. package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
  83. package/lib/plugins/index.js +100 -91
  84. package/lib/plugins/webpackwatchrunplugin.js +18 -30
  85. package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
  86. package/lib/schemas/index.js +336 -81
  87. package/lib/servers/clusterHubServer.js +22 -26
  88. package/lib/servers/docsServer.js +3 -5
  89. package/lib/servers/docsServerCore.js +84 -91
  90. package/lib/servers/helpServer.js +19 -21
  91. package/lib/servers/impactServer.js +99 -92
  92. package/lib/servers/mockserver.js +24 -24
  93. package/lib/servers/scrServer.js +78 -98
  94. package/lib/servers/server.js +101 -122
  95. package/lib/servers/ssServer.js +63 -61
  96. package/lib/sh/pre-commit.sh +34 -34
  97. package/lib/sh/reportPublish.sh +45 -46
  98. package/lib/templates/CoverageScriptTemplate.js +45 -18
  99. package/lib/templates/WMSTemplate.js +17 -18
  100. package/lib/templates/linterConstant.js +6 -4
  101. package/lib/utils/babelPresets.js +12 -5
  102. package/lib/utils/buildstats.html +148 -148
  103. package/lib/utils/clean.js +12 -11
  104. package/lib/utils/copy.js +12 -34
  105. package/lib/utils/copyTimezones.js +9 -16
  106. package/lib/utils/createEventStream.js +24 -19
  107. package/lib/utils/cssClassNameGenerate.js +44 -73
  108. package/lib/utils/cssURLReplacer.js +60 -54
  109. package/lib/utils/dependencyPostPublish.js +20 -19
  110. package/lib/utils/fileUtils.js +66 -54
  111. package/lib/utils/folderIterator.js +20 -21
  112. package/lib/utils/getComponents.js +70 -27
  113. package/lib/utils/getCurrentBranch.js +11 -17
  114. package/lib/utils/getDependenciesImpactList.js +114 -187
  115. package/lib/utils/getHash.js +9 -13
  116. package/lib/utils/getIp.js +9 -9
  117. package/lib/utils/getOptions.js +26 -29
  118. package/lib/utils/getServerURL.js +19 -10
  119. package/lib/utils/index.js +147 -126
  120. package/lib/utils/init.js +2 -2
  121. package/lib/utils/initPreCommitHook.js +40 -32
  122. package/lib/utils/jsonHelper.js +37 -21
  123. package/lib/utils/lint/addScripts.js +27 -0
  124. package/lib/utils/lint/checkExistingConfig.js +67 -0
  125. package/lib/utils/lint/copyConfigs.js +24 -0
  126. package/lib/utils/lint/index.js +54 -0
  127. package/lib/utils/lint/lintScripts.js +11 -0
  128. package/lib/utils/lint/lintSetup.js +31 -0
  129. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  130. package/lib/utils/lint/question.js +30 -0
  131. package/lib/utils/lintReporter.js +70 -56
  132. package/lib/utils/mailSender.js +12 -27
  133. package/lib/utils/pullOrigin.js +21 -18
  134. package/lib/utils/reinstallDependencies.js +76 -85
  135. package/lib/utils/removeAttributes.js +25 -23
  136. package/lib/utils/repoClone.js +47 -45
  137. package/lib/utils/request.js +64 -77
  138. package/lib/utils/resultSchema.json +73 -73
  139. package/lib/utils/rtl.js +22 -29
  140. package/lib/utils/setEnvVariables.js +5 -6
  141. package/lib/utils/ssTestHack.js +21 -19
  142. package/lib/utils/switchBranch.js +21 -20
  143. package/lib/utils/urlConcat.js +22 -0
  144. package/package.json +141 -136
  145. package/templates/app/.eslintrc.js +140 -140
  146. package/templates/app/README.md +12 -12
  147. package/templates/app/app/index.html +24 -24
  148. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  149. package/templates/app/app/properties/i18nkeys.json +3 -3
  150. package/templates/app/docs/all.html +69 -69
  151. package/templates/app/mockapi/index.js +18 -18
  152. package/templates/app/package.json +37 -37
  153. package/templates/app/src/actions/SampleActions/index.js +37 -37
  154. package/templates/app/src/actions/index.js +65 -65
  155. package/templates/app/src/appUrls.js +19 -19
  156. package/templates/app/src/components/Alert/Alert.js +134 -134
  157. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  158. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  159. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  160. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  161. package/templates/app/src/components/Sample/SampleList.js +61 -61
  162. package/templates/app/src/components/Slider/Slider.css +41 -41
  163. package/templates/app/src/components/Slider/Slider.js +55 -55
  164. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  165. package/templates/app/src/containers/AppContainer/index.js +96 -96
  166. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  167. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  168. package/templates/app/src/containers/DevTools/index.js +10 -10
  169. package/templates/app/src/containers/Header/index.js +67 -67
  170. package/templates/app/src/containers/Header/index.module.css +43 -43
  171. package/templates/app/src/containers/Redirect/index.js +63 -63
  172. package/templates/app/src/containers/Redirector/index.js +47 -47
  173. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  174. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  175. package/templates/app/src/historyChange.js +5 -5
  176. package/templates/app/src/index.html +10 -10
  177. package/templates/app/src/index.js +24 -24
  178. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  179. package/templates/app/src/reducers/alertData.js +11 -11
  180. package/templates/app/src/reducers/index.js +6 -6
  181. package/templates/app/src/reducers/samples.js +19 -19
  182. package/templates/app/src/store/configureStore.dev.js +51 -51
  183. package/templates/app/src/store/configureStore.js +5 -5
  184. package/templates/app/src/store/configureStore.prod.js +26 -26
  185. package/templates/app/src/util/Common.js +5 -5
  186. package/templates/app/src/util/RequestAPI.js +132 -132
  187. package/templates/docs/all.html +249 -249
  188. package/templates/docs/component.html +178 -178
  189. package/templates/docs/components.html +221 -221
  190. package/templates/docs/css/b.min.css +6 -6
  191. package/templates/docs/css/component.css +42 -42
  192. package/templates/docs/css/componentTest.css +6 -6
  193. package/templates/docs/css/hopscotch.css +585 -585
  194. package/templates/docs/css/style.css +1022 -1022
  195. package/templates/docs/index.html +1493 -1493
  196. package/templates/docs/js/active-line.js +72 -72
  197. package/templates/docs/js/b.min.js +7 -7
  198. package/templates/docs/js/codemirror.js +9680 -9680
  199. package/templates/docs/js/designTokens.js +334 -334
  200. package/templates/docs/js/j.min.js +4 -4
  201. package/templates/docs/js/javascript.js +874 -874
  202. package/templates/docs/js/matchbrackets.js +145 -145
@@ -0,0 +1,57 @@
1
+ const [off, , error] = ['off', 'warn', 'error'];
2
+
3
+ module.exports = {
4
+ env: {
5
+ browser: true,
6
+ es2021: true,
7
+ },
8
+ extends: ['plugin:react/recommended', 'airbnb', 'prettier'],
9
+ parserOptions: {
10
+ ecmaFeatures: {
11
+ jsx: true,
12
+ },
13
+ ecmaVersion: 12,
14
+ sourceType: 'module',
15
+ },
16
+ plugins: [
17
+ 'react',
18
+ 'css-modules',
19
+ '@zohodesk/zsecurity',
20
+ '@zohodesk/react-performance',
21
+ ],
22
+ rules: {
23
+ // Internal Rules
24
+ '@zohodesk/react-performance/no-ref-mapstatetoprops': error,
25
+ '@zohodesk/zsecurity/no-unsecure-html': error,
26
+ '@zohodesk/zsecurity/no-protocol-check': error,
27
+
28
+ // CSS Module Rules
29
+ 'css-modules/no-unused-class': [error, { camelCase: true }],
30
+ 'css-modules/no-undef-class': [error, { camelCase: 'only' }],
31
+
32
+ 'import/no-unresolved': off,
33
+ 'import/no-extraneous-dependencies': off,
34
+
35
+ // As redux used
36
+ 'no-shadow': off, // As we import the action files and use the same name in getting from props built from connect.
37
+ 'react/jsx-filename-extension': off,
38
+
39
+ // As we don't follow
40
+ 'react/require-default-props': off,
41
+ 'react/jsx-props-no-spreading': off,
42
+
43
+ // As we didn't update
44
+ 'react/jsx-fragments': off,
45
+
46
+ // Not needed
47
+ 'no-plusplus': off,
48
+ 'no-unused-expressions': [
49
+ error,
50
+ {
51
+ allowShortCircuit: true,
52
+ allowTernary: true,
53
+ },
54
+ ],
55
+ 'react/jsx-no-target-blank': error,
56
+ },
57
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ trailingComma: 'none',
3
+ };
@@ -1,17 +1,24 @@
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
- var _getOptions = (0, _utils.getOptions)(),
10
- mode = _getOptions.module.mode;
10
+ let {
11
+ module: {
12
+ mode
13
+ }
14
+ } = (0, _utils.getOptions)();
15
+ let isProd = mode.toLowerCase() === 'prod';
11
16
 
12
- var isProd = mode.toLowerCase() === 'prod';
17
+ var _default = () => ({
18
+ presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
19
+ plugins: [[require.resolve('babel-plugin-transform-define'), isProd ? {
20
+ __DOCS__: false
21
+ } : {}]]
22
+ });
13
23
 
14
- exports.default = {
15
- presets: ['env', 'react'],
16
- plugins: [['transform-define', isProd ? { __DOCS__: false } : {}], 'syntax-dynamic-import']
17
- };
24
+ exports.default = _default;
@@ -1,22 +1,34 @@
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
- var _getOptions = (0, _utils.getOptions)(),
10
- mode = _getOptions.module.mode;
10
+ let {
11
+ module: {
12
+ mode,
13
+ disableES5Transpile
14
+ }
15
+ } = (0, _utils.getOptions)();
16
+ let isProd = mode.toLowerCase() === 'prod';
11
17
 
12
- var isProd = mode.toLowerCase() === 'prod';
18
+ var _default = () => ({
19
+ presets: [[require.resolve('@babel/preset-env'), disableES5Transpile ? {
20
+ modules: false,
21
+ useBuiltIns: 'usage',
22
+ corejs: 3,
23
+ targets: {
24
+ browsers: ['last 3 Chrome versions', 'last 3 Firefox versions', 'last 3 Edge versions', 'last 3 Safari versions']
25
+ }
26
+ } : {
27
+ modules: false
28
+ }], require.resolve('@babel/preset-react')],
29
+ plugins: [[require.resolve('babel-plugin-transform-define'), isProd ? {
30
+ __DOCS__: false
31
+ } : {}], require.resolve('@babel/plugin-syntax-dynamic-import')]
32
+ });
13
33
 
14
- exports.default = {
15
- presets: [['env', { modules: false }], 'react'],
16
- plugins: [['transform-runtime', {
17
- helpers: true,
18
- polyfill: true,
19
- regenerator: false,
20
- moduleName: 'babel-runtime'
21
- }], ['transform-define', isProd ? { __DOCS__: false } : {}], 'syntax-dynamic-import']
22
- };
34
+ exports.default = _default;
@@ -1,43 +1,52 @@
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
-
11
- var _utils = require('../utils');
10
+ var _utils = require("../utils");
12
11
 
13
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
13
 
15
- var getEntries = function getEntries(appSchemas, mode) {
16
- var appPath = process.cwd();
17
- var _appSchemas$app = appSchemas.app,
18
- isReactMig = _appSchemas$app.isReactMig,
19
- hasWidget = _appSchemas$app.hasWidget,
20
- hasEFC = _appSchemas$app.hasEFC,
21
- server = _appSchemas$app.server,
22
- folder = _appSchemas$app.folder;
23
-
24
-
25
- var mainJs = [];
26
- var entry = { main: mainJs };
14
+ let getEntries = (appSchemas, mode) => {
15
+ let appPath = process.cwd();
16
+ let {
17
+ isReactMig,
18
+ hasWidget,
19
+ server,
20
+ folder
21
+ } = appSchemas.app;
22
+ const {
23
+ hasEFC: prevOptionForEnableEFC
24
+ } = appSchemas.app;
25
+ const {
26
+ hasEFC: newOptionForEnableEFC
27
+ } = appSchemas.efc;
28
+ const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
29
+ let mainJs = [];
30
+ let entry = {
31
+ main: mainJs
32
+ };
27
33
 
28
34
  if (mode === 'dev' || mode === 'dev-no-warn') {
29
- mainJs.push(_path2.default.join(__dirname, '..', 'templates', 'WMSTemplate') + '?wmsPath=wss:' + (0, _utils.getServerURL)(server));
35
+ mainJs.push(`${_path.default.join(__dirname, '..', 'templates', 'WMSTemplate')}?wmsPath=wss:${(0, _utils.getServerURL)(server)}`);
30
36
  }
31
37
 
32
- mainJs.push(_path2.default.join(appPath, folder, isReactMig ? 'migration.js' : 'index.js'));
38
+ mainJs.push(_path.default.join(appPath, folder, isReactMig ? 'migration.js' : 'index.js'));
33
39
 
34
40
  if (hasWidget) {
35
- entry.widget = [_path2.default.join(appPath, folder, 'widget.js')];
41
+ entry.widget = [_path.default.join(appPath, folder, 'widget.js')];
36
42
  }
43
+
37
44
  if (hasEFC) {
38
- entry.efc = [_path2.default.join(appPath, folder, 'efc.js')];
45
+ entry.efc = [_path.default.join(appPath, folder, 'efc.js')];
39
46
  }
40
47
 
41
48
  return entry;
42
49
  };
43
- exports.default = getEntries;
50
+
51
+ var _default = getEntries;
52
+ exports.default = _default;
@@ -1,26 +1,40 @@
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
- var _getOptions = (0, _utils.getOptions)(),
10
- _getOptions$app = _getOptions.app,
11
- publicPaths = _getOptions$app.publicPaths,
12
- mode = _getOptions$app.server.mode;
10
+ let {
11
+ app: {
12
+ publicPaths,
13
+ cdnMapping: {
14
+ isCdnEnabled,
15
+ variableName
16
+ },
17
+ server: {
18
+ mode
19
+ }
20
+ }
21
+ } = (0, _utils.getOptions)();
22
+ let isDevelopment = mode === 'dev' || mode === 'prod' || mode === 'dev-no-warn';
13
23
 
14
- var isDevelopment = mode === 'dev' || mode === 'prod' || mode === 'dev-no-warn';
24
+ var _default = url => {
25
+ let type = (0, _utils.getFileType)(url);
15
26
 
16
- exports.default = function (url) {
17
- var type = (0, _utils.getFileType)(url);
18
27
  if (!isDevelopment) {
19
28
  if (publicPaths && publicPaths.callback) {
20
- return publicPaths.callback + '(' + JSON.stringify(type) + ') + ' + JSON.stringify(url);
29
+ return `${publicPaths.callback}(${JSON.stringify(type)}) + ${JSON.stringify(url)}`;
30
+ } else if (isCdnEnabled) {
31
+ return `window["${variableName}"] + ${JSON.stringify(url)}`;
21
32
  } else if (publicPaths) {
22
- return '__REACT_CLI_' + type.toUpperCase() + '_PUBLIC_PATH__ + ' + JSON.stringify(url);
33
+ return `__REACT_CLI_${type.toUpperCase()}_PUBLIC_PATH__ + ${JSON.stringify(url)}`;
23
34
  }
24
35
  }
25
- return '__webpack_public_path__ + ' + JSON.stringify(url);
26
- };
36
+
37
+ return `__webpack_public_path__ + ${JSON.stringify(url)}`;
38
+ };
39
+
40
+ exports.default = _default;
@@ -1,43 +1,39 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
- var _splitChunks = require('./splitChunks');
8
-
9
- Object.defineProperty(exports, 'splitChunks', {
6
+ Object.defineProperty(exports, "getEntries", {
10
7
  enumerable: true,
11
- get: function get() {
12
- return _interopRequireDefault(_splitChunks).default;
8
+ get: function () {
9
+ return _getEntries.default;
13
10
  }
14
11
  });
15
-
16
- var _getEntries = require('./getEntries');
17
-
18
- Object.defineProperty(exports, 'getEntries', {
12
+ Object.defineProperty(exports, "getPublicPathConfig", {
19
13
  enumerable: true,
20
- get: function get() {
21
- return _interopRequireDefault(_getEntries).default;
14
+ get: function () {
15
+ return _getPublicPathConfig.default;
22
16
  }
23
17
  });
24
-
25
- var _getPublicPathConfig = require('./getPublicPathConfig');
26
-
27
- Object.defineProperty(exports, 'getPublicPathConfig', {
18
+ Object.defineProperty(exports, "splitChunks", {
28
19
  enumerable: true,
29
- get: function get() {
30
- return _interopRequireDefault(_getPublicPathConfig).default;
20
+ get: function () {
21
+ return _splitChunks.default;
31
22
  }
32
23
  });
33
-
34
- var _templateParameters = require('./templateParameters');
35
-
36
- Object.defineProperty(exports, 'templateParameters', {
24
+ Object.defineProperty(exports, "templateParameters", {
37
25
  enumerable: true,
38
- get: function get() {
39
- return _interopRequireDefault(_templateParameters).default;
26
+ get: function () {
27
+ return _templateParameters.default;
40
28
  }
41
29
  });
42
30
 
31
+ var _splitChunks = _interopRequireDefault(require("./splitChunks"));
32
+
33
+ var _getEntries = _interopRequireDefault(require("./getEntries"));
34
+
35
+ var _getPublicPathConfig = _interopRequireDefault(require("./getPublicPathConfig"));
36
+
37
+ var _templateParameters = _interopRequireDefault(require("./templateParameters"));
38
+
43
39
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,69 +1,78 @@
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 _utils = require("../utils");
10
11
 
11
- var _utils = require('../utils');
12
+ var _os = _interopRequireDefault(require("os"));
12
13
 
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
 
15
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
16
-
17
- var ps = _path2.default.sep;
18
- var options = (0, _utils.getOptions)();
19
- var vendorExclude = options.app.vendorExclude;
20
-
21
-
22
- var isVendor = function isVendor(module) {
23
- var userRequest = module.userRequest;
24
-
25
- var excludeList = ['script-loader', 'raw-loader', 'react', 'react-dom'];
16
+ let isWindows = _os.default.platform().toLowerCase() === 'win32';
17
+ let ps = _path.default.sep;
18
+ let options = (0, _utils.getOptions)();
19
+ let {
20
+ app: {
21
+ vendorExclude,
22
+ customChunks
23
+ }
24
+ } = options;
26
25
 
27
- excludeList = [].concat(_toConsumableArray(excludeList), _toConsumableArray(vendorExclude));
28
- return userRequest && userRequest.indexOf('node_modules') >= 0 && userRequest.endsWith('.css') === false && userRequest.endsWith('publicPathConfig.js') === false && excludeList.every(function (item) {
29
- return userRequest.indexOf('node_modules' + ps + item + ps) === -1;
30
- });
26
+ let isVendor = function isVendor(module) {
27
+ let {
28
+ userRequest
29
+ } = module;
30
+ let excludeList = ['script-loader', 'raw-loader', 'react', 'react-dom'];
31
+ excludeList = [...excludeList, ...vendorExclude];
32
+ return userRequest && userRequest.indexOf('node_modules') >= 0 && userRequest.endsWith('.css') === false && userRequest.endsWith('publicPathConfig.js') === false && excludeList.every(item => userRequest.indexOf(`node_modules${ps}${item}${ps}`) === -1);
31
33
  };
32
34
 
33
- var isReact = function isReact(module) {
34
- var userRequest = module.userRequest;
35
-
36
- var reactBundle = ['react', 'react-dom'];
37
- return userRequest && reactBundle.some(function (pkg) {
38
- return userRequest.indexOf('node_modules' + ps + pkg + ps) >= 0;
39
- });
35
+ let isReact = module => {
36
+ let {
37
+ userRequest
38
+ } = module;
39
+ let reactBundle = ['react', 'react-dom'];
40
+ return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
40
41
  };
41
42
 
42
- exports.default = {
43
- cacheGroups: {
44
- default: false,
45
- vendors: false,
46
- 'react.vendor': {
47
- name: 'react.vendor',
48
- chunks: 'all',
49
- minChunks: 1,
50
- test: isReact,
51
- priority: -10
52
- },
53
- vendor: {
54
- name: 'vendor',
55
- chunks: 'all',
56
- minChunks: 1,
57
- test: isVendor,
58
- priority: -10
59
- },
60
- styles: {
61
- name: 'styles',
62
- test: /\.css$/,
63
- chunks: 'all',
64
- enforce: true, // force css in new chunks (ignores all other options)
65
- minChunks: 2,
66
- priority: -20
67
- }
43
+ let defaultChunks = {
44
+ 'react.vendor': {
45
+ name: 'react.vendor',
46
+ chunks: 'all',
47
+ minChunks: 1,
48
+ test: isReact,
49
+ priority: -10
50
+ },
51
+ vendor: {
52
+ name: 'vendor',
53
+ chunks: 'all',
54
+ minChunks: 1,
55
+ test: isVendor,
56
+ priority: -10
68
57
  }
69
- };
58
+ };
59
+ let customChunksConfig = {};
60
+ customChunks.map(({
61
+ name,
62
+ pattern,
63
+ size = 2
64
+ }, index) => customChunksConfig[name] = {
65
+ name,
66
+ test: new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern),
67
+ chunks: 'all',
68
+ enforce: true,
69
+ minChunks: size,
70
+ priority: -10 * (index + 2)
71
+ });
72
+ var _default = {
73
+ cacheGroups: Object.assign({
74
+ default: false,
75
+ vendors: false
76
+ }, defaultChunks, customChunksConfig)
77
+ };
78
+ exports.default = _default;
@@ -1,23 +1,25 @@
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
- exports.default = function (compilation, assets, assetTags, options) {
8
- Object.keys(assetTags).forEach(function (rootTag) {
9
- assetTags[rootTag].forEach(function (tag) {
8
+ var _default = (compilation, assets, assetTags, options) => {
9
+ Object.keys(assetTags).forEach(rootTag => {
10
+ assetTags[rootTag].forEach(tag => {
10
11
  tag.attributes.nonce = '{{--CSP-nonce}}';
11
12
  });
12
13
  });
13
-
14
14
  return {
15
- compilation: compilation,
15
+ compilation,
16
16
  webpackConfig: compilation.options,
17
17
  htmlWebpackPlugin: {
18
18
  tags: assetTags,
19
19
  files: assets,
20
- options: options
20
+ options
21
21
  }
22
22
  };
23
- };
23
+ };
24
+
25
+ exports.default = _default;
@@ -1,28 +1,25 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _path = require('path');
4
-
5
- var _path2 = _interopRequireDefault(_path);
3
+ var _path = _interopRequireDefault(require("path"));
6
4
 
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
6
 
9
- var appPath = process.cwd();
10
-
11
- var commonConfig = {
7
+ let appPath = process.cwd();
8
+ let commonConfig = {
12
9
  coverageReporters: ['json', 'html', 'json-summary', 'text'],
13
10
  collectCoverage: true,
14
- moduleDirectories: [_path2.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
11
+ moduleDirectories: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
15
12
  transform: {
16
- '^.+\\.(js|jsx)$': _path2.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'jsPreprocessor.js'),
17
- '^.+\\.css$': _path2.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'cssPreprocessor.js'),
18
- '^(?!.*\\.(js|jsx|css|json)$)': _path2.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'otherFilesPreprocessor.js')
13
+ '^.+\\.(js|jsx)$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'jsPreprocessor.js'),
14
+ '^.+\\.css$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'cssPreprocessor.js'),
15
+ '^(?!.*\\.(js|jsx|css|json)$)': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'otherFilesPreprocessor.js')
19
16
  },
20
17
  moduleNameMapper: {
21
18
  '\\.(css|less)$': 'identity-obj-proxy'
22
19
  },
23
20
  transformIgnorePatterns: ['/node_modules.*?.js$'],
24
21
  moduleFileExtensions: ['js'],
25
- setupFiles: [_path2.default.resolve(appPath, '__testUtils__', 'globals.js'), _path2.default.resolve(__dirname, '..', 'jest', 'setup.js')],
22
+ setupFiles: [_path.default.resolve(appPath, '__testUtils__', 'globals.js'), _path.default.resolve(__dirname, '..', 'jest', 'setup.js')],
26
23
  globals: {
27
24
  __DEVELOPMENT__: true,
28
25
  __DOCS__: false,
@@ -30,20 +27,13 @@ var commonConfig = {
30
27
  }
31
28
  };
32
29
 
33
- module.exports = function () {
34
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
35
- args[_key] = arguments[_key];
36
- }
37
-
38
- var appFolder = args[0],
39
- _args$ = args[1],
40
- forCommittedFiles = _args$ === undefined ? false : _args$;
41
-
30
+ module.exports = (...args) => {
31
+ let [appFolder, forCommittedFiles = false] = args;
42
32
 
43
33
  if (forCommittedFiles) {
44
34
  return Object.assign({}, commonConfig, {
45
- coverageDirectory: _path2.default.resolve(appPath, 'commitCoverage'),
46
- testResultsProcessor: _path2.default.resolve(__dirname, '..', 'jest', 'commitedFilesResult.js')
35
+ coverageDirectory: _path.default.resolve(appPath, 'commitCoverage'),
36
+ testResultsProcessor: _path.default.resolve(__dirname, '..', 'jest', 'commitedFilesResult.js')
47
37
  });
48
38
  }
49
39
 
@@ -51,8 +41,8 @@ module.exports = function () {
51
41
  rootDir: appPath,
52
42
  testPathIgnorePatterns: ['/node_modules/', 'docs'],
53
43
  unmockedModulePathPatterns: ['__tests__', 'node_modules', '.*'],
54
- roots: ['<rootDir>/' + appFolder + '/'],
44
+ roots: [`<rootDir>/${appFolder}/`],
55
45
  testRegex: '(/__tests__/.*|\\.(test|spec))\\.(jsx|js|json|node)$',
56
- testResultsProcessor: _path2.default.resolve(__dirname, '..', 'jest', 'result.js')
46
+ testResultsProcessor: _path.default.resolve(__dirname, '..', 'jest', 'result.js')
57
47
  });
58
48
  };