@studyportals/webpack-helper 5.3.1-beta → 5.3.2-0

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.
@@ -1,45 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Output = void 0;
4
- class Output {
5
- constructor(outputConfig) {
6
- this.path = outputConfig.path;
7
- this.publicPath = typeof outputConfig.publicPath === "string" ? outputConfig.publicPath : null;
8
- this.library = outputConfig.library || null;
9
- this.addHash = this.shouldAddHash(outputConfig.hash),
10
- this.fileName = outputConfig.fileName || "[name]";
11
- this.crossOriginLoading = outputConfig.crossOriginLoading || null;
12
- }
13
- getOutput() {
14
- let output = {
15
- path: this.path,
16
- filename: this.getFileName()
17
- };
18
- if (this.publicPath !== null) {
19
- output.publicPath = this.publicPath;
20
- }
21
- if (this.library !== null) {
22
- output.library = this.library;
23
- }
24
- if (this.crossOriginLoading !== null) {
25
- output.crossOriginLoading = this.crossOriginLoading;
26
- }
27
- return output;
28
- }
29
- getFileName() {
30
- let fileName = this.addHash === true ? `${this.fileName}.[fullhash].js` : `${this.fileName}.js`;
31
- return fileName;
32
- }
33
- shouldAddHash(hashConfig) {
34
- if (typeof hashConfig === 'undefined') {
35
- return true;
36
- }
37
- if (typeof hashConfig.js !== 'undefined'
38
- && hashConfig.js === false
39
- || hashConfig === false) {
40
- return false;
41
- }
42
- return true;
43
- }
44
- }
45
- exports.Output = Output;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Output = void 0;
4
+ class Output {
5
+ constructor(outputConfig) {
6
+ this.path = outputConfig.path;
7
+ this.publicPath = typeof outputConfig.publicPath === "string" ? outputConfig.publicPath : null;
8
+ this.library = outputConfig.library || null;
9
+ this.addHash = this.shouldAddHash(outputConfig.hash),
10
+ this.fileName = outputConfig.fileName || "[name]";
11
+ this.crossOriginLoading = outputConfig.crossOriginLoading || null;
12
+ }
13
+ getOutput() {
14
+ let output = {
15
+ path: this.path,
16
+ filename: this.getFileName()
17
+ };
18
+ if (this.publicPath !== null) {
19
+ output.publicPath = this.publicPath;
20
+ }
21
+ if (this.library !== null) {
22
+ output.library = this.library;
23
+ }
24
+ if (this.crossOriginLoading !== null) {
25
+ output.crossOriginLoading = this.crossOriginLoading;
26
+ }
27
+ return output;
28
+ }
29
+ getFileName() {
30
+ let fileName = this.addHash === true ? `${this.fileName}.[fullhash].js` : `${this.fileName}.js`;
31
+ return fileName;
32
+ }
33
+ shouldAddHash(hashConfig) {
34
+ if (typeof hashConfig === 'undefined') {
35
+ return true;
36
+ }
37
+ if (typeof hashConfig.js !== 'undefined'
38
+ && hashConfig.js === false
39
+ || hashConfig === false) {
40
+ return false;
41
+ }
42
+ return true;
43
+ }
44
+ }
45
+ exports.Output = Output;
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Plugins = void 0;
4
- class Plugins {
5
- constructor(plugins = []) {
6
- this.plugins = [];
7
- this.plugins = this.plugins.concat(plugins);
8
- }
9
- addPlugin(plugin) {
10
- this.plugins.push(plugin);
11
- }
12
- getPlugins() {
13
- return this.plugins;
14
- }
15
- }
16
- exports.Plugins = Plugins;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Plugins = void 0;
4
+ class Plugins {
5
+ constructor(plugins = []) {
6
+ this.plugins = [];
7
+ this.plugins = this.plugins.concat(plugins);
8
+ }
9
+ addPlugin(plugin) {
10
+ this.plugins.push(plugin);
11
+ }
12
+ getPlugins() {
13
+ return this.plugins;
14
+ }
15
+ }
16
+ exports.Plugins = Plugins;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RetryChunkLoadPlugin = void 0;
4
+ const prettier = require('prettier');
5
+ const { RuntimeGlobals } = require('webpack');
6
+ const pluginName = 'RetryChunkLoadPlugin';
7
+ class RetryChunkLoadPlugin {
8
+ constructor(options = {}) {
9
+ this.options = Object.assign({}, options);
10
+ }
11
+ apply(compiler) {
12
+ compiler.hooks.thisCompilation.tap(pluginName, compilation => {
13
+ const { mainTemplate, runtimeTemplate } = compilation;
14
+ const maxRetryValueFromOptions = Number(this.options.maxRetries);
15
+ const maxRetries = Number.isInteger(maxRetryValueFromOptions) &&
16
+ maxRetryValueFromOptions > 0
17
+ ? maxRetryValueFromOptions
18
+ : 1;
19
+ const getCacheBustString = () => this.options.cacheBust
20
+ ? `
21
+ (${this.options.cacheBust})();
22
+ `
23
+ : '"cache-bust=true"';
24
+ mainTemplate.hooks.localVars.tap({ name: pluginName, stage: 1 }, (source, chunk) => {
25
+ const currentChunkName = chunk.name;
26
+ const addRetryCode = !this.options.chunks ||
27
+ this.options.chunks.some(chunk => chunk === currentChunkName);
28
+ const getRetryDelay = typeof this.options.retryDelay === 'string'
29
+ ? this.options.retryDelay
30
+ : `function() { return ${this.options.retryDelay || 0} }`;
31
+ if (!addRetryCode)
32
+ return source;
33
+ const script = runtimeTemplate.iife('', `
34
+ if(typeof ${RuntimeGlobals.require} !== "undefined") {
35
+ var oldGetScript = ${RuntimeGlobals.getChunkScriptFilename};
36
+ var oldLoadScript = ${RuntimeGlobals.ensureChunk};
37
+ var queryMap = {};
38
+ var countMap = {};
39
+ var getRetryDelay = ${getRetryDelay}
40
+ ${RuntimeGlobals.getChunkScriptFilename} = function(chunkId){
41
+ var result = oldGetScript(chunkId);
42
+ return result + (queryMap.hasOwnProperty(chunkId) ? '?' + queryMap[chunkId] : '');
43
+ };
44
+ ${RuntimeGlobals.ensureChunk} = function(chunkId){
45
+ var result = oldLoadScript(chunkId);
46
+ return result.catch(function(error){
47
+ var retries = countMap.hasOwnProperty(chunkId) ? countMap[chunkId] : ${maxRetries};
48
+ if (retries < 1) {
49
+ var realSrc = oldGetScript(chunkId);
50
+ error.message = 'Loading chunk ' + chunkId + ' failed after ${maxRetries} retries.\\n(' + realSrc + ')';
51
+ error.request = realSrc;${this.options.lastResortScript
52
+ ? this.options.lastResortScript
53
+ : ''}
54
+ throw error;
55
+ }
56
+ return new Promise(function (resolve) {
57
+ var retryAttempt = ${maxRetries} - retries + 1;
58
+ setTimeout(function () {
59
+ var retryAttemptString = '&retry-attempt=' + retryAttempt;
60
+ var cacheBust = ${getCacheBustString()} + retryAttemptString;
61
+ queryMap[chunkId] = cacheBust;
62
+ countMap[chunkId] = retries - 1;
63
+ resolve(${RuntimeGlobals.ensureChunk}(chunkId));
64
+ }, getRetryDelay(retryAttempt))
65
+ })
66
+ });
67
+ };
68
+ }`);
69
+ return (source +
70
+ prettier.format(script, {
71
+ singleQuote: true,
72
+ parser: 'babel',
73
+ bracketSpacing: true,
74
+ trailingComma: 'all',
75
+ arrowParens: 'avoid',
76
+ }));
77
+ });
78
+ });
79
+ }
80
+ }
81
+ exports.RetryChunkLoadPlugin = RetryChunkLoadPlugin;
@@ -1,47 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JavascriptPreset = void 0;
4
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5
- class JavascriptPreset {
6
- getPlugins(filename) {
7
- return [
8
- new MiniCssExtractPlugin({
9
- filename
10
- })
11
- ];
12
- }
13
- getModule() {
14
- return {
15
- rules: [
16
- {
17
- test: /\.css$/,
18
- use: [
19
- MiniCssExtractPlugin.loader,
20
- 'css-loader'
21
- ],
22
- },
23
- {
24
- test: /\.scss$/,
25
- use: [
26
- MiniCssExtractPlugin.loader,
27
- 'css-loader',
28
- 'sass-loader'
29
- ],
30
- },
31
- {
32
- test: /\.jsx?$/,
33
- loader: 'babel-loader',
34
- exclude: /node_modules\/(?!@studyportals\/).*/,
35
- }
36
- ]
37
- };
38
- }
39
- getExtensions() {
40
- return [
41
- '*',
42
- '.js',
43
- '.json'
44
- ];
45
- }
46
- }
47
- exports.JavascriptPreset = JavascriptPreset;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JavascriptPreset = void 0;
4
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5
+ class JavascriptPreset {
6
+ getPlugins(filename) {
7
+ return [
8
+ new MiniCssExtractPlugin({
9
+ filename
10
+ })
11
+ ];
12
+ }
13
+ getModule() {
14
+ return {
15
+ rules: [
16
+ {
17
+ test: /\.css$/,
18
+ use: [
19
+ MiniCssExtractPlugin.loader,
20
+ 'css-loader'
21
+ ],
22
+ },
23
+ {
24
+ test: /\.scss$/,
25
+ use: [
26
+ MiniCssExtractPlugin.loader,
27
+ 'css-loader',
28
+ 'sass-loader'
29
+ ],
30
+ },
31
+ {
32
+ test: /\.jsx?$/,
33
+ loader: 'babel-loader',
34
+ exclude: /node_modules\/(?!@studyportals\/).*/,
35
+ }
36
+ ]
37
+ };
38
+ }
39
+ getExtensions() {
40
+ return [
41
+ '*',
42
+ '.js',
43
+ '.json'
44
+ ];
45
+ }
46
+ }
47
+ exports.JavascriptPreset = JavascriptPreset;
@@ -1,74 +1,74 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeScriptPreset = void 0;
4
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5
- class TypeScriptPreset {
6
- getPlugins(filename) {
7
- return [
8
- new MiniCssExtractPlugin({
9
- filename
10
- })
11
- ];
12
- }
13
- getModule() {
14
- return {
15
- rules: [
16
- {
17
- test: /\.css$/,
18
- use: [
19
- MiniCssExtractPlugin.loader,
20
- 'css-loader'
21
- ],
22
- },
23
- {
24
- test: /\.scss$/,
25
- use: [
26
- MiniCssExtractPlugin.loader,
27
- 'css-loader',
28
- 'sass-loader'
29
- ],
30
- },
31
- {
32
- test: /\.tsx?$/,
33
- exclude: /node_modules\/(?!@studyportals\/).*/,
34
- use: [
35
- {
36
- loader: 'babel-loader',
37
- },
38
- {
39
- loader: 'ts-loader'
40
- }
41
- ],
42
- },
43
- {
44
- test: /\.js$/,
45
- exclude: /node_modules\/(?!@studyportals\/).*/,
46
- use: [
47
- {
48
- loader: 'babel-loader',
49
- }
50
- ],
51
- resolve: {
52
- fullySpecified: false
53
- }
54
- },
55
- {
56
- test: /\.(png|jpg|gif|svg)$/,
57
- loader: 'file-loader',
58
- options: {
59
- name: '[name].[ext]?[fullhash]'
60
- }
61
- }
62
- ]
63
- };
64
- }
65
- getExtensions() {
66
- return [
67
- '*',
68
- '.ts',
69
- '.js',
70
- '.json'
71
- ];
72
- }
73
- }
74
- exports.TypeScriptPreset = TypeScriptPreset;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeScriptPreset = void 0;
4
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5
+ class TypeScriptPreset {
6
+ getPlugins(filename) {
7
+ return [
8
+ new MiniCssExtractPlugin({
9
+ filename
10
+ })
11
+ ];
12
+ }
13
+ getModule() {
14
+ return {
15
+ rules: [
16
+ {
17
+ test: /\.css$/,
18
+ use: [
19
+ MiniCssExtractPlugin.loader,
20
+ 'css-loader'
21
+ ],
22
+ },
23
+ {
24
+ test: /\.scss$/,
25
+ use: [
26
+ MiniCssExtractPlugin.loader,
27
+ 'css-loader',
28
+ 'sass-loader'
29
+ ],
30
+ },
31
+ {
32
+ test: /\.tsx?$/,
33
+ exclude: /node_modules\/(?!@studyportals\/).*/,
34
+ use: [
35
+ {
36
+ loader: 'babel-loader',
37
+ },
38
+ {
39
+ loader: 'ts-loader'
40
+ }
41
+ ],
42
+ },
43
+ {
44
+ test: /\.js$/,
45
+ exclude: /node_modules\/(?!@studyportals\/).*/,
46
+ use: [
47
+ {
48
+ loader: 'babel-loader',
49
+ }
50
+ ],
51
+ resolve: {
52
+ fullySpecified: false
53
+ }
54
+ },
55
+ {
56
+ test: /\.(png|jpg|gif|svg)$/,
57
+ loader: 'file-loader',
58
+ options: {
59
+ name: '[name].[ext]?[fullhash]'
60
+ }
61
+ }
62
+ ]
63
+ };
64
+ }
65
+ getExtensions() {
66
+ return [
67
+ '*',
68
+ '.ts',
69
+ '.js',
70
+ '.json'
71
+ ];
72
+ }
73
+ }
74
+ exports.TypeScriptPreset = TypeScriptPreset;
@@ -1,20 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VueTypescriptNoCodeSplittingPreset = void 0;
4
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5
- const VueLoaderPlugin = require('vue-loader').VueLoaderPlugin;
6
- const vue_typescript_preset_1 = require("./vue-typescript.preset");
7
- class VueTypescriptNoCodeSplittingPreset extends vue_typescript_preset_1.VueTypeScriptPreset {
8
- constructor(mode) {
9
- super(mode);
10
- }
11
- getPlugins(filename) {
12
- return [
13
- new MiniCssExtractPlugin({
14
- filename
15
- }),
16
- new VueLoaderPlugin()
17
- ];
18
- }
19
- }
20
- exports.VueTypescriptNoCodeSplittingPreset = VueTypescriptNoCodeSplittingPreset;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VueTypescriptNoCodeSplittingPreset = void 0;
4
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5
+ const VueLoaderPlugin = require('vue-loader').VueLoaderPlugin;
6
+ const vue_typescript_preset_1 = require("./vue-typescript.preset");
7
+ class VueTypescriptNoCodeSplittingPreset extends vue_typescript_preset_1.VueTypeScriptPreset {
8
+ constructor(mode) {
9
+ super(mode);
10
+ }
11
+ getPlugins(filename) {
12
+ return [
13
+ new MiniCssExtractPlugin({
14
+ filename
15
+ }),
16
+ new VueLoaderPlugin()
17
+ ];
18
+ }
19
+ }
20
+ exports.VueTypescriptNoCodeSplittingPreset = VueTypescriptNoCodeSplittingPreset;