@zohodesk/client_build_tool 0.0.5-exp.4 → 0.0.5-exp.5

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 (64) hide show
  1. package/CHANGELOG.md +1 -4
  2. package/README.md +1 -4
  3. package/lib/schemas/defaultConfigValues.js +15 -0
  4. package/lib/schemas/defaultConfigValuesOnly.js +8 -1
  5. package/lib/shared/bundler/webpack/common/modeUtils.js +8 -0
  6. package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +83 -0
  7. package/lib/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +21 -29
  8. package/lib/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +73 -0
  9. package/lib/shared/bundler/webpack/outputConfig.js +4 -3
  10. package/lib/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +11 -11
  11. package/lib/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +31 -0
  12. package/lib/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +31 -0
  13. package/lib/shared/bundler/webpack/plugins.js +5 -1
  14. package/lib/shared/bundler/webpack/splitChunksConfig.js +14 -11
  15. package/lib/shared/bundler/webpack/utils/object-manipulation.js +87 -0
  16. package/lib/shared/commands-utils/doBasicRequirementCheck.js +2 -2
  17. package/lib/shared/server/corsHandling.js +9 -0
  18. package/npm-shrinkwrap.json +2 -2
  19. package/package.json +1 -1
  20. package/coverage/addFilesNamesToManifestJson.js.html +0 -148
  21. package/coverage/base.css +0 -224
  22. package/coverage/block-navigation.js +0 -87
  23. package/coverage/bundler/webpack/custom_plugins/AddManifestJson/addFilesNamesToManifestJson.js.html +0 -148
  24. package/coverage/bundler/webpack/custom_plugins/AddManifestJson/createInitialEntries.js.html +0 -136
  25. package/coverage/bundler/webpack/custom_plugins/AddManifestJson/createManifestJson.js.html +0 -181
  26. package/coverage/bundler/webpack/custom_plugins/AddManifestJson/findInitialFileNames.js.html +0 -133
  27. package/coverage/bundler/webpack/custom_plugins/AddManifestJson/index.html +0 -146
  28. package/coverage/bundler/webpack/custom_plugins/AddManifestJson/index.js.html +0 -199
  29. package/coverage/bundler/webpack/custom_plugins/AddManifestJson/removeHashFromFileName.js.html +0 -127
  30. package/coverage/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js.html +0 -346
  31. package/coverage/bundler/webpack/custom_plugins/VariableConversionCollector/index.html +0 -116
  32. package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/constants.js.html +0 -94
  33. package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js.html +0 -259
  34. package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/index.html +0 -236
  35. package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/index.js.html +0 -442
  36. package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/insertBefore.js.html +0 -154
  37. package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js.html +0 -142
  38. package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js.html +0 -127
  39. package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js.html +0 -139
  40. package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/specialCases.js.html +0 -184
  41. package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js.html +0 -193
  42. package/coverage/bundler/webpack/custom_postcss_plugins/SelectorReplace.js.html +0 -292
  43. package/coverage/bundler/webpack/custom_postcss_plugins/ValueReplacer.js.html +0 -223
  44. package/coverage/bundler/webpack/custom_postcss_plugins/VariableModificationPlugin/index.html +0 -116
  45. package/coverage/bundler/webpack/custom_postcss_plugins/VariableModificationPlugin/index.js.html +0 -1126
  46. package/coverage/bundler/webpack/custom_postcss_plugins/index.html +0 -131
  47. package/coverage/bundler/webpack/loaderConfigs/getSpecificPostCssPlugin.js.html +0 -247
  48. package/coverage/bundler/webpack/loaderConfigs/index.html +0 -116
  49. package/coverage/coverage-final.json +0 -4
  50. package/coverage/coverage-summary.json +0 -5
  51. package/coverage/createInitialEntries.js.html +0 -136
  52. package/coverage/dummy.js.html +0 -238
  53. package/coverage/favicon.png +0 -0
  54. package/coverage/index.html +0 -146
  55. package/coverage/index.js.html +0 -169
  56. package/coverage/isObject.js.html +0 -94
  57. package/coverage/isValid.js.html +0 -106
  58. package/coverage/prettify.css +0 -1
  59. package/coverage/prettify.js +0 -2
  60. package/coverage/removeHashFromFileName.js.html +0 -127
  61. package/coverage/sort-arrow-sprite.png +0 -0
  62. package/coverage/sorter.js +0 -196
  63. package/result.json +0 -1
  64. package/unittest/index.html +0 -35
