@docusaurus/plugin-pwa 0.0.0-6081 → 0.0.0-6083
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 +16 -14
- package/package.json +11 -12
- package/src/index.ts +22 -14
- package/src/deps.d.ts +0 -15
package/lib/index.js
CHANGED
|
@@ -10,13 +10,10 @@ exports.validateOptions = void 0;
|
|
|
10
10
|
exports.default = pluginPWA;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
-
const
|
|
14
|
-
const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
|
|
15
|
-
const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
|
|
13
|
+
const bundler_1 = require("@docusaurus/bundler");
|
|
16
14
|
const workbox_build_1 = require("workbox-build");
|
|
17
15
|
const utils_1 = require("@docusaurus/utils");
|
|
18
16
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
19
|
-
const utils_2 = require("@docusaurus/core/lib/webpack/utils");
|
|
20
17
|
const theme_translations_1 = require("@docusaurus/theme-translations");
|
|
21
18
|
const PluginName = 'docusaurus-plugin-pwa';
|
|
22
19
|
function getSWBabelLoader() {
|
|
@@ -66,10 +63,10 @@ function pluginPWA(context, options) {
|
|
|
66
63
|
name: 'plugin-pwa',
|
|
67
64
|
});
|
|
68
65
|
},
|
|
69
|
-
configureWebpack(config) {
|
|
66
|
+
configureWebpack(config, isServer, { currentBundler }) {
|
|
70
67
|
return {
|
|
71
68
|
plugins: [
|
|
72
|
-
new
|
|
69
|
+
new currentBundler.instance.EnvironmentPlugin(
|
|
73
70
|
// See https://github.com/facebook/docusaurus/pull/10455#issuecomment-2317593528
|
|
74
71
|
// See https://github.com/webpack/webpack/commit/adf2a6b7c6077fd806ea0e378c1450cccecc9ed0#r145989788
|
|
75
72
|
// @ts-expect-error: bad Webpack type?
|
|
@@ -103,6 +100,9 @@ function pluginPWA(context, options) {
|
|
|
103
100
|
},
|
|
104
101
|
async postBuild(props) {
|
|
105
102
|
const swSourceFileTest = /\.m?js$/;
|
|
103
|
+
const ProgressBarPlugin = await (0, bundler_1.getProgressBarPlugin)({
|
|
104
|
+
currentBundler: props.currentBundler,
|
|
105
|
+
});
|
|
106
106
|
const swWebpackConfig = {
|
|
107
107
|
entry: require.resolve('./sw.js'),
|
|
108
108
|
output: {
|
|
@@ -119,18 +119,17 @@ function pluginPWA(context, options) {
|
|
|
119
119
|
// See https://developers.google.com/web/tools/workbox/guides/using-bundlers#webpack
|
|
120
120
|
minimizer: debug
|
|
121
121
|
? []
|
|
122
|
-
:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
],
|
|
122
|
+
: await (0, bundler_1.getMinimizers)({
|
|
123
|
+
faster: props.siteConfig.future.experimental_faster,
|
|
124
|
+
currentBundler: props.currentBundler,
|
|
125
|
+
}),
|
|
127
126
|
},
|
|
128
127
|
plugins: [
|
|
129
|
-
new
|
|
128
|
+
new props.currentBundler.instance.EnvironmentPlugin({
|
|
130
129
|
// Fallback value required with Webpack 5
|
|
131
130
|
PWA_SW_CUSTOM: swCustom ?? '',
|
|
132
131
|
}),
|
|
133
|
-
new
|
|
132
|
+
new ProgressBarPlugin({
|
|
134
133
|
name: 'Service Worker',
|
|
135
134
|
color: 'red',
|
|
136
135
|
}),
|
|
@@ -145,7 +144,10 @@ function pluginPWA(context, options) {
|
|
|
145
144
|
],
|
|
146
145
|
},
|
|
147
146
|
};
|
|
148
|
-
await (0,
|
|
147
|
+
await (0, bundler_1.compile)({
|
|
148
|
+
configs: [swWebpackConfig],
|
|
149
|
+
currentBundler: props.currentBundler,
|
|
150
|
+
});
|
|
149
151
|
const swDest = path_1.default.resolve(props.outDir, 'sw.js');
|
|
150
152
|
await (0, workbox_build_1.injectManifest)({
|
|
151
153
|
...injectManifestConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-pwa",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-6083",
|
|
4
4
|
"description": "Docusaurus Plugin to add PWA support.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-pwa.d.ts",
|
|
@@ -22,27 +22,26 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@babel/core": "^7.23.3",
|
|
24
24
|
"@babel/preset-env": "^7.23.3",
|
|
25
|
-
"@docusaurus/
|
|
26
|
-
"@docusaurus/
|
|
27
|
-
"@docusaurus/
|
|
28
|
-
"@docusaurus/theme-
|
|
29
|
-
"@docusaurus/
|
|
30
|
-
"@docusaurus/
|
|
31
|
-
"@docusaurus/utils
|
|
25
|
+
"@docusaurus/bundler": "0.0.0-6083",
|
|
26
|
+
"@docusaurus/core": "0.0.0-6083",
|
|
27
|
+
"@docusaurus/logger": "0.0.0-6083",
|
|
28
|
+
"@docusaurus/theme-common": "0.0.0-6083",
|
|
29
|
+
"@docusaurus/theme-translations": "0.0.0-6083",
|
|
30
|
+
"@docusaurus/types": "0.0.0-6083",
|
|
31
|
+
"@docusaurus/utils": "0.0.0-6083",
|
|
32
|
+
"@docusaurus/utils-validation": "0.0.0-6083",
|
|
32
33
|
"babel-loader": "^9.1.3",
|
|
33
34
|
"clsx": "^2.0.0",
|
|
34
35
|
"core-js": "^3.31.1",
|
|
35
|
-
"terser-webpack-plugin": "^5.3.9",
|
|
36
36
|
"tslib": "^2.6.0",
|
|
37
37
|
"webpack": "^5.88.1",
|
|
38
38
|
"webpack-merge": "^5.9.0",
|
|
39
|
-
"webpackbar": "^5.0.2",
|
|
40
39
|
"workbox-build": "^7.0.0",
|
|
41
40
|
"workbox-precaching": "^7.0.0",
|
|
42
41
|
"workbox-window": "^7.0.0"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
44
|
+
"@docusaurus/module-type-aliases": "0.0.0-6083",
|
|
46
45
|
"fs-extra": "^11.1.0"
|
|
47
46
|
},
|
|
48
47
|
"peerDependencies": {
|
|
@@ -52,5 +51,5 @@
|
|
|
52
51
|
"engines": {
|
|
53
52
|
"node": ">=18.0"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "474967f4f49da90a1fca9f9034b0c054c5e29c7f"
|
|
56
55
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import path from 'path';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
9
|
+
import {type Configuration} from 'webpack';
|
|
10
|
+
import {
|
|
11
|
+
compile,
|
|
12
|
+
getProgressBarPlugin,
|
|
13
|
+
getMinimizers,
|
|
14
|
+
} from '@docusaurus/bundler';
|
|
12
15
|
import {injectManifest} from 'workbox-build';
|
|
13
16
|
import {normalizeUrl} from '@docusaurus/utils';
|
|
14
17
|
import logger from '@docusaurus/logger';
|
|
15
|
-
import {compile} from '@docusaurus/core/lib/webpack/utils';
|
|
16
18
|
import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
|
|
17
19
|
import type {HtmlTags, LoadContext, Plugin} from '@docusaurus/types';
|
|
18
20
|
import type {PluginOptions} from '@docusaurus/plugin-pwa';
|
|
@@ -89,10 +91,10 @@ export default function pluginPWA(
|
|
|
89
91
|
});
|
|
90
92
|
},
|
|
91
93
|
|
|
92
|
-
configureWebpack(config) {
|
|
94
|
+
configureWebpack(config, isServer, {currentBundler}) {
|
|
93
95
|
return {
|
|
94
96
|
plugins: [
|
|
95
|
-
new
|
|
97
|
+
new currentBundler.instance.EnvironmentPlugin(
|
|
96
98
|
// See https://github.com/facebook/docusaurus/pull/10455#issuecomment-2317593528
|
|
97
99
|
// See https://github.com/webpack/webpack/commit/adf2a6b7c6077fd806ea0e378c1450cccecc9ed0#r145989788
|
|
98
100
|
// @ts-expect-error: bad Webpack type?
|
|
@@ -139,6 +141,10 @@ export default function pluginPWA(
|
|
|
139
141
|
async postBuild(props) {
|
|
140
142
|
const swSourceFileTest = /\.m?js$/;
|
|
141
143
|
|
|
144
|
+
const ProgressBarPlugin = await getProgressBarPlugin({
|
|
145
|
+
currentBundler: props.currentBundler,
|
|
146
|
+
});
|
|
147
|
+
|
|
142
148
|
const swWebpackConfig: Configuration = {
|
|
143
149
|
entry: require.resolve('./sw.js'),
|
|
144
150
|
output: {
|
|
@@ -155,18 +161,17 @@ export default function pluginPWA(
|
|
|
155
161
|
// See https://developers.google.com/web/tools/workbox/guides/using-bundlers#webpack
|
|
156
162
|
minimizer: debug
|
|
157
163
|
? []
|
|
158
|
-
:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
],
|
|
164
|
+
: await getMinimizers({
|
|
165
|
+
faster: props.siteConfig.future.experimental_faster,
|
|
166
|
+
currentBundler: props.currentBundler,
|
|
167
|
+
}),
|
|
163
168
|
},
|
|
164
169
|
plugins: [
|
|
165
|
-
new
|
|
170
|
+
new props.currentBundler.instance.EnvironmentPlugin({
|
|
166
171
|
// Fallback value required with Webpack 5
|
|
167
172
|
PWA_SW_CUSTOM: swCustom ?? '',
|
|
168
173
|
}),
|
|
169
|
-
new
|
|
174
|
+
new ProgressBarPlugin({
|
|
170
175
|
name: 'Service Worker',
|
|
171
176
|
color: 'red',
|
|
172
177
|
}),
|
|
@@ -182,7 +187,10 @@ export default function pluginPWA(
|
|
|
182
187
|
},
|
|
183
188
|
};
|
|
184
189
|
|
|
185
|
-
await compile(
|
|
190
|
+
await compile({
|
|
191
|
+
configs: [swWebpackConfig],
|
|
192
|
+
currentBundler: props.currentBundler,
|
|
193
|
+
});
|
|
186
194
|
|
|
187
195
|
const swDest = path.resolve(props.outDir, 'sw.js');
|
|
188
196
|
|
package/src/deps.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// TODO incompatible declaration file: https://github.com/unjs/webpackbar/pull/108
|
|
9
|
-
declare module 'webpackbar' {
|
|
10
|
-
import webpack from 'webpack';
|
|
11
|
-
|
|
12
|
-
export default class WebpackBarPlugin extends webpack.ProgressPlugin {
|
|
13
|
-
constructor(options: {name: string; color?: string});
|
|
14
|
-
}
|
|
15
|
-
}
|