@serwist/next 10.0.0-preview.1 → 10.0.0-preview.10
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/chunks/schema.js +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -10
- package/dist/lib/find-first-truthy.d.ts.map +1 -1
- package/dist/lib/get-content-hash.d.ts.map +1 -1
- package/dist/lib/get-package-version.d.ts.map +1 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/load-tsconfig.d.ts.map +1 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/schema.d.ts +64 -225
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/validator.d.ts.map +1 -1
- package/package.json +20 -18
- package/src/index.ts +15 -5
- package/src/lib/get-content-hash.ts +1 -2
- package/src/lib/index.ts +0 -1
- package/src/lib/schema.ts +16 -16
- package/src/lib/validator.ts +3 -2
- package/dist/lib/get-file-hash.d.ts +0 -3
- package/dist/lib/get-file-hash.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -4
- package/dist/utils.d.ts.map +0 -1
- package/src/lib/get-file-hash.ts +0 -4
- package/src/utils.ts +0 -11
package/dist/chunks/schema.js
CHANGED
|
@@ -2,7 +2,7 @@ import { requiredSwDestPartial } from '@serwist/build/schema';
|
|
|
2
2
|
import { injectManifestOptions as injectManifestOptions$1 } from '@serwist/webpack-plugin/schema';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
const injectPartial = z.
|
|
5
|
+
const injectPartial = z.strictObject({
|
|
6
6
|
cacheOnNavigation: z.boolean().default(false),
|
|
7
7
|
disable: z.boolean().default(false),
|
|
8
8
|
register: z.boolean().default(true),
|
|
@@ -12,9 +12,13 @@ const injectPartial = z.object({
|
|
|
12
12
|
globPublicPatterns: z.array(z.string()).default([
|
|
13
13
|
"**/*"
|
|
14
14
|
])
|
|
15
|
-
})
|
|
16
|
-
const injectManifestOptions =
|
|
15
|
+
});
|
|
16
|
+
const injectManifestOptions = z.strictObject({
|
|
17
|
+
...injectManifestOptions$1.shape,
|
|
18
|
+
...requiredSwDestPartial.shape,
|
|
19
|
+
...injectPartial.shape
|
|
20
|
+
}).omit({
|
|
17
21
|
disablePrecacheManifest: true
|
|
18
|
-
})
|
|
22
|
+
});
|
|
19
23
|
|
|
20
24
|
export { injectManifestOptions as a, injectPartial as i };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAMnE;;;;GAIG;AACH,QAAA,MAAM,eAAe,GAAI,aAAa,qBAAqB,KAAG,CAAC,CAAC,UAAU,CAAC,EAAE,UAAU,KAAK,UAAU,CA8NrG,CAAC;AAEF,eAAe,eAAe,CAAC;AAC/B,OAAO,EAAE,6BAA6B,EAAE,CAAC;AACzC,YAAY,EAAE,qBAAqB,IAAI,aAAa,EAAE,6BAA6B,IAAI,qBAAqB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { getFileHash } from '@serwist/utils/node';
|
|
4
5
|
import { InjectManifest } from '@serwist/webpack-plugin';
|
|
5
6
|
import { ChildCompilationPlugin, relativeToOutputPath } from '@serwist/webpack-plugin/internal';
|
|
6
7
|
import { globSync } from 'glob';
|
|
7
|
-
import crypto from 'node:crypto';
|
|
8
8
|
import { createRequire } from 'node:module';
|
|
9
9
|
import chalk from 'chalk';
|
|
10
10
|
import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
|
|
11
|
+
import { z } from 'zod';
|
|
11
12
|
import { a as injectManifestOptions } from './chunks/schema.js';
|
|
12
13
|
import '@serwist/webpack-plugin/schema';
|
|
13
|
-
import 'zod';
|
|
14
14
|
|
|
15
15
|
const findFirstTruthy = (arr, fn)=>{
|
|
16
16
|
for (const i of arr){
|
|
@@ -22,8 +22,6 @@ const findFirstTruthy = (arr, fn)=>{
|
|
|
22
22
|
return undefined;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const getFileHash = (file)=>crypto.createHash("md5").update(fs.readFileSync(file)).digest("hex");
|
|
26
|
-
|
|
27
25
|
const getContentHash = (file, isDev)=>{
|
|
28
26
|
if (isDev) {
|
|
29
27
|
return "development";
|
|
@@ -86,19 +84,24 @@ const event = (...message)=>{
|
|
|
86
84
|
|
|
87
85
|
const validateInjectManifestOptions = (input)=>{
|
|
88
86
|
const result = injectManifestOptions.safeParse(input, {
|
|
89
|
-
|
|
87
|
+
error: validationErrorMap
|
|
90
88
|
});
|
|
91
89
|
if (!result.success) {
|
|
92
90
|
throw new SerwistConfigError({
|
|
93
91
|
moduleName: "@serwist/next",
|
|
94
|
-
message:
|
|
92
|
+
message: z.prettifyError(result.error)
|
|
95
93
|
});
|
|
96
94
|
}
|
|
97
95
|
return result.data;
|
|
98
96
|
};
|
|
99
97
|
|
|
100
98
|
const dirname = "__dirname" in globalThis ? __dirname : fileURLToPath(new URL(".", import.meta.url));
|
|
99
|
+
let warnedTurbopack = false;
|
|
101
100
|
const withSerwistInit = (userOptions)=>{
|
|
101
|
+
if (!warnedTurbopack && process.env.TURBOPACK && !userOptions.disable && !process.env.SERWIST_SUPPRESS_TURBOPACK_WARNING) {
|
|
102
|
+
warnedTurbopack = true;
|
|
103
|
+
console.warn(`[@serwist/next] WARNING: You are using '@serwist/next' with \`next dev --turbopack\`, but Serwist doesn't support Turbopack at the moment. It is recommended that you set \`disable\` to \`process.env.NODE_ENV !== \"production\"\`. Follow https://github.com/serwist/serwist/issues/54 for progress on Serwist + Turbopack. You can also suppress this warning by setting SERWIST_SUPPRESS_TURBOPACK_WARNING=1.`);
|
|
104
|
+
}
|
|
102
105
|
return (nextConfig = {})=>({
|
|
103
106
|
...nextConfig,
|
|
104
107
|
webpack (config, options) {
|
|
@@ -188,8 +191,8 @@ const withSerwistInit = (userOptions)=>{
|
|
|
188
191
|
});
|
|
189
192
|
}
|
|
190
193
|
const shouldBuildSWEntryWorker = cacheOnNavigation;
|
|
191
|
-
let swEntryPublicPath
|
|
192
|
-
let swEntryWorkerDest
|
|
194
|
+
let swEntryPublicPath;
|
|
195
|
+
let swEntryWorkerDest;
|
|
193
196
|
if (shouldBuildSWEntryWorker) {
|
|
194
197
|
const swEntryWorkerSrc = path.join(dirname, "sw-entry-worker.js");
|
|
195
198
|
const swEntryName = `swe-worker-${getContentHash(swEntryWorkerSrc, dev)}.js`;
|
|
@@ -231,7 +234,7 @@ const withSerwistInit = (userOptions)=>{
|
|
|
231
234
|
({ asset, compilation })=>{
|
|
232
235
|
const swDestRelativeOutput = relativeToOutputPath(compilation, swDest);
|
|
233
236
|
const swAsset = compilation.getAsset(swDestRelativeOutput);
|
|
234
|
-
return asset.name === swAsset?.name || asset.name.startsWith("server/") || /^[
|
|
237
|
+
return asset.name === swAsset?.name || asset.name.startsWith("server/") || /^[^/]*\.json$/.test(asset.name) || dev && !asset.name.startsWith("static/runtime/");
|
|
235
238
|
}
|
|
236
239
|
],
|
|
237
240
|
manifestTransforms: [
|
|
@@ -244,7 +247,7 @@ const withSerwistInit = (userOptions)=>{
|
|
|
244
247
|
if (m.url.startsWith(publicFilesPrefix)) {
|
|
245
248
|
m.url = path.posix.join(basePath, m.url.replace(publicFilesPrefix, ""));
|
|
246
249
|
}
|
|
247
|
-
m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D");
|
|
250
|
+
m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D").replace(/@/g, "%40");
|
|
248
251
|
return m;
|
|
249
252
|
});
|
|
250
253
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-first-truthy.d.ts","sourceRoot":"","sources":["../../src/lib/find-first-truthy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"find-first-truthy.d.ts","sourceRoot":"","sources":["../../src/lib/find-first-truthy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,+BAQhE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-content-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-content-hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"get-content-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-content-hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAG9B,eAAO,MAAM,cAAc,GAAI,MAAM,EAAE,CAAC,oBAAoB,EAAE,OAAO,OAAO,WAK3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-package-version.d.ts","sourceRoot":"","sources":["../../src/lib/get-package-version.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"get-package-version.d.ts","sourceRoot":"","sources":["../../src/lib/get-package-version.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,KAAG,MAAM,GAAG,SAMhE,CAAC"}
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { findFirstTruthy } from "./find-first-truthy.js";
|
|
2
2
|
export { getContentHash } from "./get-content-hash.js";
|
|
3
|
-
export { getFileHash } from "./get-file-hash.js";
|
|
4
3
|
export { getPackageVersion } from "./get-package-version.js";
|
|
5
4
|
export { loadTSConfig } from "./load-tsconfig.js";
|
|
6
5
|
export * as logger from "./logger.js";
|
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-tsconfig.d.ts","sourceRoot":"","sources":["../../src/lib/load-tsconfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9D,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"load-tsconfig.d.ts","sourceRoot":"","sources":["../../src/lib/load-tsconfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9D,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,sBAAsB,MAAM,GAAG,SAAS,KAAG,YAAY,GAAG,SAevG,CAAC"}
|
package/dist/lib/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAsCA,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAsCA,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,GAAG,SAAS,GAAG,EAAE,SAEtC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,GAAG,SAAS,GAAG,EAAE,SAEtC,CAAC"}
|
package/dist/lib/schema.d.ts
CHANGED
|
@@ -6,246 +6,85 @@ export declare const injectPartial: z.ZodObject<{
|
|
|
6
6
|
reloadOnOnline: z.ZodDefault<z.ZodBoolean>;
|
|
7
7
|
scope: z.ZodOptional<z.ZodString>;
|
|
8
8
|
swUrl: z.ZodDefault<z.ZodString>;
|
|
9
|
-
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
9
|
+
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
export declare const injectManifestOptions: z.ZodObject<{
|
|
12
|
+
cacheOnNavigation: z.ZodDefault<z.ZodBoolean>;
|
|
13
|
+
disable: z.ZodDefault<z.ZodBoolean>;
|
|
14
|
+
register: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
reloadOnOnline: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
17
|
+
swUrl: z.ZodDefault<z.ZodString>;
|
|
18
|
+
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
19
|
+
swDest: z.ZodString;
|
|
20
|
+
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
21
|
+
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
22
|
+
injectionPoint: z.ZodPrefault<z.ZodString>;
|
|
23
|
+
swSrc: z.ZodString;
|
|
24
|
+
chunks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>, z.ZodTransform<(args_0: any) => boolean, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>>]>>>;
|
|
26
|
+
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
include: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>, z.ZodTransform<(args_0: any) => boolean, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>>]>>>;
|
|
28
|
+
additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
29
29
|
integrity: z.ZodOptional<z.ZodString>;
|
|
30
30
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
31
|
url: z.ZodString;
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, {
|
|
37
|
-
url: string;
|
|
38
|
-
integrity?: string | undefined;
|
|
39
|
-
revision?: string | null | undefined;
|
|
40
|
-
}>]>, "many">>;
|
|
41
|
-
disablePrecacheManifest: z.ZodDefault<z.ZodBoolean>;
|
|
42
|
-
dontCacheBustURLsMatching: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>;
|
|
43
|
-
manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
|
|
32
|
+
}, z.core.$strict>]>>>;
|
|
33
|
+
dontCacheBustURLsMatching: z.ZodOptional<z.ZodCustom<RegExp, RegExp>>;
|
|
34
|
+
manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
35
|
+
size: z.ZodNumber;
|
|
44
36
|
integrity: z.ZodOptional<z.ZodString>;
|
|
45
37
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
38
|
url: z.ZodString;
|
|
47
|
-
}, {
|
|
39
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
40
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
41
|
+
size: z.ZodNumber;
|
|
42
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
43
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
url: z.ZodString;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
|
+
}, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
48
48
|
size: z.ZodNumber;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
url: string;
|
|
56
|
-
size: number;
|
|
57
|
-
integrity?: string | undefined;
|
|
58
|
-
revision?: string | null | undefined;
|
|
59
|
-
}>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{
|
|
60
|
-
manifest: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
|
|
49
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
50
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
url: z.ZodString;
|
|
52
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
53
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
54
|
+
size: z.ZodNumber;
|
|
61
55
|
integrity: z.ZodOptional<z.ZodString>;
|
|
62
56
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
57
|
url: z.ZodString;
|
|
64
|
-
},
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
60
|
+
}, z.core.$strict>>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
61
|
+
size: z.ZodNumber;
|
|
62
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
63
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
64
|
+
url: z.ZodString;
|
|
65
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
66
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
65
67
|
size: z.ZodNumber;
|
|
66
|
-
}>, "strip", z.ZodTypeAny, {
|
|
67
|
-
url: string;
|
|
68
|
-
size: number;
|
|
69
|
-
integrity?: string | undefined;
|
|
70
|
-
revision?: string | null | undefined;
|
|
71
|
-
}, {
|
|
72
|
-
url: string;
|
|
73
|
-
size: number;
|
|
74
|
-
integrity?: string | undefined;
|
|
75
|
-
revision?: string | null | undefined;
|
|
76
|
-
}>, "many">;
|
|
77
|
-
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
78
|
-
}, "strict", z.ZodTypeAny, {
|
|
79
|
-
manifest: {
|
|
80
|
-
url: string;
|
|
81
|
-
size: number;
|
|
82
|
-
integrity?: string | undefined;
|
|
83
|
-
revision?: string | null | undefined;
|
|
84
|
-
}[];
|
|
85
|
-
warnings?: string[] | undefined;
|
|
86
|
-
}, {
|
|
87
|
-
manifest: {
|
|
88
|
-
url: string;
|
|
89
|
-
size: number;
|
|
90
|
-
integrity?: string | undefined;
|
|
91
|
-
revision?: string | null | undefined;
|
|
92
|
-
}[];
|
|
93
|
-
warnings?: string[] | undefined;
|
|
94
|
-
}>>, z.ZodObject<{
|
|
95
|
-
manifest: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
|
|
96
68
|
integrity: z.ZodOptional<z.ZodString>;
|
|
97
69
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
98
70
|
url: z.ZodString;
|
|
99
|
-
},
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
|
+
}, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
74
|
+
size: z.ZodNumber;
|
|
75
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
76
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
77
|
+
url: z.ZodString;
|
|
78
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
79
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
100
80
|
size: z.ZodNumber;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
url: string;
|
|
108
|
-
size: number;
|
|
109
|
-
integrity?: string | undefined;
|
|
110
|
-
revision?: string | null | undefined;
|
|
111
|
-
}>, "many">;
|
|
112
|
-
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
113
|
-
}, "strict", z.ZodTypeAny, {
|
|
114
|
-
manifest: {
|
|
115
|
-
url: string;
|
|
116
|
-
size: number;
|
|
117
|
-
integrity?: string | undefined;
|
|
118
|
-
revision?: string | null | undefined;
|
|
119
|
-
}[];
|
|
120
|
-
warnings?: string[] | undefined;
|
|
121
|
-
}, {
|
|
122
|
-
manifest: {
|
|
123
|
-
url: string;
|
|
124
|
-
size: number;
|
|
125
|
-
integrity?: string | undefined;
|
|
126
|
-
revision?: string | null | undefined;
|
|
127
|
-
}[];
|
|
128
|
-
warnings?: string[] | undefined;
|
|
129
|
-
}>]>>, "many">>;
|
|
81
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
82
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
83
|
+
url: z.ZodString;
|
|
84
|
+
}, z.core.$strip>>;
|
|
85
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
86
|
+
}, z.core.$strict>>>>>>;
|
|
130
87
|
maximumFileSizeToCacheInBytes: z.ZodDefault<z.ZodNumber>;
|
|
131
88
|
modifyURLPrefix: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
132
|
-
},
|
|
133
|
-
chunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
134
|
-
exclude: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>]>, "many">>;
|
|
135
|
-
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
136
|
-
include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>]>, "many">>;
|
|
137
|
-
}>, {
|
|
138
|
-
injectionPoint: z.ZodDefault<z.ZodString>;
|
|
139
|
-
swSrc: z.ZodString;
|
|
140
|
-
}>, {
|
|
141
|
-
swDest: z.ZodOptional<z.ZodString>;
|
|
142
|
-
}>, {
|
|
143
|
-
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
144
|
-
swDest: z.ZodOptional<z.ZodString>;
|
|
145
|
-
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
146
|
-
}>, {
|
|
147
|
-
swDest: z.ZodString;
|
|
148
|
-
}>, {
|
|
149
|
-
cacheOnNavigation: z.ZodDefault<z.ZodBoolean>;
|
|
150
|
-
disable: z.ZodDefault<z.ZodBoolean>;
|
|
151
|
-
register: z.ZodDefault<z.ZodBoolean>;
|
|
152
|
-
reloadOnOnline: z.ZodDefault<z.ZodBoolean>;
|
|
153
|
-
scope: z.ZodOptional<z.ZodString>;
|
|
154
|
-
swUrl: z.ZodDefault<z.ZodString>;
|
|
155
|
-
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
156
|
-
}>, "disablePrecacheManifest">, "strict", z.ZodTypeAny, {
|
|
157
|
-
cacheOnNavigation: boolean;
|
|
158
|
-
disable: boolean;
|
|
159
|
-
register: boolean;
|
|
160
|
-
reloadOnOnline: boolean;
|
|
161
|
-
swUrl: string;
|
|
162
|
-
globPublicPatterns: string[];
|
|
163
|
-
maximumFileSizeToCacheInBytes: number;
|
|
164
|
-
exclude: (string | RegExp | ((args_0: any) => boolean))[];
|
|
165
|
-
injectionPoint: string;
|
|
166
|
-
swSrc: string;
|
|
167
|
-
swDest: string;
|
|
168
|
-
compileSrc: boolean;
|
|
169
|
-
scope?: string | undefined;
|
|
170
|
-
additionalPrecacheEntries?: (string | {
|
|
171
|
-
url: string;
|
|
172
|
-
integrity?: string | undefined;
|
|
173
|
-
revision?: string | null | undefined;
|
|
174
|
-
})[] | undefined;
|
|
175
|
-
dontCacheBustURLsMatching?: RegExp | undefined;
|
|
176
|
-
manifestTransforms?: ((args_0: {
|
|
177
|
-
url: string;
|
|
178
|
-
size: number;
|
|
179
|
-
integrity?: string | undefined;
|
|
180
|
-
revision?: string | null | undefined;
|
|
181
|
-
}[], args_1: unknown) => {
|
|
182
|
-
manifest: {
|
|
183
|
-
url: string;
|
|
184
|
-
size: number;
|
|
185
|
-
integrity?: string | undefined;
|
|
186
|
-
revision?: string | null | undefined;
|
|
187
|
-
}[];
|
|
188
|
-
warnings?: string[] | undefined;
|
|
189
|
-
} | Promise<{
|
|
190
|
-
manifest: {
|
|
191
|
-
url: string;
|
|
192
|
-
size: number;
|
|
193
|
-
integrity?: string | undefined;
|
|
194
|
-
revision?: string | null | undefined;
|
|
195
|
-
}[];
|
|
196
|
-
warnings?: string[] | undefined;
|
|
197
|
-
}>)[] | undefined;
|
|
198
|
-
modifyURLPrefix?: Record<string, string> | undefined;
|
|
199
|
-
chunks?: string[] | undefined;
|
|
200
|
-
excludeChunks?: string[] | undefined;
|
|
201
|
-
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
202
|
-
webpackCompilationPlugins?: any[] | undefined;
|
|
203
|
-
}, {
|
|
204
|
-
swSrc: string;
|
|
205
|
-
swDest: string;
|
|
206
|
-
cacheOnNavigation?: boolean | undefined;
|
|
207
|
-
disable?: boolean | undefined;
|
|
208
|
-
register?: boolean | undefined;
|
|
209
|
-
reloadOnOnline?: boolean | undefined;
|
|
210
|
-
scope?: string | undefined;
|
|
211
|
-
swUrl?: string | undefined;
|
|
212
|
-
globPublicPatterns?: string[] | undefined;
|
|
213
|
-
additionalPrecacheEntries?: (string | {
|
|
214
|
-
url: string;
|
|
215
|
-
integrity?: string | undefined;
|
|
216
|
-
revision?: string | null | undefined;
|
|
217
|
-
})[] | undefined;
|
|
218
|
-
dontCacheBustURLsMatching?: RegExp | undefined;
|
|
219
|
-
manifestTransforms?: ((args_0: {
|
|
220
|
-
url: string;
|
|
221
|
-
size: number;
|
|
222
|
-
integrity?: string | undefined;
|
|
223
|
-
revision?: string | null | undefined;
|
|
224
|
-
}[], args_1: unknown) => {
|
|
225
|
-
manifest: {
|
|
226
|
-
url: string;
|
|
227
|
-
size: number;
|
|
228
|
-
integrity?: string | undefined;
|
|
229
|
-
revision?: string | null | undefined;
|
|
230
|
-
}[];
|
|
231
|
-
warnings?: string[] | undefined;
|
|
232
|
-
} | Promise<{
|
|
233
|
-
manifest: {
|
|
234
|
-
url: string;
|
|
235
|
-
size: number;
|
|
236
|
-
integrity?: string | undefined;
|
|
237
|
-
revision?: string | null | undefined;
|
|
238
|
-
}[];
|
|
239
|
-
warnings?: string[] | undefined;
|
|
240
|
-
}>)[] | undefined;
|
|
241
|
-
maximumFileSizeToCacheInBytes?: number | undefined;
|
|
242
|
-
modifyURLPrefix?: Record<string, string> | undefined;
|
|
243
|
-
chunks?: string[] | undefined;
|
|
244
|
-
exclude?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
245
|
-
excludeChunks?: string[] | undefined;
|
|
246
|
-
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
247
|
-
injectionPoint?: string | undefined;
|
|
248
|
-
compileSrc?: boolean | undefined;
|
|
249
|
-
webpackCompilationPlugins?: any[] | undefined;
|
|
250
|
-
}>;
|
|
89
|
+
}, z.core.$strict>;
|
|
251
90
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/lib/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa;;;;;;;;kBAQxB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAMQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,6BAA6B,GAAI,OAAO,OAAO,KAAG,6BAQ9D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/next",
|
|
3
|
-
"version": "10.0.0-preview.
|
|
3
|
+
"version": "10.0.0-preview.10",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
5
6
|
"description": "A module that integrates Serwist into your Next.js application.",
|
|
6
7
|
"files": [
|
|
7
8
|
"src",
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
"pwa"
|
|
22
23
|
],
|
|
23
24
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
25
|
+
"node": ">=20.0.0"
|
|
25
26
|
},
|
|
26
27
|
"author": "Serwist <ducanh2912.rusty@gmail.com> (https://serwist.pages.dev/)",
|
|
27
28
|
"license": "MIT",
|
|
@@ -63,24 +64,24 @@
|
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
65
66
|
"chalk": "5.4.1",
|
|
66
|
-
"glob": "
|
|
67
|
-
"zod": "
|
|
68
|
-
"@serwist/build": "10.0.0-preview.
|
|
69
|
-
"@serwist/utils": "10.0.0-preview.
|
|
70
|
-
"@serwist/webpack-plugin": "10.0.0-preview.
|
|
71
|
-
"@serwist/window": "10.0.0-preview.
|
|
72
|
-
"serwist": "10.0.0-preview.
|
|
67
|
+
"glob": "11.0.3",
|
|
68
|
+
"zod": "4.0.5",
|
|
69
|
+
"@serwist/build": "10.0.0-preview.10",
|
|
70
|
+
"@serwist/utils": "10.0.0-preview.10",
|
|
71
|
+
"@serwist/webpack-plugin": "10.0.0-preview.10",
|
|
72
|
+
"@serwist/window": "10.0.0-preview.10",
|
|
73
|
+
"serwist": "10.0.0-preview.10"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
|
-
"@types/node": "
|
|
76
|
-
"next": "15.1
|
|
77
|
-
"react": "19.
|
|
78
|
-
"react-dom": "19.
|
|
79
|
-
"rollup": "4.
|
|
80
|
-
"type-fest": "4.
|
|
81
|
-
"typescript": "5.
|
|
82
|
-
"webpack": "5.
|
|
83
|
-
"@serwist/configs": "10.0.0-preview.
|
|
76
|
+
"@types/node": "24.0.14",
|
|
77
|
+
"next": "15.4.1",
|
|
78
|
+
"react": "19.1.0",
|
|
79
|
+
"react-dom": "19.1.0",
|
|
80
|
+
"rollup": "4.45.1",
|
|
81
|
+
"type-fest": "4.41.0",
|
|
82
|
+
"typescript": "5.8.3",
|
|
83
|
+
"webpack": "5.100.2",
|
|
84
|
+
"@serwist/configs": "10.0.0-preview.10"
|
|
84
85
|
},
|
|
85
86
|
"peerDependencies": {
|
|
86
87
|
"next": ">=14.0.0",
|
|
@@ -95,6 +96,7 @@
|
|
|
95
96
|
"build": "rimraf dist && NODE_ENV=production rollup --config rollup.config.js",
|
|
96
97
|
"dev": "rollup --config rollup.config.js --watch",
|
|
97
98
|
"lint": "biome lint ./src",
|
|
99
|
+
"qcheck": "biome check ./src",
|
|
98
100
|
"typecheck": "tsc"
|
|
99
101
|
}
|
|
100
102
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { getFileHash } from "@serwist/utils/node";
|
|
4
5
|
import { InjectManifest } from "@serwist/webpack-plugin";
|
|
5
6
|
import { ChildCompilationPlugin, relativeToOutputPath } from "@serwist/webpack-plugin/internal";
|
|
6
7
|
import { globSync } from "glob";
|
|
7
8
|
import type { NextConfig } from "next";
|
|
8
9
|
import type { Compilation, Configuration, default as Webpack } from "webpack";
|
|
9
10
|
import type { ExcludeParams, SerwistNextOptions, SerwistNextOptionsKey } from "./internal-types.js";
|
|
10
|
-
import { getContentHash,
|
|
11
|
+
import { getContentHash, loadTSConfig, logger } from "./lib/index.js";
|
|
11
12
|
import type { InjectManifestOptions, InjectManifestOptionsComplete } from "./lib/types.js";
|
|
12
13
|
import { validateInjectManifestOptions } from "./lib/validator.js";
|
|
13
14
|
|
|
14
15
|
const dirname = "__dirname" in globalThis ? __dirname : fileURLToPath(new URL(".", import.meta.url));
|
|
15
16
|
|
|
17
|
+
let warnedTurbopack = false;
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* Integrates Serwist into your Next.js app.
|
|
18
21
|
* @param userOptions
|
|
19
22
|
* @returns
|
|
20
23
|
*/
|
|
21
24
|
const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: NextConfig) => NextConfig) => {
|
|
25
|
+
if (!warnedTurbopack && process.env.TURBOPACK && !userOptions.disable && !process.env.SERWIST_SUPPRESS_TURBOPACK_WARNING) {
|
|
26
|
+
warnedTurbopack = true;
|
|
27
|
+
console.warn(
|
|
28
|
+
`[@serwist/next] WARNING: You are using '@serwist/next' with \`next dev --turbopack\`, but Serwist doesn't support Turbopack at the moment. It is recommended that you set \`disable\` to \`process.env.NODE_ENV !== \"production\"\`. Follow https://github.com/serwist/serwist/issues/54 for progress on Serwist + Turbopack. You can also suppress this warning by setting SERWIST_SUPPRESS_TURBOPACK_WARNING=1.`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
22
31
|
return (nextConfig = {}) => ({
|
|
23
32
|
...nextConfig,
|
|
24
33
|
webpack(config: Configuration, options) {
|
|
@@ -138,8 +147,8 @@ const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: Nex
|
|
|
138
147
|
}
|
|
139
148
|
|
|
140
149
|
const shouldBuildSWEntryWorker = cacheOnNavigation;
|
|
141
|
-
let swEntryPublicPath: string | undefined
|
|
142
|
-
let swEntryWorkerDest: string | undefined
|
|
150
|
+
let swEntryPublicPath: string | undefined;
|
|
151
|
+
let swEntryWorkerDest: string | undefined;
|
|
143
152
|
|
|
144
153
|
if (shouldBuildSWEntryWorker) {
|
|
145
154
|
const swEntryWorkerSrc = path.join(dirname, "sw-entry-worker.js");
|
|
@@ -198,12 +207,13 @@ const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: Nex
|
|
|
198
207
|
// This excludes all JSON files in the compilation directory by filtering
|
|
199
208
|
// out paths that have slashes or don't end with `.json`. Only said files
|
|
200
209
|
// match this criterion.
|
|
201
|
-
/^[
|
|
210
|
+
/^[^/]*\.json$/.test(asset.name) ||
|
|
202
211
|
(dev && !asset.name.startsWith("static/runtime/"))
|
|
203
212
|
);
|
|
204
213
|
},
|
|
205
214
|
],
|
|
206
215
|
manifestTransforms: [
|
|
216
|
+
// TODO(ducanhgh): move this spread to below our transform function?
|
|
207
217
|
...manifestTransforms,
|
|
208
218
|
async (manifestEntries, compilation) => {
|
|
209
219
|
// This path always uses forward slashes, so it is safe to use it in the following string replace.
|
|
@@ -219,7 +229,7 @@ const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: Nex
|
|
|
219
229
|
if (m.url.startsWith(publicFilesPrefix)) {
|
|
220
230
|
m.url = path.posix.join(basePath, m.url.replace(publicFilesPrefix, ""));
|
|
221
231
|
}
|
|
222
|
-
m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D");
|
|
232
|
+
m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D").replace(/@/g, "%40");
|
|
223
233
|
return m;
|
|
224
234
|
});
|
|
225
235
|
return { manifest, warnings: [] };
|
package/src/lib/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { findFirstTruthy } from "./find-first-truthy.js";
|
|
2
2
|
export { getContentHash } from "./get-content-hash.js";
|
|
3
|
-
export { getFileHash } from "./get-file-hash.js";
|
|
4
3
|
export { getPackageVersion } from "./get-package-version.js";
|
|
5
4
|
export { loadTSConfig } from "./load-tsconfig.js";
|
|
6
5
|
export * as logger from "./logger.js";
|
package/src/lib/schema.ts
CHANGED
|
@@ -2,20 +2,20 @@ import { requiredSwDestPartial } from "@serwist/build/schema";
|
|
|
2
2
|
import { injectManifestOptions as webpackInjectManifestOptions } from "@serwist/webpack-plugin/schema";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
|
-
export const injectPartial = z
|
|
6
|
-
.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})
|
|
15
|
-
.strict("Do not pass invalid properties to NextInjectManifestPartial!");
|
|
5
|
+
export const injectPartial = z.strictObject({
|
|
6
|
+
cacheOnNavigation: z.boolean().default(false),
|
|
7
|
+
disable: z.boolean().default(false),
|
|
8
|
+
register: z.boolean().default(true),
|
|
9
|
+
reloadOnOnline: z.boolean().default(true),
|
|
10
|
+
scope: z.string().optional(),
|
|
11
|
+
swUrl: z.string().default("/sw.js"),
|
|
12
|
+
globPublicPatterns: z.array(z.string()).default(["**/*"]),
|
|
13
|
+
});
|
|
16
14
|
|
|
17
|
-
export const injectManifestOptions =
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
export const injectManifestOptions = z
|
|
16
|
+
.strictObject({
|
|
17
|
+
...webpackInjectManifestOptions.shape,
|
|
18
|
+
...requiredSwDestPartial.shape,
|
|
19
|
+
...injectPartial.shape,
|
|
20
|
+
})
|
|
21
|
+
.omit({ disablePrecacheManifest: true });
|
package/src/lib/validator.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { SerwistConfigError, validationErrorMap } from "@serwist/build/schema";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import { injectManifestOptions } from "./schema.js";
|
|
3
4
|
import type { InjectManifestOptionsComplete } from "./types.js";
|
|
4
5
|
|
|
5
6
|
export const validateInjectManifestOptions = (input: unknown): InjectManifestOptionsComplete => {
|
|
6
7
|
const result = injectManifestOptions.safeParse(input, {
|
|
7
|
-
|
|
8
|
+
error: validationErrorMap,
|
|
8
9
|
});
|
|
9
10
|
if (!result.success) {
|
|
10
|
-
throw new SerwistConfigError({ moduleName: "@serwist/next", message:
|
|
11
|
+
throw new SerwistConfigError({ moduleName: "@serwist/next", message: z.prettifyError(result.error) });
|
|
11
12
|
}
|
|
12
13
|
return result.data;
|
|
13
14
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-file-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-file-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,eAAO,MAAM,WAAW,SAAU,EAAE,CAAC,oBAAoB,WAAyE,CAAC"}
|
package/dist/utils.d.ts
DELETED
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,eAAO,MAAM,WAAW,SAAU,EAAE,CAAC,oBAAoB,WAAyE,CAAC;AAEnI,eAAO,MAAM,cAAc,SAAU,EAAE,CAAC,oBAAoB,SAAS,OAAO,WAK3E,CAAC"}
|
package/src/lib/get-file-hash.ts
DELETED
package/src/utils.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import crypto from "node:crypto";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
|
|
4
|
-
export const getFileHash = (file: fs.PathOrFileDescriptor) => crypto.createHash("md5").update(fs.readFileSync(file)).digest("hex");
|
|
5
|
-
|
|
6
|
-
export const getContentHash = (file: fs.PathOrFileDescriptor, isDev: boolean) => {
|
|
7
|
-
if (isDev) {
|
|
8
|
-
return "development";
|
|
9
|
-
}
|
|
10
|
-
return getFileHash(file).slice(0, 16);
|
|
11
|
-
};
|