@studyportals/webpack-helper 6.0.7-20 → 6.0.7-22
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studyportals/webpack-helper",
|
|
3
|
-
"version": "6.0.7-
|
|
3
|
+
"version": "6.0.7-22",
|
|
4
4
|
"description": "A collection of standard configurations and helpers for webpack.",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
33
33
|
"mini-css-extract-plugin": "^2.8.0",
|
|
34
34
|
"path": "^0.12.7",
|
|
35
|
+
"prettier": "^3.4.2",
|
|
35
36
|
"sass": "^1.71.1",
|
|
36
37
|
"sass-loader": "^14.1.1",
|
|
37
38
|
"terser-webpack-plugin": "^5.3.10",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RetryChunkLoadPlugin = void 0;
|
|
4
|
-
const
|
|
4
|
+
const prettier = require('prettier');
|
|
5
|
+
const { RuntimeGlobals } = require('webpack');
|
|
5
6
|
const pluginName = 'RetryChunkLoadPlugin';
|
|
6
7
|
class RetryChunkLoadPlugin {
|
|
7
8
|
constructor(options = {}) {
|
|
@@ -30,17 +31,17 @@ class RetryChunkLoadPlugin {
|
|
|
30
31
|
if (!addRetryCode)
|
|
31
32
|
return source;
|
|
32
33
|
const script = runtimeTemplate.iife('', `
|
|
33
|
-
if(typeof ${
|
|
34
|
-
var oldGetScript = ${
|
|
35
|
-
var oldLoadScript = ${
|
|
34
|
+
if(typeof ${RuntimeGlobals.require} !== "undefined") {
|
|
35
|
+
var oldGetScript = ${RuntimeGlobals.getChunkScriptFilename};
|
|
36
|
+
var oldLoadScript = ${RuntimeGlobals.ensureChunk};
|
|
36
37
|
var queryMap = {};
|
|
37
38
|
var countMap = {};
|
|
38
39
|
var getRetryDelay = ${getRetryDelay}
|
|
39
|
-
${
|
|
40
|
+
${RuntimeGlobals.getChunkScriptFilename} = function(chunkId){
|
|
40
41
|
var result = oldGetScript(chunkId);
|
|
41
42
|
return result + (queryMap.hasOwnProperty(chunkId) ? '?' + queryMap[chunkId] : '');
|
|
42
43
|
};
|
|
43
|
-
${
|
|
44
|
+
${RuntimeGlobals.ensureChunk} = function(chunkId){
|
|
44
45
|
var result = oldLoadScript(chunkId);
|
|
45
46
|
return result.catch(function(error){
|
|
46
47
|
var retries = countMap.hasOwnProperty(chunkId) ? countMap[chunkId] : ${maxRetries};
|
|
@@ -59,13 +60,20 @@ class RetryChunkLoadPlugin {
|
|
|
59
60
|
var cacheBust = ${getCacheBustString()} + retryAttemptString;
|
|
60
61
|
queryMap[chunkId] = cacheBust;
|
|
61
62
|
countMap[chunkId] = retries - 1;
|
|
62
|
-
resolve(${
|
|
63
|
+
resolve(${RuntimeGlobals.ensureChunk}(chunkId));
|
|
63
64
|
}, getRetryDelay(retryAttempt))
|
|
64
65
|
})
|
|
65
66
|
});
|
|
66
67
|
};
|
|
67
68
|
}`);
|
|
68
|
-
return
|
|
69
|
+
return (source +
|
|
70
|
+
prettier.format(script, {
|
|
71
|
+
singleQuote: true,
|
|
72
|
+
parser: 'babel',
|
|
73
|
+
bracketSpacing: true,
|
|
74
|
+
trailingComma: 'all',
|
|
75
|
+
arrowParens: 'avoid',
|
|
76
|
+
}));
|
|
69
77
|
});
|
|
70
78
|
});
|
|
71
79
|
}
|