@serwist/nuxt 9.0.12 → 10.0.0-preview.1
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/dist/module.d.mts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +122 -19
- package/package.json +8 -8
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
@@ -1,11 +1,121 @@
|
|
1
1
|
import path from 'node:path';
|
2
2
|
import { defineNuxtModule, createResolver, addPlugin, extendWebpackConfig } from '@nuxt/kit';
|
3
|
-
import { resolveEntry, createContext,
|
3
|
+
import { resolveEntry, createContext, main as main$1, dev, generateServiceWorker } from 'vite-plugin-serwist';
|
4
4
|
import { createHash } from 'node:crypto';
|
5
5
|
import { createReadStream } from 'node:fs';
|
6
6
|
import fsp from 'node:fs/promises';
|
7
7
|
|
8
|
-
const
|
8
|
+
const name = "@serwist/nuxt";
|
9
|
+
const version = "10.0.0-preview.1";
|
10
|
+
const type = "module";
|
11
|
+
const description = "A Nuxt module that integrates Serwist into your application.";
|
12
|
+
const files = [
|
13
|
+
"dist"
|
14
|
+
];
|
15
|
+
const keywords = [
|
16
|
+
"nuxt",
|
17
|
+
"pwa",
|
18
|
+
"vite",
|
19
|
+
"vite-plugin",
|
20
|
+
"serwist",
|
21
|
+
"serwistjs",
|
22
|
+
"pwa",
|
23
|
+
"sw",
|
24
|
+
"service worker",
|
25
|
+
"web",
|
26
|
+
"service-worker",
|
27
|
+
"nuxt-module"
|
28
|
+
];
|
29
|
+
const engines = {
|
30
|
+
node: ">=18.0.0"
|
31
|
+
};
|
32
|
+
const repository = "https://github.com/serwist/serwist";
|
33
|
+
const bugs = "https://github.com/serwist/serwist/issues";
|
34
|
+
const homepage = "https://serwist.pages.dev";
|
35
|
+
const main = "./dist/module.mjs";
|
36
|
+
const types = "./dist/types.d.ts";
|
37
|
+
const exports = {
|
38
|
+
".": {
|
39
|
+
types: "./dist/types.d.mts",
|
40
|
+
"default": "./dist/module.mjs"
|
41
|
+
}
|
42
|
+
};
|
43
|
+
const build = {
|
44
|
+
externals: [
|
45
|
+
"node:child_process",
|
46
|
+
"node:fs",
|
47
|
+
"node:path",
|
48
|
+
"consola",
|
49
|
+
"esbuild",
|
50
|
+
"rollup",
|
51
|
+
"vite",
|
52
|
+
"@nuxt/kit",
|
53
|
+
"@serwist/build",
|
54
|
+
"vite-plugin-serwist",
|
55
|
+
"virtual:serwist-nuxt-configuration",
|
56
|
+
"virtual:serwist"
|
57
|
+
]
|
58
|
+
};
|
59
|
+
const scripts = {
|
60
|
+
build: "nuxt-module-build prepare && nuxt-module-build build",
|
61
|
+
dev: "nuxi dev playground --port 5173",
|
62
|
+
"dev:generate": "nuxi generate playground",
|
63
|
+
"dev:generate:netlify": "NITRO_PRESET=netlify nuxi generate playground",
|
64
|
+
"dev:generate:vercel": "NITRO_PRESET=vercel nuxi generate playground",
|
65
|
+
"dev:build": "nuxi build playground",
|
66
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
67
|
+
"dev:preview:build": "nr dev:build && node playground/.output/server/index.mjs",
|
68
|
+
"dev:preview:generate": "nr dev:generate && serve playground/dist"
|
69
|
+
};
|
70
|
+
const dependencies = {
|
71
|
+
"@nuxt/kit": "3.15.4",
|
72
|
+
"@serwist/build": "workspace:*",
|
73
|
+
"vite-plugin-serwist": "workspace:*",
|
74
|
+
"@serwist/window": "workspace:*"
|
75
|
+
};
|
76
|
+
const devDependencies = {
|
77
|
+
"@nuxt/module-builder": "0.8.4",
|
78
|
+
"@nuxt/schema": "3.15.4",
|
79
|
+
"@serwist/configs": "workspace:*",
|
80
|
+
"@types/node": "22.13.5",
|
81
|
+
eslint: "9.21.0",
|
82
|
+
nuxt: "3.15.4",
|
83
|
+
rimraf: "5.0.9",
|
84
|
+
serve: "14.2.4",
|
85
|
+
typescript: "5.7.3",
|
86
|
+
vite: "6.1.1",
|
87
|
+
"vue-tsc": "2.2.4"
|
88
|
+
};
|
89
|
+
const peerDependencies = {
|
90
|
+
typescript: ">=5.0.0",
|
91
|
+
vite: "^5.0.0"
|
92
|
+
};
|
93
|
+
const peerDependenciesMeta = {
|
94
|
+
typescript: {
|
95
|
+
optional: true
|
96
|
+
}
|
97
|
+
};
|
98
|
+
const packageJson = {
|
99
|
+
name: name,
|
100
|
+
version: version,
|
101
|
+
type: type,
|
102
|
+
description: description,
|
103
|
+
files: files,
|
104
|
+
keywords: keywords,
|
105
|
+
engines: engines,
|
106
|
+
repository: repository,
|
107
|
+
bugs: bugs,
|
108
|
+
homepage: homepage,
|
109
|
+
main: main,
|
110
|
+
types: types,
|
111
|
+
exports: exports,
|
112
|
+
build: build,
|
113
|
+
scripts: scripts,
|
114
|
+
dependencies: dependencies,
|
115
|
+
devDependencies: devDependencies,
|
116
|
+
peerDependencies: peerDependencies,
|
117
|
+
peerDependenciesMeta: peerDependenciesMeta
|
118
|
+
};
|
9
119
|
|
10
120
|
function configurePwaOptions(options, nuxt, nitroConfig) {
|
11
121
|
let buildAssetsDir = nuxt.options.app.buildAssetsDir ?? "_nuxt/";
|
@@ -88,7 +198,7 @@ const module = defineNuxtModule({
|
|
88
198
|
nuxt: "^3.8.0",
|
89
199
|
bridge: false
|
90
200
|
},
|
91
|
-
version
|
201
|
+
version: packageJson.version
|
92
202
|
},
|
93
203
|
defaults(nuxt) {
|
94
204
|
const publicDir = nuxt.options.nitro?.output?.publicDir ? path.resolve(nuxt.options.nitro.output.publicDir) : path.resolve(nuxt.options.buildDir, "../.output/public");
|
@@ -110,7 +220,6 @@ const module = defineNuxtModule({
|
|
110
220
|
async setup(options, nuxt) {
|
111
221
|
const resolver = createResolver(import.meta.url);
|
112
222
|
let ctx;
|
113
|
-
let api;
|
114
223
|
const { client: _client, ...userOptions } = options;
|
115
224
|
const client = { registerPlugin: true, ..._client };
|
116
225
|
const runtimeDir = resolver.resolve("./runtime");
|
@@ -129,19 +238,17 @@ const module = defineNuxtModule({
|
|
129
238
|
configurePwaOptions(options, nuxt, nitro.options);
|
130
239
|
});
|
131
240
|
nuxt.hook("vite:extend", ({ config }) => {
|
132
|
-
const plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "
|
241
|
+
const plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "vite-plugin-serwist");
|
133
242
|
if (plugin) {
|
134
|
-
throw new Error("Remove '
|
243
|
+
throw new Error("Remove 'vite-plugin-serwist' from your Vite configuration! Do not use it alongside '@serwist/nuxt'.");
|
135
244
|
}
|
136
245
|
});
|
137
246
|
nuxt.hook("vite:extendConfig", async (viteInlineConfig, { isClient }) => {
|
138
|
-
if (!viteInlineConfig.plugins)
|
247
|
+
if (!viteInlineConfig.plugins)
|
139
248
|
viteInlineConfig.plugins = [];
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
throw new Error("Remove '@serwist/vite' from your Vite configuration! Do not use it alongside '@serwist/nuxt'.");
|
144
|
-
}
|
249
|
+
const plugin = viteInlineConfig.plugins.find((p) => p && typeof p === "object" && "name" in p && p.name === "vite-plugin-serwist");
|
250
|
+
if (plugin)
|
251
|
+
throw new Error("Remove 'vite-plugin-serwist' from your Vite configuration! Do not use it alongside '@serwist/nuxt'.");
|
145
252
|
if (isClient) {
|
146
253
|
const configuration = "virtual:serwist-nuxt-configuration";
|
147
254
|
const resolvedConfiguration = `\0${configuration}`;
|
@@ -163,19 +270,15 @@ const module = defineNuxtModule({
|
|
163
270
|
});
|
164
271
|
}
|
165
272
|
ctx = createContext(userOptions, "nuxt");
|
166
|
-
|
167
|
-
const plugins = [main(ctx, api), dev(ctx, api)];
|
168
|
-
viteInlineConfig.plugins.push(plugins);
|
273
|
+
viteInlineConfig.plugins.push(main$1(ctx), dev(ctx));
|
169
274
|
});
|
170
275
|
extendWebpackConfig(() => {
|
171
276
|
throw new Error("Webpack is not supported: '@serwist/nuxt' can only be used with Vite!");
|
172
277
|
});
|
173
278
|
if (!nuxt.options.dev) {
|
174
279
|
nuxt.hook("nitro:build:public-assets", () => {
|
175
|
-
if (
|
176
|
-
|
177
|
-
}
|
178
|
-
void api.generateSW();
|
280
|
+
if (ctx && !ctx.options.disable)
|
281
|
+
void generateServiceWorker(ctx);
|
179
282
|
});
|
180
283
|
}
|
181
284
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@serwist/nuxt",
|
3
|
-
"version": "
|
3
|
+
"version": "10.0.0-preview.1",
|
4
4
|
"type": "module",
|
5
5
|
"description": "A Nuxt module that integrates Serwist into your application.",
|
6
6
|
"files": [
|
@@ -45,16 +45,16 @@
|
|
45
45
|
"vite",
|
46
46
|
"@nuxt/kit",
|
47
47
|
"@serwist/build",
|
48
|
-
"
|
48
|
+
"vite-plugin-serwist",
|
49
49
|
"virtual:serwist-nuxt-configuration",
|
50
50
|
"virtual:serwist"
|
51
51
|
]
|
52
52
|
},
|
53
53
|
"dependencies": {
|
54
54
|
"@nuxt/kit": "3.15.4",
|
55
|
-
"@serwist/build": "
|
56
|
-
"
|
57
|
-
"@serwist/window": "
|
55
|
+
"@serwist/build": "10.0.0-preview.1",
|
56
|
+
"vite-plugin-serwist": "10.0.0-preview.1",
|
57
|
+
"@serwist/window": "10.0.0-preview.1"
|
58
58
|
},
|
59
59
|
"devDependencies": {
|
60
60
|
"@nuxt/module-builder": "0.8.4",
|
@@ -64,10 +64,10 @@
|
|
64
64
|
"nuxt": "3.15.4",
|
65
65
|
"rimraf": "5.0.9",
|
66
66
|
"serve": "14.2.4",
|
67
|
-
"typescript": "5.
|
67
|
+
"typescript": "5.7.3",
|
68
68
|
"vite": "6.1.1",
|
69
|
-
"vue-tsc": "2.2.
|
70
|
-
"@serwist/configs": "
|
69
|
+
"vue-tsc": "2.2.4",
|
70
|
+
"@serwist/configs": "10.0.0-preview.1"
|
71
71
|
},
|
72
72
|
"peerDependencies": {
|
73
73
|
"typescript": ">=5.0.0",
|