@serwist/nuxt 10.0.0-preview.12 → 10.0.0-preview.14
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 +6 -17
- package/dist/module.json +2 -2
- package/dist/module.mjs +21 -21
- package/dist/types.d.mts +1 -1
- package/package.json +16 -15
package/dist/module.d.mts
CHANGED
@@ -1,21 +1,7 @@
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
2
|
+
import { Optional, Require } from '@serwist/utils';
|
2
3
|
import { PluginOptions } from 'vite-plugin-serwist';
|
3
4
|
|
4
|
-
/**
|
5
|
-
* Make certain fields in a object type optional
|
6
|
-
*
|
7
|
-
* @example
|
8
|
-
* interface A {
|
9
|
-
* a: string;
|
10
|
-
* b: string;
|
11
|
-
* c: string;
|
12
|
-
* }
|
13
|
-
* type B = Optional<A, "b" | "c">;
|
14
|
-
* const b: B = { a: "hehe" }; //valid
|
15
|
-
* const b: B = {}; //invalid
|
16
|
-
*/
|
17
|
-
type Optional<T, U extends keyof T> = Omit<T, U> & Partial<Pick<T, U>>;
|
18
|
-
|
19
5
|
interface ClientOptions {
|
20
6
|
/**
|
21
7
|
* Whether this plugin should be registered.
|
@@ -28,8 +14,11 @@ interface ModuleOptions extends Optional<PluginOptions, "swSrc" | "swDest" | "gl
|
|
28
14
|
*/
|
29
15
|
client?: ClientOptions;
|
30
16
|
}
|
17
|
+
type DefaultModuleKeys = "base" | "scope" | "client" | "swSrc" | "swDest" | "swUrl" | "globDirectory" | "injectionPoint";
|
18
|
+
type DefaultModuleOptions = Required<Pick<ModuleOptions, DefaultModuleKeys>>;
|
19
|
+
type ResolvedModuleOptions = Require<ModuleOptions, DefaultModuleKeys>;
|
31
20
|
|
32
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions,
|
21
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, Required<Pick<ModuleOptions, DefaultModuleKeys>>, true>;
|
33
22
|
|
34
23
|
export { _default as default };
|
35
|
-
export type { ClientOptions, ModuleOptions };
|
24
|
+
export type { ClientOptions, DefaultModuleKeys, DefaultModuleOptions, ModuleOptions, ResolvedModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
@@ -1,41 +1,40 @@
|
|
1
1
|
import path from 'node:path';
|
2
2
|
import { defineNuxtModule, createResolver, addPlugin, extendWebpackConfig } from '@nuxt/kit';
|
3
|
-
import { resolveEntry } from '
|
4
|
-
import { createContext, main, dev, generateServiceWorker } from 'vite-plugin-serwist';
|
3
|
+
import { createContext, main, dev, generateServiceWorker, resolveEntry } from 'vite-plugin-serwist';
|
5
4
|
import { createHash } from 'node:crypto';
|
6
5
|
import { createReadStream } from 'node:fs';
|
7
6
|
import fsp from 'node:fs/promises';
|
7
|
+
import { DEFAULT_GLOB_PATTERNS } from '@serwist/build';
|
8
8
|
|
9
|
-
const version = "10.0.0-preview.
|
9
|
+
const version = "10.0.0-preview.14";
|
10
10
|
const packageJson = {
|
11
11
|
version: version};
|
12
12
|
|
13
|
-
|
13
|
+
const configureSerwistOptions = (options, nuxt, nitroConfig) => {
|
14
14
|
let buildAssetsDir = nuxt.options.app.buildAssetsDir ?? "_nuxt/";
|
15
15
|
if (buildAssetsDir[0] === "/") buildAssetsDir = buildAssetsDir.slice(1);
|
16
16
|
if (buildAssetsDir[buildAssetsDir.length - 1] !== "/") buildAssetsDir += "/";
|
17
17
|
if (!("dontCacheBustURLsMatching" in options)) {
|
18
18
|
options.dontCacheBustURLsMatching = new RegExp(buildAssetsDir);
|
19
19
|
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
options.globPatterns.push("**/_payload.json");
|
25
|
-
}
|
20
|
+
options.globPatterns = options.globPatterns ?? DEFAULT_GLOB_PATTERNS;
|
21
|
+
if (nuxt.options.experimental.payloadExtraction && // Has prerendered routes
|
22
|
+
(nuxt.options.nitro.static || nuxt.options._generate || !!nitroConfig.prerender?.routes?.length || Object.values(nitroConfig.routeRules ?? {}).some((r) => r.prerender))) {
|
23
|
+
options.globPatterns.push("**/_payload.json");
|
26
24
|
}
|
27
25
|
let appManifestFolder;
|
28
26
|
if (nuxt.options.experimental.appManifest) {
|
29
|
-
options.globPatterns = options.globPatterns ?? [];
|
30
27
|
appManifestFolder = `${buildAssetsDir}builds/`;
|
31
28
|
options.globPatterns.push(`${appManifestFolder}**/*.json`);
|
32
29
|
}
|
33
30
|
const _public = nitroConfig.output?.publicDir ?? nuxt.options.nitro?.output?.publicDir;
|
34
|
-
const publicDir = _public ? path.resolve(_public) : path.resolve(nuxt.options.
|
31
|
+
const publicDir = _public ? path.resolve(_public) : path.resolve(nuxt.options.rootDir, ".output/public");
|
32
|
+
options.swDest = options.swDest ? path.isAbsolute(options.swDest) ? options.swDest : path.resolve(publicDir, options.swDest) : path.resolve(publicDir, "sw.js");
|
33
|
+
options.globDirectory = options.globDirectory || publicDir;
|
35
34
|
if (!nuxt.options.dev && !options.manifestTransforms) {
|
36
35
|
options.manifestTransforms = [createManifestTransform(nuxt.options.app.baseURL ?? "/", publicDir, appManifestFolder)];
|
37
36
|
}
|
38
|
-
}
|
37
|
+
};
|
39
38
|
function createManifestTransform(base, publicDir, appManifestFolder) {
|
40
39
|
return async (entries) => {
|
41
40
|
entries.filter((e) => e.url.endsWith(".html")).forEach((e) => {
|
@@ -79,7 +78,7 @@ function createManifestTransform(base, publicDir, appManifestFolder) {
|
|
79
78
|
};
|
80
79
|
}
|
81
80
|
|
82
|
-
const module = defineNuxtModule({
|
81
|
+
const module = defineNuxtModule().with({
|
83
82
|
meta: {
|
84
83
|
name: "@serwist/nuxt",
|
85
84
|
configKey: "serwist",
|
@@ -89,7 +88,6 @@ const module = defineNuxtModule({
|
|
89
88
|
version: packageJson.version
|
90
89
|
},
|
91
90
|
defaults(nuxt) {
|
92
|
-
const publicDir = path.resolve(nuxt.options.rootDir, ".output/public");
|
93
91
|
return {
|
94
92
|
base: nuxt.options.app.baseURL,
|
95
93
|
scope: nuxt.options.app.baseURL,
|
@@ -99,16 +97,18 @@ const module = defineNuxtModule({
|
|
99
97
|
// Try to find `service-worker.{ts,js}` or `service-worker/index.{ts,js}`. If not found,
|
100
98
|
// force the user to provide a `swSrc` themself.
|
101
99
|
swSrc: resolveEntry(path.resolve(nuxt.options.rootDir, "service-worker")) || void 0,
|
102
|
-
swDest
|
100
|
+
// If `swDest` is not set by `configureSerwistOptions`, something is wrong.
|
101
|
+
swDest: "",
|
103
102
|
swUrl: "/sw.js",
|
104
|
-
globDirectory
|
103
|
+
// If `globDirectory` is not set by `configureSerwistOptions`, something is wrong.
|
104
|
+
globDirectory: "",
|
105
105
|
injectionPoint: "self.__SW_MANIFEST"
|
106
106
|
};
|
107
107
|
},
|
108
|
-
async setup(
|
108
|
+
async setup(_options, nuxt) {
|
109
109
|
const resolver = createResolver(import.meta.url);
|
110
110
|
let ctx;
|
111
|
-
const { client: _client, ...
|
111
|
+
const { client: _client, ...options } = _options;
|
112
112
|
const client = { registerPlugin: true, ..._client };
|
113
113
|
const runtimeDir = resolver.resolve("./runtime");
|
114
114
|
if (!nuxt.options.ssr) nuxt.options.build.transpile.push(runtimeDir);
|
@@ -122,7 +122,7 @@ const module = defineNuxtModule({
|
|
122
122
|
references.push({ path: resolver.resolve(runtimeDir, "plugins/augmentation.d.ts") });
|
123
123
|
});
|
124
124
|
nuxt.hook("nitro:init", (nitro) => {
|
125
|
-
|
125
|
+
configureSerwistOptions(options, nuxt, nitro.options);
|
126
126
|
});
|
127
127
|
nuxt.hook("vite:extend", ({ config }) => {
|
128
128
|
const plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "vite-plugin-serwist");
|
@@ -154,7 +154,7 @@ const module = defineNuxtModule({
|
|
154
154
|
}
|
155
155
|
});
|
156
156
|
}
|
157
|
-
ctx = createContext(
|
157
|
+
ctx = createContext(options, "nuxt");
|
158
158
|
viteInlineConfig.plugins.push(main(ctx), dev(ctx));
|
159
159
|
});
|
160
160
|
extendWebpackConfig(() => {
|
package/dist/types.d.mts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@serwist/nuxt",
|
3
|
-
"version": "10.0.0-preview.
|
3
|
+
"version": "10.0.0-preview.14",
|
4
4
|
"type": "module",
|
5
5
|
"sideEffects": false,
|
6
6
|
"description": "A Nuxt module that integrates Serwist into your application.",
|
@@ -45,30 +45,31 @@
|
|
45
45
|
"vite",
|
46
46
|
"@nuxt/kit",
|
47
47
|
"@serwist/build",
|
48
|
+
"@serwist/utils",
|
48
49
|
"vite-plugin-serwist",
|
49
50
|
"virtual:serwist-nuxt-configuration",
|
50
51
|
"virtual:serwist"
|
51
52
|
]
|
52
53
|
},
|
53
54
|
"dependencies": {
|
54
|
-
"@nuxt/kit": "4.0.
|
55
|
-
"@serwist/build": "10.0.0-preview.
|
56
|
-
"@serwist/utils": "10.0.0-preview.
|
57
|
-
"@serwist/window": "10.0.0-preview.
|
58
|
-
"vite-plugin-serwist": "10.0.0-preview.
|
55
|
+
"@nuxt/kit": "4.0.3",
|
56
|
+
"@serwist/build": "10.0.0-preview.14",
|
57
|
+
"@serwist/utils": "10.0.0-preview.14",
|
58
|
+
"@serwist/window": "10.0.0-preview.14",
|
59
|
+
"vite-plugin-serwist": "10.0.0-preview.14"
|
59
60
|
},
|
60
61
|
"devDependencies": {
|
61
|
-
"@nuxt/module-builder": "1.0.
|
62
|
-
"@nuxt/schema": "4.0.
|
63
|
-
"@types/node": "24.0
|
64
|
-
"eslint": "9.
|
65
|
-
"nuxt": "4.0.
|
62
|
+
"@nuxt/module-builder": "1.0.2",
|
63
|
+
"@nuxt/schema": "4.0.3",
|
64
|
+
"@types/node": "24.3.0",
|
65
|
+
"eslint": "9.34.0",
|
66
|
+
"nuxt": "4.0.3",
|
66
67
|
"rimraf": "6.0.1",
|
67
68
|
"serve": "14.2.4",
|
68
|
-
"typescript": "5.
|
69
|
-
"vite": "7.
|
70
|
-
"vue-tsc": "3.0.
|
71
|
-
"@serwist/configs": "10.0.0-preview.
|
69
|
+
"typescript": "5.9.2",
|
70
|
+
"vite": "7.1.3",
|
71
|
+
"vue-tsc": "3.0.6",
|
72
|
+
"@serwist/configs": "10.0.0-preview.14"
|
72
73
|
},
|
73
74
|
"peerDependencies": {
|
74
75
|
"typescript": ">=5.0.0",
|