@docusaurus/plugin-pwa 2.0.0-beta.18 → 2.0.0-beta.19
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/lib/index.js +4 -3
- package/lib/registerSw.js +2 -2
- package/lib/sw.js +3 -2
- package/package.json +18 -18
- package/src/index.ts +4 -3
- package/src/plugin-pwa.d.ts +3 -1
- package/src/registerSw.js +2 -2
- package/src/sw.js +3 -2
package/lib/index.js
CHANGED
|
@@ -112,7 +112,7 @@ function pluginPWA(context, options) {
|
|
|
112
112
|
optimization: {
|
|
113
113
|
splitChunks: false,
|
|
114
114
|
minimize: !debug,
|
|
115
|
-
//
|
|
115
|
+
// See https://developers.google.com/web/tools/workbox/guides/using-bundlers#webpack
|
|
116
116
|
minimizer: debug
|
|
117
117
|
? []
|
|
118
118
|
: [
|
|
@@ -123,7 +123,8 @@ function pluginPWA(context, options) {
|
|
|
123
123
|
},
|
|
124
124
|
plugins: [
|
|
125
125
|
new webpack_1.default.EnvironmentPlugin({
|
|
126
|
-
|
|
126
|
+
// Fallback value required with Webpack 5
|
|
127
|
+
PWA_SW_CUSTOM: swCustom || '',
|
|
127
128
|
}),
|
|
128
129
|
new LogPlugin_1.default({
|
|
129
130
|
name: 'Service Worker',
|
|
@@ -151,7 +152,7 @@ function pluginPWA(context, options) {
|
|
|
151
152
|
// @ts-expect-error: internal API?
|
|
152
153
|
...(workbox_build_1.injectManifest.globPatterns ?? []),
|
|
153
154
|
],
|
|
154
|
-
//
|
|
155
|
+
// Those attributes are not overrideable
|
|
155
156
|
swDest,
|
|
156
157
|
swSrc: swDest,
|
|
157
158
|
globDirectory: props.outDir,
|
package/lib/registerSw.js
CHANGED
|
@@ -16,7 +16,7 @@ const PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES =
|
|
|
16
16
|
const PWA_DEBUG = process.env.PWA_DEBUG;
|
|
17
17
|
/* eslint-enable prefer-destructuring */
|
|
18
18
|
|
|
19
|
-
const debug = PWA_DEBUG; //
|
|
19
|
+
const debug = PWA_DEBUG; // Shortcut
|
|
20
20
|
|
|
21
21
|
const MAX_MOBILE_WIDTH = 940;
|
|
22
22
|
|
|
@@ -101,7 +101,7 @@ async function getActiveStrategies() {
|
|
|
101
101
|
return isActive ? strategyName : undefined;
|
|
102
102
|
}),
|
|
103
103
|
);
|
|
104
|
-
return activeStrategies.filter(Boolean);
|
|
104
|
+
return activeStrategies.filter(Boolean);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
async function isOfflineModeEnabled() {
|
package/lib/sw.js
CHANGED
|
@@ -18,7 +18,7 @@ function parseSwParams() {
|
|
|
18
18
|
return params;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
//
|
|
21
|
+
// Doc advises against dynamic imports in SW
|
|
22
22
|
// https://developers.google.com/web/tools/workbox/guides/using-bundlers#code_splitting_and_dynamic_imports
|
|
23
23
|
// https://twitter.com/sebastienlorber/status/1280155204575518720
|
|
24
24
|
// but looks it's working fine as it's inlined by webpack, need to double check
|
|
@@ -73,7 +73,8 @@ function getPossibleURLs(url) {
|
|
|
73
73
|
// eslint-disable-next-line no-underscore-dangle
|
|
74
74
|
const precacheManifest = self.__WB_MANIFEST;
|
|
75
75
|
const controller = new PrecacheController({
|
|
76
|
-
|
|
76
|
+
// Safer to turn this true?
|
|
77
|
+
fallbackToNetwork: true,
|
|
77
78
|
});
|
|
78
79
|
|
|
79
80
|
if (params.offlineMode) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-pwa",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.19",
|
|
4
4
|
"description": "Docusaurus Plugin to add PWA support.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-pwa.d.ts",
|
|
@@ -20,31 +20,31 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@babel/core": "^7.17.
|
|
24
|
-
"@babel/preset-env": "^7.
|
|
25
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
26
|
-
"@docusaurus/theme-common": "2.0.0-beta.
|
|
27
|
-
"@docusaurus/theme-translations": "2.0.0-beta.
|
|
28
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
29
|
-
"@docusaurus/utils-validation": "2.0.0-beta.
|
|
30
|
-
"babel-loader": "^8.2.
|
|
23
|
+
"@babel/core": "^7.17.10",
|
|
24
|
+
"@babel/preset-env": "^7.17.10",
|
|
25
|
+
"@docusaurus/core": "2.0.0-beta.19",
|
|
26
|
+
"@docusaurus/theme-common": "2.0.0-beta.19",
|
|
27
|
+
"@docusaurus/theme-translations": "2.0.0-beta.19",
|
|
28
|
+
"@docusaurus/utils": "2.0.0-beta.19",
|
|
29
|
+
"@docusaurus/utils-validation": "2.0.0-beta.19",
|
|
30
|
+
"babel-loader": "^8.2.5",
|
|
31
31
|
"clsx": "^1.1.1",
|
|
32
|
-
"core-js": "^3.
|
|
32
|
+
"core-js": "^3.22.3",
|
|
33
33
|
"terser-webpack-plugin": "^5.3.1",
|
|
34
|
-
"tslib": "^2.
|
|
35
|
-
"webpack": "^5.
|
|
34
|
+
"tslib": "^2.4.0",
|
|
35
|
+
"webpack": "^5.72.0",
|
|
36
36
|
"webpack-merge": "^5.8.0",
|
|
37
|
-
"workbox-build": "^6.5.
|
|
38
|
-
"workbox-precaching": "^6.5.
|
|
39
|
-
"workbox-window": "^6.5.
|
|
37
|
+
"workbox-build": "^6.5.3",
|
|
38
|
+
"workbox-precaching": "^6.5.3",
|
|
39
|
+
"workbox-window": "^6.5.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
43
|
-
"fs-extra": "^10.0
|
|
42
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.19",
|
|
43
|
+
"fs-extra": "^10.1.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": "^16.8.4 || ^17.0.0",
|
|
47
47
|
"react-dom": "^16.8.4 || ^17.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "a71e60a49cce93c1006ef10c41ac03187f057102"
|
|
50
50
|
}
|
package/src/index.ts
CHANGED
|
@@ -150,7 +150,7 @@ export default function pluginPWA(
|
|
|
150
150
|
optimization: {
|
|
151
151
|
splitChunks: false,
|
|
152
152
|
minimize: !debug,
|
|
153
|
-
//
|
|
153
|
+
// See https://developers.google.com/web/tools/workbox/guides/using-bundlers#webpack
|
|
154
154
|
minimizer: debug
|
|
155
155
|
? []
|
|
156
156
|
: [
|
|
@@ -161,7 +161,8 @@ export default function pluginPWA(
|
|
|
161
161
|
},
|
|
162
162
|
plugins: [
|
|
163
163
|
new webpack.EnvironmentPlugin({
|
|
164
|
-
|
|
164
|
+
// Fallback value required with Webpack 5
|
|
165
|
+
PWA_SW_CUSTOM: swCustom || '',
|
|
165
166
|
}),
|
|
166
167
|
new LogPlugin({
|
|
167
168
|
name: 'Service Worker',
|
|
@@ -192,7 +193,7 @@ export default function pluginPWA(
|
|
|
192
193
|
// @ts-expect-error: internal API?
|
|
193
194
|
...(injectManifest.globPatterns ?? []),
|
|
194
195
|
],
|
|
195
|
-
//
|
|
196
|
+
// Those attributes are not overrideable
|
|
196
197
|
swDest,
|
|
197
198
|
swSrc: swDest,
|
|
198
199
|
globDirectory: props.outDir,
|
package/src/plugin-pwa.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ declare module '@docusaurus/plugin-pwa' {
|
|
|
66
66
|
tagName: string;
|
|
67
67
|
href?: string;
|
|
68
68
|
content?: string;
|
|
69
|
-
[attributeName: string]: string | boolean;
|
|
69
|
+
[attributeName: string]: string | boolean | undefined;
|
|
70
70
|
}[];
|
|
71
71
|
/**
|
|
72
72
|
* Useful for additional Workbox rules. You can do whatever a service worker
|
|
@@ -81,6 +81,8 @@ declare module '@docusaurus/plugin-pwa' {
|
|
|
81
81
|
*/
|
|
82
82
|
swRegister: string | false;
|
|
83
83
|
};
|
|
84
|
+
|
|
85
|
+
export type Options = Partial<PluginOptions>;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
declare module '@theme/PwaReloadPopup' {
|
package/src/registerSw.js
CHANGED
|
@@ -16,7 +16,7 @@ const PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES =
|
|
|
16
16
|
const PWA_DEBUG = process.env.PWA_DEBUG;
|
|
17
17
|
/* eslint-enable prefer-destructuring */
|
|
18
18
|
|
|
19
|
-
const debug = PWA_DEBUG; //
|
|
19
|
+
const debug = PWA_DEBUG; // Shortcut
|
|
20
20
|
|
|
21
21
|
const MAX_MOBILE_WIDTH = 940;
|
|
22
22
|
|
|
@@ -101,7 +101,7 @@ async function getActiveStrategies() {
|
|
|
101
101
|
return isActive ? strategyName : undefined;
|
|
102
102
|
}),
|
|
103
103
|
);
|
|
104
|
-
return activeStrategies.filter(Boolean);
|
|
104
|
+
return activeStrategies.filter(Boolean);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
async function isOfflineModeEnabled() {
|
package/src/sw.js
CHANGED
|
@@ -18,7 +18,7 @@ function parseSwParams() {
|
|
|
18
18
|
return params;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
//
|
|
21
|
+
// Doc advises against dynamic imports in SW
|
|
22
22
|
// https://developers.google.com/web/tools/workbox/guides/using-bundlers#code_splitting_and_dynamic_imports
|
|
23
23
|
// https://twitter.com/sebastienlorber/status/1280155204575518720
|
|
24
24
|
// but looks it's working fine as it's inlined by webpack, need to double check
|
|
@@ -73,7 +73,8 @@ function getPossibleURLs(url) {
|
|
|
73
73
|
// eslint-disable-next-line no-underscore-dangle
|
|
74
74
|
const precacheManifest = self.__WB_MANIFEST;
|
|
75
75
|
const controller = new PrecacheController({
|
|
76
|
-
|
|
76
|
+
// Safer to turn this true?
|
|
77
|
+
fallbackToNetwork: true,
|
|
77
78
|
});
|
|
78
79
|
|
|
79
80
|
if (params.offlineMode) {
|