package/CHANGELOG.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # Changelog and Release Notes
2
2
 
3
- ## v0.0.5-exp.4 (14-09-2023)
4
-
5
- **changes:--**
6
- - changing jsPP,cssPP,i18nPP values in ResourceHintsPlugin
3
+ ## v0.0.5-exp.5
7
4
 
8
5
  ## v0.0.5-exp.3 (11-09-2023)
9
6
 
package/README.md CHANGED
@@ -84,10 +84,7 @@ These commands provide flexibility and control over your client-side build proce
84
84
  For more [Details](ConfigurationDocumentation.md)
85
85
  # Changelog and Release Notes
86
86
 
87
- ## v0.0.5-exp.4 (14-09-2023)
88
-
89
- **changes:--**
90
- - changing jsPP,cssPP,i18nPP values in ResourceHintsPlugin
87
+ ## v0.0.5-exp.5
91
88
 
92
89
  ## v0.0.5-exp.3 (11-09-2023)
93
90
 
@@ -15,6 +15,16 @@ var _default = {
15
15
  },
16
16
  devtool: 'source-map',
17
17
  statsLogConfig: null,
18
+ stats: {
19
+ enable: {
20
+ value: false,
21
+ cli: 'enable_stats',
22
+ type: 'boolean'
23
+ },
24
+ fileName: null,
25
+ options: null,
26
+ excludeKeys: null
27
+ },
18
28
  enableFileNameHashing: {
19
29
  value: false,
20
30
  cli: 'enable_hash'
@@ -210,6 +220,11 @@ var _default = {
210
220
  outputFile: {
211
221
  value: 'efc-sdk-[version].js',
212
222
  cli: 'efc_output'
223
+ },
224
+ resourceCleanup: {
225
+ value: false,
226
+ cli: 'enable_efc_resource_cleanup',
227
+ type: 'boolean'
213
228
  }
214
229
  },
215
230
  createSeparateSMap: {
@@ -119,7 +119,8 @@ var _default = {
119
119
  version: 'v1',
120
120
  createSDkFile: false,
121
121
  templateFilePath: 'efcTemplate.js',
122
- outputFile: 'efc-sdk-[version].js'
122
+ outputFile: 'efc-sdk-[version].js',
123
+ resourceCleanup: false
123
124
  },
124
125
  createSeparateSMap: false,
125
126
  babelCustomizations: {
@@ -175,6 +176,12 @@ var _default = {
175
176
  templateFilePath: 'sw.js',
176
177
  outputFilePath: '/v1.js',
177
178
  replaceText: '//<!--AssetsFromBuild -->'
179
+ },
180
+ stats: {
181
+ enable: false,
182
+ fileName: null,
183
+ options: null,
184
+ excludeKeys: null
178
185
  }
179
186
  };
180
187
  exports.default = _default;
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.getGlobalCacheStorageName = getGlobalCacheStorageName;
6
7
  exports.getWebpackMode = getWebpackMode;
7
8
  exports.isDevelopmentMode = isDevelopmentMode;
8
9
  exports.isNotProduction = isNotProduction;
@@ -23,6 +24,13 @@ function getWebpackMode(options) {
23
24
  return isProductionMode(mode) ? 'production' : 'development';
24
25
  }
25
26
 
27
+ function getGlobalCacheStorageName(options) {
28
+ const {
29
+ context
30
+ } = options;
31
+ return `${context}Jsonp`;
32
+ }
33
+
26
34
  function isNotProduction(options) {
27
35
  const {
28
36
  mode
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BundleIntegrityReport = void 0;
7
+
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+
10
+ var _path = _interopRequireDefault(require("path"));
11
+
12
+ var _stream = require("stream");
13
+
14
+ var _objectManipulation = require("../../utils/object-manipulation");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ const pluginName = 'BundleIntegrityReportPlugin';
19
+
20
+ class BundleIntegrityReport {
21
+ constructor({
22
+ options,
23
+ excludeKeysInReport,
24
+ fileName
25
+ }) {
26
+ this.excludeKeysInStat = excludeKeysInReport;
27
+ this.statsFileName = fileName;
28
+ this.statsOptions = options;
29
+ }
30
+
31
+ apply(compiler) {
32
+ compiler.hooks.done.tapAsync(pluginName, (stats, callback) => {
33
+ const statsJson = (0, _objectManipulation.removeKeysFromObject)(stats.toJson(this.statsOptions), this.excludeKeysInStat);
34
+ this.emitStats(statsJson).on('end', () => {
35
+ callback();
36
+ }).on('error', e => {
37
+ callback(e);
38
+ });
39
+ });
40
+ }
41
+
42
+ writeStatsFileInAStream(statsObj) {
43
+ const {
44
+ outputPath
45
+ } = statsObj;
46
+
47
+ const ouputFileName = _path.default.join(outputPath, this.statsFileName);
48
+
49
+ return this.createReadStream(statsObj).pipe(_fs.default.createWriteStream(ouputFileName));
50
+ }
51
+
52
+ createReadStream(statsObj) {
53
+ const excludeKeys = this.excludeKeysInStat;
54
+ return new _stream.Readable({
55
+ read() {
56
+ let isDone = false;
57
+ const objToStringGen = (0, _objectManipulation.convertObjectToStringGen)(statsObj, excludeKeys);
58
+
59
+ while (!isDone) {
60
+ const {
61
+ done,
62
+ value
63
+ } = objToStringGen.next();
64
+
65
+ if (done) {
66
+ isDone = true;
67
+ this.push(null);
68
+ } else {
69
+ this.push(value);
70
+ }
71
+ }
72
+ }
73
+
74
+ });
75
+ }
76
+
77
+ emitStats(statsJson) {
78
+ return this.writeStatsFileInAStream(statsJson);
79
+ }
80
+
81
+ }
82
+
83
+ exports.BundleIntegrityReport = BundleIntegrityReport;
@@ -51,8 +51,7 @@ class ResourceHintsPlugin {
51
51
  publicPathsTemplateObj
52
52
  } = this;
53
53
  compilation.addRuntimeModule(entryRuntimeChunk, // eslint-disable-next-line no-use-before-define
54
- new ResourceHintsRuntimePlugin(set, {
55
- compiler,
54
+ new ResourceHintsRuntimePlugin(compiler, {
56
55
  chunk: entryRuntimeChunk,
57
56
  allowPrefetchingMultipleChunks: this.allowPrefetchingMultipleChunks,
58
57
  publicPathsTemplateObj
@@ -96,14 +95,12 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
96
95
  }
97
96
  });
98
97
  const {
99
- js: jsPP = _webpack.RuntimeGlobals.publicPath,
100
- css: cssPP = _webpack.RuntimeGlobals.publicPath,
101
- i18n: i18nPP = _webpack.RuntimeGlobals.publicPath
98
+ js: jsPP,
99
+ css: cssPP,
100
+ i18n: i18nPP
102
101
  } = this.publicPathsTemplateObj;
103
- return _webpack.Template.asString([`
104
- const preloadedChunks = {};
105
- const nameToChunkIdMap = ${JSON.stringify(needsMap ? nameIdMap : {})};
106
- const chunkNames = Object.keys(nameToChunkIdMap);
102
+ return _webpack.Template.asString([`const nameToChunkIdMap = ${JSON.stringify(needsMap ? nameIdMap : {})};
103
+ const chunkNames = Object.keys(nameToChunkIdMap);
107
104
 
108
105
  function createLinkTag(href, rel) {
109
106
  let link = document.createElement("link");
@@ -123,17 +120,15 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
123
120
  function loadAsPreloadOrPrefetch(_chunkId, rel) {
124
121
  let chunkId = ${_webpack.RuntimeGlobals.require}.getChunkId(_chunkId);
125
122
  // ${_webpack.RuntimeGlobals.require}.e(chunkId);
126
- if(__webpack_require__.O.j(chunkId) || preloadedChunks[chunkId]) {
127
- preloadedChunks[chunkId] = true;
128
- // console.log("skipped loadAsPreloadOrPrefetch", _chunkId, chunkId, rel);
123
+ if(__webpack_require__.O.j(chunkId)) {
129
124
  return;
130
125
  }
131
- const jsUrl = ${jsPP} + __webpack_require__.u(chunkId);
132
- const cssUrl = ${cssPP} + __webpack_require__.miniCssF(chunkId);
126
+ const jsUrl = ${jsPP || _webpack.RuntimeGlobals.publicPath} + __webpack_require__.u(chunkId);
127
+ const cssUrl = ${cssPP || _webpack.RuntimeGlobals.publicPath} + __webpack_require__.miniCssF(chunkId);
133
128
  isValidUrl(jsUrl) && createLinkTag(jsUrl, rel);
134
129
  isValidUrl(cssUrl) && createLinkTag(cssUrl, rel);
135
130
  if(__webpack_require__.miniI18nF) {
136
- const i18nUrl = ${i18nPP} + __webpack_require__.miniI18nF(chunkId);
131
+ const i18nUrl = ${i18nPP || _webpack.RuntimeGlobals.publicPath} + __webpack_require__.miniI18nF(chunkId);
137
132
  isValidUrl(i18nUrl) && createLinkTag(i18nUrl, rel);
138
133
  }
139
134
  }
@@ -148,29 +143,26 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
148
143
  const isRegExAsChunkId = chunkId instanceof RegExp;
149
144
  if(isRegExAsChunkId) {
150
145
  return chunkNames.filter(chunkName => chunkId.test(chunkName)).map(chunkName => nameToChunkIdMap[chunkName]);
151
- }` : ''}
152
- return [${_webpack.RuntimeGlobals.require}.getChunkId(chunkId)];
146
+ }
147
+ return [${_webpack.RuntimeGlobals.require}.getChunkId(chunkId)];
148
+ ` : `return [${_webpack.RuntimeGlobals.require}.getChunkId(chunkId)];`}
153
149
  }
154
150
  // Prefetch a chunk (${pluginName})
155
151
  ${_webpack.RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {
156
- loadAsPreloadOrPrefetch(chunkId, "prefetch");
157
- ${this.allowPrefetchingMultipleChunks ? `
158
- let chunkIds = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId)
152
+ ${`
153
+ let chunkIds = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId);
159
154
  chunkIds.forEach(idOfAChunk => {
160
- // ${_webpack.RuntimeGlobals.require}.e(idOfAChunk);
161
- loadAsPreloadOrPrefetch(idOfAChunk, "prefetch");
162
- })` : 'loadAsPreloadOrPrefetch(chunkId, "prefetch");'}
155
+ ${_webpack.RuntimeGlobals.require}.e(idOfAChunk);
156
+ // loadAsPreloadOrPrefetch(idOfAChunk, "prefetch");
157
+ })`}
163
158
  };
164
159
 
165
160
  // Preload a chunk (${pluginName})
166
161
  ${_webpack.RuntimeGlobals.require}.plc = function preloadChunk(chunkId) {
167
- ${this.allowPrefetchingMultipleChunks ? `
168
- let chunkIds = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId)
169
- chunkIds.forEach(idOfAChunk => {
162
+ let idOfAChunk = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId)[0];
170
163
  // ${_webpack.RuntimeGlobals.require}.e(idOfAChunk);
171
- loadAsPreloadOrPrefetch(idOfAChunk, "preload");
172
- })` : 'loadAsPreloadOrPrefetch(chunkId, "preload");'}
173
- };
164
+ loadAsPreloadOrPrefetch(idOfAChunk, "preload");
165
+ }
174
166
  ` // `// Prefetch a chunk (${pluginName})`,
175
167
  // `${RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {`,
176
168
  // Template.indent([
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _webpack = require("webpack");
9
+
10
+ const pluginName = 'RuntimeResourceCleanupPlugin';
11
+
12
+ class RuntimeResourceCleanup {
13
+ constructor({
14
+ enable: scriptCleanUpEnabled,
15
+ chunkLoadingGlobal,
16
+ ...options
17
+ }) {
18
+ this.options = options;
19
+ this.scriptCleanUpEnabled = scriptCleanUpEnabled;
20
+ this.chunkLoadingGlobal = chunkLoadingGlobal;
21
+ }
22
+
23
+ apply(compiler) {
24
+ compiler.hooks.compilation.tap(pluginName, compilation => {
25
+ compilation.hooks.processAssets.tap({
26
+ name: pluginName,
27
+ stage: _webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
28
+ }, assets => {
29
+ const runtimeFiles = Object.keys(assets).filter(assetName => /.+?runtime.*\.js$/.test(assetName));
30
+ const searchString = 'chunkLoadingGlobal.forEach';
31
+
32
+ function generateScriptCleanUpCode(attributes) {
33
+ const [[attributeKey, attributeValue]] = Object.entries(attributes);
34
+ const selectorForGettingResources = `[${attributeKey}="${attributeValue}"]`;
35
+ return `
36
+ document.querySelectorAll('${selectorForGettingResources}').forEach(resource => resource.remove());
37
+ `;
38
+ }
39
+
40
+ function generateRunTimeObjectCleanupCode() {
41
+ return `
42
+ Object.keys(__webpack_modules__).forEach(moduleKey => __webpack_modules__[moduleKey] = null);
43
+ Object.keys(__webpack_module_cache__).forEach(moduleCacheKey => __webpack_module_cache__[moduleCacheKey] = null);
44
+ __webpack_modules__ = null;
45
+ __webpack_module_cache__ = null;
46
+ Object.keys(__webpack_require__).forEach(staticMethodsKey => __webpack_require__[staticMethodsKey] = null);
47
+ __webpack_require__ = null;
48
+ `;
49
+ }
50
+
51
+ function attachUninstallMethodToChunkGlobal() {
52
+ const {
53
+ chunkLoadingGlobal
54
+ } = this;
55
+ return `self['${chunkLoadingGlobal}'].unInstall = function() {
56
+ ${generateRunTimeObjectCleanupCode()};
57
+ ${this.scriptCleanUpEnabled ? generateScriptCleanUpCode(this.options.attributes) : ''}
58
+ }`;
59
+ }
60
+
61
+ runtimeFiles.forEach(runtTimeFile => {
62
+ const runTimeSource = assets[runtTimeFile].source();
63
+ const newRunTimeCode = runTimeSource.replace(searchString, `${attachUninstallMethodToChunkGlobal.call(this)};${searchString}`);
64
+ const newRunTimeResource = new compiler.webpack.sources.RawSource(newRunTimeCode);
65
+ compilation.updateAsset(runtTimeFile, newRunTimeResource);
66
+ });
67
+ });
68
+ });
69
+ }
70
+
71
+ }
72
+
73
+ exports.default = RuntimeResourceCleanup;
@@ -11,19 +11,20 @@ var _constants = require("../../constants");
11
11
 
12
12
  var _nameTemplates = require("./common/nameTemplates");
13
13
 
14
+ var _modeUtils = require("./common/modeUtils");
15
+
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
 
16
18
  function outputConfig(options) {
17
19
  const {
18
20
  output,
19
21
  publicPath,
20
- htmlTemplate,
21
- context
22
+ htmlTemplate
22
23
  } = options;
23
24
  const outputO = {
24
25
  filename: (0, _nameTemplates.nameTemplates)('js', options),
25
26
  chunkFilename: (0, _nameTemplates.nameTemplates)('chunkjs', options),
26
- chunkLoadingGlobal: `${context}Jsonp`,
27
+ chunkLoadingGlobal: (0, _modeUtils.getGlobalCacheStorageName)(options),
27
28
  publicPath,
28
29
  // clean: true,
29
30
  path: _path.default.resolve(_constants.appPath, output)
@@ -25,16 +25,16 @@ function configBundleAnalyzer(options) {
25
25
  function getBundleAnalyzerOptions(options) {
26
26
  return {
27
27
  analyzerMode: 'static',
28
- generateStatsFile: true,
29
- openAnalyzer: false,
30
- statsOptions: {
31
- source: false,
32
- normal: true,
33
- chunks: false,
34
- chunkGroups: false,
35
- module: false,
36
- assets: true,
37
- assetsSort: 'name'
38
- }
28
+ // generateStatsFile: false,
29
+ openAnalyzer: false // statsOptions: {
30
+ // source: false,
31
+ // normal: true,
32
+ // chunks: false,
33
+ // chunkGroups: false,
34
+ // module: false,
35
+ // assets: true,
36
+ // assetsSort: 'name'
37
+ // }
38
+
39
39
  };
40
40
  }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.configBundleIntegrityReport = configBundleIntegrityReport;
7
+
8
+ var _modeUtils = require("../common/modeUtils");
9
+
10
+ var _BundleIntegrityReport = require("../custom_plugins/BundleIntegrityReport");
11
+
12
+ function configBundleIntegrityReport(options) {
13
+ const webpackMode = (0, _modeUtils.getWebpackMode)(options);
14
+ const isProduction = (0, _modeUtils.isProductionMode)(webpackMode);
15
+ const {
16
+ enable: statsEnable
17
+ } = options.stats;
18
+
19
+ if (isProduction && statsEnable) {
20
+ return new _BundleIntegrityReport.BundleIntegrityReport({
21
+ fileName: options.stats.fileName || 'bundle-report-integrity.json',
22
+ excludeKeysInReport: options.stats.excludeKeys || [],
23
+ options: {
24
+ all: true,
25
+ ...options.stats.options
26
+ }
27
+ });
28
+ }
29
+
30
+ return null;
31
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.configRuntimeResourceCleanup = configRuntimeResourceCleanup;
7
+
8
+ var _modeUtils = require("../common/modeUtils");
9
+
10
+ var _RuntimeResourceCleanup = _interopRequireDefault(require("../custom_plugins/RuntimeResourceCleanup"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function configRuntimeResourceCleanup(options) {
15
+ const chunkLoadingGlobal = (0, _modeUtils.getGlobalCacheStorageName)(options);
16
+ const {
17
+ resourceCleanup: runtimeResourceCleanupEnabled,
18
+ hasEFC: efcEnabled
19
+ } = options.efc;
20
+ const {
21
+ customAttributes = {}
22
+ } = options;
23
+
24
+ if (efcEnabled && runtimeResourceCleanupEnabled) {
25
+ return new _RuntimeResourceCleanup.default({ ...customAttributes,
26
+ chunkLoadingGlobal
27
+ });
28
+ }
29
+
30
+ return null;
31
+ }
@@ -43,10 +43,14 @@ var _configTPHashMappingPlugin = require("./pluginConfigs/configTPHashMappingPlu
43
43
 
44
44
  var _configCustomAttributesPlugin = require("./pluginConfigs/configCustomAttributesPlugin");
45
45
 
46
+ var _configBundleIntegrityReport = require("./pluginConfigs/configBundleIntegrityReport");
47
+
48
+ var _configRuntimeResourceCleanup = require("./pluginConfigs/configRuntimeResourceCleanup");
49
+
46
50
  // import { IgnorePlugin } from 'webpack';
47
51
  function plugins(options) {
48
52
  const {
49
53
  webpackPlugins
50
54
  } = options;
51
- return [(0, _configEnvVariables.configEnvVariables)(options), (0, _configCustomAttributesPlugin.configCustomAttributesPlugin)(options), (0, _configTPHashMappingPlugin.configTPHashMappingPlugin)(options), (0, _configCopyPublicFolders.configCopyPublicFolders)(options), (0, _configIgnorePlugin.configIgnorePlugin)(options), (0, _configMiniCSSExtractPlugin.configMiniCSSExtractPlugin)(options), (0, _configSelectorWeightPlugin.configSelectorWeightPlugin)(options), (0, _configVariableConversionPlugin.configVariableConversionPlugin)(options), (0, _configI18nSplitPlugin.configI18nSplitPlugin)(options), (0, _configRtlCssPlugin.configRtlCssPlugin)(options), (0, _configHtmlWebpackPlugin.configHtmlWebpackPlugin)(options), (0, _configCdnChangePlugin.configCdnChangePlugin)(options), (0, _configServiceWorkerPlugin.configServiceWorkerPlugin)(options), (0, _configEFCTemplatePlugin.configEFCTemplatePlugin)(options), (0, _configResourceHintsPlugin.configResourceHintsPlugin)(options), (0, _configBundleAnalyzer.configBundleAnalyzer)(options), (0, _configManifestJsonPlugin.configManifestJsonPlugin)(options), (0, _configSourceMapPlugin.configSourceMapPlugin)(options), (0, _configProgressPlugin.configProgressPlugin)(options), ...webpackPlugins].filter(Boolean);
55
+ return [(0, _configEnvVariables.configEnvVariables)(options), (0, _configCustomAttributesPlugin.configCustomAttributesPlugin)(options), (0, _configTPHashMappingPlugin.configTPHashMappingPlugin)(options), (0, _configCopyPublicFolders.configCopyPublicFolders)(options), (0, _configIgnorePlugin.configIgnorePlugin)(options), (0, _configMiniCSSExtractPlugin.configMiniCSSExtractPlugin)(options), (0, _configSelectorWeightPlugin.configSelectorWeightPlugin)(options), (0, _configVariableConversionPlugin.configVariableConversionPlugin)(options), (0, _configI18nSplitPlugin.configI18nSplitPlugin)(options), (0, _configRtlCssPlugin.configRtlCssPlugin)(options), (0, _configHtmlWebpackPlugin.configHtmlWebpackPlugin)(options), (0, _configCdnChangePlugin.configCdnChangePlugin)(options), (0, _configServiceWorkerPlugin.configServiceWorkerPlugin)(options), (0, _configEFCTemplatePlugin.configEFCTemplatePlugin)(options), (0, _configResourceHintsPlugin.configResourceHintsPlugin)(options), (0, _configBundleAnalyzer.configBundleAnalyzer)(options), (0, _configManifestJsonPlugin.configManifestJsonPlugin)(options), (0, _configSourceMapPlugin.configSourceMapPlugin)(options), (0, _configProgressPlugin.configProgressPlugin)(options), (0, _configBundleIntegrityReport.configBundleIntegrityReport)(options), (0, _configRuntimeResourceCleanup.configRuntimeResourceCleanup)(options), ...webpackPlugins].filter(Boolean);
52
56
  }
@@ -36,17 +36,14 @@ function splitChunksConfig(options) {
36
36
  minChunks: 1,
37
37
  test: isReact,
38
38
  enforce: true,
39
- // priority: 10
40
- priority: 0
39
+ priority: 30
41
40
  },
42
41
  vendor: {
43
42
  name: 'vendor',
44
43
  chunks: 'all',
45
- // chunks: 'initial',
46
44
  minChunks: 1,
47
45
  test: isVendor,
48
- // priority: 19,
49
- priority: 0
46
+ priority: 20
50
47
  }
51
48
  };
52
49
  const customChunksConfig = {};
@@ -56,16 +53,17 @@ function splitChunksConfig(options) {
56
53
  const obj = getCacheGroup(cacheGroupObj, index);
57
54
  customChunksConfig[cacheGroupName] = obj;
58
55
  });
59
- return {
56
+ const splitChunksConfig = {
60
57
  minSize: 12000,
61
58
  ...(customChunksBaseConfig || {}),
62
59
  cacheGroups: {
63
60
  default: false,
64
- vendors: false,
61
+ defaultVendors: false,
65
62
  ...defaultChunks,
66
63
  ...customChunksConfig
67
64
  }
68
65
  };
66
+ return splitChunksConfig;
69
67
  }
70
68
 
71
69
  function getCacheGroup(obj, index) {
@@ -75,16 +73,17 @@ function getCacheGroup(obj, index) {
75
73
  chunks = 'all'
76
74
  } = obj;
77
75
  const {
76
+ name,
78
77
  patterns,
79
78
  enforce,
80
79
  minSize,
81
80
  maxSize,
82
81
  reuseExistingChunk,
83
- name
82
+ automaticNameDelimiter
84
83
  } = obj;
84
+ chunks = obj.chunks || 'all';
85
85
  minChunks = obj.minChunks || 2;
86
86
  priority = obj.priority || 10 * (index + 2);
87
- chunks = obj.chunks || 'all';
88
87
  const cacheGroup = {
89
88
  name,
90
89
  test: m => {
@@ -92,9 +91,9 @@ function getCacheGroup(obj, index) {
92
91
  return userRequest && (0, _checkIsPatternsMatchFilename.checkIsPatternsMatchFilename)(patterns, userRequest);
93
92
  },
94
93
  chunks,
95
- enforce,
96
94
  minChunks,
97
- priority
95
+ priority,
96
+ enforce
98
97
  };
99
98
 
100
99
  if (minSize !== undefined) {
@@ -109,5 +108,9 @@ function getCacheGroup(obj, index) {
109
108
  cacheGroup.reuseExistingChunk = reuseExistingChunk;
110
109
  }
111
110
 
111
+ if (automaticNameDelimiter !== undefined) {
112
+ cacheGroup.automaticNameDelimiter = automaticNameDelimiter;
113
+ }
114
+
112
115
  return cacheGroup;
113
116
  }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertObjectToStringGen = convertObjectToStringGen;
7
+ exports.removeKeysFromObject = removeKeysFromObject;
8
+
9
+ /* eslint-disable no-restricted-syntax */
10
+ function objectPathMatcher(currentKey, objHierarchy = [], keysToBeRemoved = []) {
11
+ const objPathKey = objHierarchy.length > 0 ? `${objHierarchy.join('.')}.${currentKey}` : currentKey;
12
+ return keysToBeRemoved.some(key => {
13
+ const isWildPath = /^\*/.test(key);
14
+
15
+ if (isWildPath) {
16
+ const newKey = key.replace(/\*\.?/, '');
17
+ return objPathKey.includes(newKey);
18
+ }
19
+
20
+ return key === objPathKey;
21
+ });
22
+ }
23
+ /*
24
+ 1) *.keyTobeRemoved -> means match every object path, this key will be removed
25
+ 2) keyToBeremoved -> means root object key
26
+ 3) nestedPath.keyToBeRemoved -> means only that nested path key
27
+ 4) don't need to account for array iteration, just object key path is enough in the key to be removed.
28
+ */
29
+
30
+
31
+ function removeKeysFromObject(obj, keysToBeRemoved, prevKeys = []) {
32
+ if (Array.isArray(obj)) {
33
+ return obj.map(item => removeKeysFromObject(item, keysToBeRemoved, prevKeys));
34
+ }
35
+
36
+ if (obj && typeof obj === 'object') {
37
+ const filteredKeyObject = {};
38
+ const ObjectKeys = Object.keys(obj);
39
+
40
+ for (const objectKey of ObjectKeys) {
41
+ const isKeyToBeRemoved = objectPathMatcher(objectKey, prevKeys, keysToBeRemoved);
42
+
43
+ if (!isKeyToBeRemoved) {
44
+ filteredKeyObject[objectKey] = removeKeysFromObject(obj[objectKey], keysToBeRemoved, [...prevKeys, objectKey]);
45
+ }
46
+ }
47
+
48
+ return filteredKeyObject;
49
+ }
50
+
51
+ return obj;
52
+ }
53
+
54
+ function* convertObjectToStringGen(obj) {
55
+ if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || obj === null) {
56
+ yield JSON.stringify(obj);
57
+ } else if (Array.isArray(obj)) {
58
+ yield '[';
59
+ let isFirst = true;
60
+
61
+ for (let item of obj) {
62
+ if (item === undefined) {
63
+ item = null;
64
+ }
65
+
66
+ yield `${isFirst ? '' : ','}`;
67
+ yield* convertObjectToStringGen(item);
68
+ isFirst = false;
69
+ }
70
+
71
+ yield ']';
72
+ } else {
73
+ yield '{';
74
+ let isFirst = true;
75
+ const entries = Object.entries(obj);
76
+
77
+ for (const [itemKey, itemValue] of entries) {
78
+ if (itemValue !== undefined) {
79
+ yield `${isFirst ? '' : ','}${JSON.stringify(itemKey)}: `;
80
+ yield* convertObjectToStringGen(itemValue);
81
+ isFirst = false;
82
+ }
83
+ }
84
+
85
+ yield '}';
86
+ }
87
+ }
@@ -9,9 +9,9 @@ exports.doBasicRequirementCheck = doBasicRequirementCheck;
9
9
  function doBasicRequirementCheck() {
10
10
  const majorV = Number(process.version.slice(1, 4));
11
11
 
12
- if (majorV >= 12 && majorV <= 18) {
12
+ if (majorV >= 14 && majorV <= 18) {
13
13
  return true;
14
14
  }
15
15
 
16
- throw `your node version not compatible with this cli please update node version to 12 - 18, and your current version is ${process.version}`;
16
+ throw `your node version not compatible with this cli please update node version to 14 - 18, and your current version is ${process.version}`;
17
17
  }