@zohodesk/client_build_tool 0.0.5-exp.4 → 0.0.5-exp.6
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.
- package/CHANGELOG.md +1 -4
- package/README.md +1 -4
- package/lib/commands/start/optionsProcessor.js +1 -1
- package/lib/schemas/defaultConfigValues.js +15 -0
- package/lib/schemas/defaultConfigValuesOnly.js +8 -1
- package/lib/shared/bundler/webpack/common/modeUtils.js +8 -0
- package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +83 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +39 -38
- package/lib/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +73 -0
- package/lib/shared/bundler/webpack/outputConfig.js +4 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +11 -11
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +31 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +31 -0
- package/lib/shared/bundler/webpack/plugins.js +5 -1
- package/lib/shared/bundler/webpack/splitChunksConfig.js +14 -11
- package/lib/shared/bundler/webpack/utils/object-manipulation.js +87 -0
- package/lib/shared/commands-utils/doBasicRequirementCheck.js +2 -2
- package/lib/shared/server/corsHandling.js +9 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/coverage/addFilesNamesToManifestJson.js.html +0 -148
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/addFilesNamesToManifestJson.js.html +0 -148
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/createInitialEntries.js.html +0 -136
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/createManifestJson.js.html +0 -181
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/findInitialFileNames.js.html +0 -133
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/index.html +0 -146
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/index.js.html +0 -199
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/removeHashFromFileName.js.html +0 -127
- package/coverage/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js.html +0 -346
- package/coverage/bundler/webpack/custom_plugins/VariableConversionCollector/index.html +0 -116
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/constants.js.html +0 -94
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js.html +0 -259
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/index.html +0 -236
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/index.js.html +0 -442
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/insertBefore.js.html +0 -154
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js.html +0 -142
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js.html +0 -127
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js.html +0 -139
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/specialCases.js.html +0 -184
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js.html +0 -193
- package/coverage/bundler/webpack/custom_postcss_plugins/SelectorReplace.js.html +0 -292
- package/coverage/bundler/webpack/custom_postcss_plugins/ValueReplacer.js.html +0 -223
- package/coverage/bundler/webpack/custom_postcss_plugins/VariableModificationPlugin/index.html +0 -116
- package/coverage/bundler/webpack/custom_postcss_plugins/VariableModificationPlugin/index.js.html +0 -1126
- package/coverage/bundler/webpack/custom_postcss_plugins/index.html +0 -131
- package/coverage/bundler/webpack/loaderConfigs/getSpecificPostCssPlugin.js.html +0 -247
- package/coverage/bundler/webpack/loaderConfigs/index.html +0 -116
- package/coverage/coverage-final.json +0 -4
- package/coverage/coverage-summary.json +0 -5
- package/coverage/createInitialEntries.js.html +0 -136
- package/coverage/dummy.js.html +0 -238
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -146
- package/coverage/index.js.html +0 -169
- package/coverage/isObject.js.html +0 -94
- package/coverage/isValid.js.html +0 -106
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/removeHashFromFileName.js.html +0 -127
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/result.json +0 -1
- package/unittest/index.html +0 -35
package/CHANGELOG.md
CHANGED
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.
|
|
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
|
|
|
@@ -16,7 +16,7 @@ function optionsProcessor(options) {
|
|
|
16
16
|
noPublicPath
|
|
17
17
|
} = options;
|
|
18
18
|
const serverExtras = (0, _decidePublicPath.modifiedServerOptions)(options);
|
|
19
|
-
const publicPath = noPublicPath ?
|
|
19
|
+
const publicPath = noPublicPath ? null : (0, _decidePublicPath.decidePublicPath)(serverExtras);
|
|
20
20
|
const contextFolderPath = (0, _constants.joinWithAppPath)(context);
|
|
21
21
|
const defaultAppliedOptions = { ...options,
|
|
22
22
|
// eslint-disable-next-line no-nested-ternary
|
|
@@ -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;
|
|
@@ -136,6 +136,7 @@ class I18nFilesEmitPlugin {
|
|
|
136
136
|
const fileName = fileNameTemplate.replaceAll('[locale]', locale);
|
|
137
137
|
const filename = (0, _pathCreator.pathCreator)(fileName, compilation, {
|
|
138
138
|
hash: compilation.hash,
|
|
139
|
+
chunkName: chunk.name,
|
|
139
140
|
chunkId: chunk.id,
|
|
140
141
|
chunkHash: chunk.hash,
|
|
141
142
|
contentHash
|
|
@@ -45,14 +45,13 @@ class ResourceHintsPlugin {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
enabledChunks.add(entryRuntimeChunk);
|
|
48
|
-
set.add(_webpack.RuntimeGlobals.getFullHash);
|
|
49
|
-
|
|
48
|
+
set.add(_webpack.RuntimeGlobals.getFullHash); // set.add(RuntimeGlobals.getChunkCssFilename);
|
|
49
|
+
|
|
50
50
|
const {
|
|
51
51
|
publicPathsTemplateObj
|
|
52
52
|
} = this;
|
|
53
53
|
compilation.addRuntimeModule(entryRuntimeChunk, // eslint-disable-next-line no-use-before-define
|
|
54
|
-
new ResourceHintsRuntimePlugin(
|
|
55
|
-
compiler,
|
|
54
|
+
new ResourceHintsRuntimePlugin(compiler, {
|
|
56
55
|
chunk: entryRuntimeChunk,
|
|
57
56
|
allowPrefetchingMultipleChunks: this.allowPrefetchingMultipleChunks,
|
|
58
57
|
publicPathsTemplateObj
|
|
@@ -95,17 +94,26 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
95
94
|
needsMap = true;
|
|
96
95
|
}
|
|
97
96
|
});
|
|
98
|
-
|
|
99
|
-
js: jsPP
|
|
100
|
-
css: cssPP
|
|
101
|
-
i18n: i18nPP
|
|
97
|
+
let {
|
|
98
|
+
js: jsPP,
|
|
99
|
+
css: cssPP,
|
|
100
|
+
i18n: i18nPP
|
|
102
101
|
} = this.publicPathsTemplateObj;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
jsPP = jsPP || _webpack.RuntimeGlobals.publicPath;
|
|
103
|
+
cssPP = cssPP || _webpack.RuntimeGlobals.publicPath;
|
|
104
|
+
i18nPP = i18nPP || _webpack.RuntimeGlobals.publicPath;
|
|
105
|
+
/**
|
|
106
|
+
* naming abbr
|
|
107
|
+
* ntc -> nameToChunkIdMap
|
|
108
|
+
* cns -> chunkNames
|
|
109
|
+
* clt -> createLinkTag
|
|
110
|
+
* lpp -> loadAsPreloadOrPrefetch
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
return _webpack.Template.asString([`const ntc = ${JSON.stringify(needsMap ? nameIdMap : {})};
|
|
114
|
+
const cns = Object.keys(ntc);
|
|
115
|
+
|
|
116
|
+
function clt(href, rel) {
|
|
109
117
|
let link = document.createElement("link");
|
|
110
118
|
link.href = href;
|
|
111
119
|
link.rel = rel;
|
|
@@ -120,26 +128,24 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
120
128
|
//return !url.includes(".undefined.");
|
|
121
129
|
return url.indexOf(".undefined.") === -1;
|
|
122
130
|
}
|
|
123
|
-
function
|
|
131
|
+
function lpp(_chunkId, rel) {
|
|
124
132
|
let chunkId = ${_webpack.RuntimeGlobals.require}.getChunkId(_chunkId);
|
|
125
133
|
// ${_webpack.RuntimeGlobals.require}.e(chunkId);
|
|
126
|
-
if(__webpack_require__.O.j(chunkId)
|
|
127
|
-
preloadedChunks[chunkId] = true;
|
|
128
|
-
// console.log("skipped loadAsPreloadOrPrefetch", _chunkId, chunkId, rel);
|
|
134
|
+
if(__webpack_require__.O.j(chunkId)) {
|
|
129
135
|
return;
|
|
130
136
|
}
|
|
131
137
|
const jsUrl = ${jsPP} + __webpack_require__.u(chunkId);
|
|
132
138
|
const cssUrl = ${cssPP} + __webpack_require__.miniCssF(chunkId);
|
|
133
|
-
isValidUrl(jsUrl) &&
|
|
134
|
-
isValidUrl(cssUrl) &&
|
|
139
|
+
isValidUrl(jsUrl) && clt(jsUrl, rel);
|
|
140
|
+
isValidUrl(cssUrl) && clt(cssUrl, rel);
|
|
135
141
|
if(__webpack_require__.miniI18nF) {
|
|
136
142
|
const i18nUrl = ${i18nPP} + __webpack_require__.miniI18nF(chunkId);
|
|
137
|
-
isValidUrl(i18nUrl) &&
|
|
143
|
+
isValidUrl(i18nUrl) && clt(i18nUrl, rel);
|
|
138
144
|
}
|
|
139
145
|
}
|
|
140
146
|
|
|
141
147
|
${_webpack.RuntimeGlobals.require}.getChunkId = function getChunkId(chunkId) {
|
|
142
|
-
${needsMap ? 'chunkId =
|
|
148
|
+
${needsMap ? 'chunkId = ntc[chunkId]||chunkId;' : ''}
|
|
143
149
|
return chunkId;
|
|
144
150
|
}
|
|
145
151
|
${_webpack.RuntimeGlobals.require}.getChunkIds = function getChunkIds(chunkId) {
|
|
@@ -147,30 +153,25 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
147
153
|
this.allowPrefetchingMultipleChunks ? `
|
|
148
154
|
const isRegExAsChunkId = chunkId instanceof RegExp;
|
|
149
155
|
if(isRegExAsChunkId) {
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
|
|
156
|
+
return cns.filter(chunkName => chunkId.test(chunkName)).map(chunkName => ntc[chunkName]);
|
|
157
|
+
}
|
|
158
|
+
return [${_webpack.RuntimeGlobals.require}.getChunkId(chunkId)];
|
|
159
|
+
` : `return [${_webpack.RuntimeGlobals.require}.getChunkId(chunkId)];`}
|
|
153
160
|
}
|
|
154
161
|
// Prefetch a chunk (${pluginName})
|
|
155
162
|
${_webpack.RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
let chunkIds = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId)
|
|
163
|
+
${`
|
|
164
|
+
let chunkIds = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId);
|
|
159
165
|
chunkIds.forEach(idOfAChunk => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
})` : 'loadAsPreloadOrPrefetch(chunkId, "prefetch");'}
|
|
166
|
+
${_webpack.RuntimeGlobals.require}.e(idOfAChunk);
|
|
167
|
+
})`}
|
|
163
168
|
};
|
|
164
169
|
|
|
165
170
|
// Preload a chunk (${pluginName})
|
|
166
171
|
${_webpack.RuntimeGlobals.require}.plc = function preloadChunk(chunkId) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
// ${_webpack.RuntimeGlobals.require}.e(idOfAChunk);
|
|
171
|
-
loadAsPreloadOrPrefetch(idOfAChunk, "preload");
|
|
172
|
-
})` : 'loadAsPreloadOrPrefetch(chunkId, "preload");'}
|
|
173
|
-
};
|
|
172
|
+
let idOfAChunk = ${_webpack.RuntimeGlobals.require}.getChunkIds(chunkId)[0];
|
|
173
|
+
lpp(idOfAChunk, "preload");
|
|
174
|
+
}
|
|
174
175
|
` // `// Prefetch a chunk (${pluginName})`,
|
|
175
176
|
// `${RuntimeGlobals.require}.pfc = function prefetchChunk(chunkId) {`,
|
|
176
177
|
// 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:
|
|
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:
|
|
29
|
-
openAnalyzer: false
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
56
|
+
const splitChunksConfig = {
|
|
60
57
|
minSize: 12000,
|
|
61
58
|
...(customChunksBaseConfig || {}),
|
|
62
59
|
cacheGroups: {
|
|
63
60
|
default: false,
|
|
64
|
-
|
|
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
|
-
|
|
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
|
}
|