@serwist/next 10.0.0-preview.1 → 10.0.0-preview.11
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 +13 -5
- 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 +20 -237
- 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 +22 -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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { requiredSwDestPartial } from '@serwist/build/schema';
|
|
1
|
+
import { requiredSwDestPartial, assertType } 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,17 @@ 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
|
+
});
|
|
23
|
+
assertType();
|
|
24
|
+
assertType();
|
|
25
|
+
assertType();
|
|
26
|
+
assertType();
|
|
19
27
|
|
|
20
28
|
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,29 @@ 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
|
-
disable: boolean;
|
|
13
|
-
register: boolean;
|
|
14
|
-
reloadOnOnline: boolean;
|
|
15
|
-
swUrl: string;
|
|
16
|
-
globPublicPatterns: string[];
|
|
17
|
-
scope?: string | undefined;
|
|
18
|
-
}, {
|
|
19
|
-
cacheOnNavigation?: boolean | undefined;
|
|
20
|
-
disable?: boolean | undefined;
|
|
21
|
-
register?: boolean | undefined;
|
|
22
|
-
reloadOnOnline?: boolean | undefined;
|
|
23
|
-
scope?: string | undefined;
|
|
24
|
-
swUrl?: string | undefined;
|
|
25
|
-
globPublicPatterns?: string[] | undefined;
|
|
26
|
-
}>;
|
|
27
|
-
export declare const injectManifestOptions: z.ZodObject<Omit<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
28
|
-
additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
29
|
-
integrity: z.ZodOptional<z.ZodString>;
|
|
30
|
-
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
-
url: z.ZodString;
|
|
32
|
-
}, "strict", z.ZodTypeAny, {
|
|
33
|
-
url: string;
|
|
34
|
-
integrity?: string | undefined;
|
|
35
|
-
revision?: string | null | undefined;
|
|
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<{
|
|
44
|
-
integrity: z.ZodOptional<z.ZodString>;
|
|
45
|
-
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
|
-
url: z.ZodString;
|
|
47
|
-
}, {
|
|
48
|
-
size: z.ZodNumber;
|
|
49
|
-
}>, "strip", z.ZodTypeAny, {
|
|
50
|
-
url: string;
|
|
51
|
-
size: number;
|
|
52
|
-
integrity?: string | undefined;
|
|
53
|
-
revision?: string | null | undefined;
|
|
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<{
|
|
61
|
-
integrity: z.ZodOptional<z.ZodString>;
|
|
62
|
-
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
|
-
url: z.ZodString;
|
|
64
|
-
}, {
|
|
65
|
-
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
|
-
integrity: z.ZodOptional<z.ZodString>;
|
|
97
|
-
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
98
|
-
url: z.ZodString;
|
|
99
|
-
}, {
|
|
100
|
-
size: z.ZodNumber;
|
|
101
|
-
}>, "strip", z.ZodTypeAny, {
|
|
102
|
-
url: string;
|
|
103
|
-
size: number;
|
|
104
|
-
integrity?: string | undefined;
|
|
105
|
-
revision?: string | null | undefined;
|
|
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">>;
|
|
130
|
-
maximumFileSizeToCacheInBytes: z.ZodDefault<z.ZodNumber>;
|
|
131
|
-
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
|
-
}>, {
|
|
9
|
+
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
export declare const injectManifestOptions: z.ZodObject<{
|
|
149
12
|
cacheOnNavigation: z.ZodDefault<z.ZodBoolean>;
|
|
150
13
|
disable: z.ZodDefault<z.ZodBoolean>;
|
|
151
14
|
register: z.ZodDefault<z.ZodBoolean>;
|
|
152
15
|
reloadOnOnline: z.ZodDefault<z.ZodBoolean>;
|
|
153
|
-
scope: z.ZodOptional<z.ZodString>;
|
|
154
16
|
swUrl: z.ZodDefault<z.ZodString>;
|
|
155
|
-
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
compileSrc:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
}>;
|
|
17
|
+
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
18
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
19
|
+
additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodType<import("@serwist/build").ManifestEntry, import("@serwist/build").ManifestEntry, z.core.$ZodTypeInternals<import("@serwist/build").ManifestEntry, import("@serwist/build").ManifestEntry>>]>>>;
|
|
20
|
+
dontCacheBustURLsMatching: z.ZodOptional<z.ZodCustom<RegExp, RegExp>>;
|
|
21
|
+
manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodType<import("@serwist/build").ManifestTransform, import("@serwist/build").ManifestTransform, z.core.$ZodTypeInternals<import("@serwist/build").ManifestTransform, import("@serwist/build").ManifestTransform>>>>;
|
|
22
|
+
maximumFileSizeToCacheInBytes: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
modifyURLPrefix: z.ZodOptional<z.ZodRecord<z.ZodString, 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.ZodType<(args_0: any) => boolean, (args_0: any) => boolean, z.core.$ZodTypeInternals<(args_0: any) => boolean, (args_0: any) => boolean>>]>>>;
|
|
26
|
+
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
include: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodType<(args_0: any) => boolean, (args_0: any) => boolean, z.core.$ZodTypeInternals<(args_0: any) => boolean, (args_0: any) => boolean>>]>>>;
|
|
28
|
+
injectionPoint: z.ZodPrefault<z.ZodString>;
|
|
29
|
+
swSrc: z.ZodString;
|
|
30
|
+
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
+
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
32
|
+
swDest: z.ZodString;
|
|
33
|
+
}, z.core.$strict>;
|
|
251
34
|
//# 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;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,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.11",
|
|
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.11",
|
|
70
|
+
"@serwist/utils": "10.0.0-preview.11",
|
|
71
|
+
"@serwist/webpack-plugin": "10.0.0-preview.11",
|
|
72
|
+
"@serwist/window": "10.0.0-preview.11",
|
|
73
|
+
"serwist": "10.0.0-preview.11"
|
|
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.11"
|
|
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
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { requiredSwDestPartial } from "@serwist/build/schema";
|
|
1
|
+
import { assertType, type Equals, requiredSwDestPartial } from "@serwist/build/schema";
|
|
2
2
|
import { injectManifestOptions as webpackInjectManifestOptions } from "@serwist/webpack-plugin/schema";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import type { InjectManifestOptions, InjectManifestOptionsComplete, InjectPartial, InjectResolved } from "./types.js";
|
|
4
5
|
|
|
5
|
-
export const injectPartial = z
|
|
6
|
-
.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
export const injectPartial = z.strictObject({
|
|
7
|
+
cacheOnNavigation: z.boolean().default(false),
|
|
8
|
+
disable: z.boolean().default(false),
|
|
9
|
+
register: z.boolean().default(true),
|
|
10
|
+
reloadOnOnline: z.boolean().default(true),
|
|
11
|
+
scope: z.string().optional(),
|
|
12
|
+
swUrl: z.string().default("/sw.js"),
|
|
13
|
+
globPublicPatterns: z.array(z.string()).default(["**/*"]),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const injectManifestOptions = z
|
|
17
|
+
.strictObject({
|
|
18
|
+
...webpackInjectManifestOptions.shape,
|
|
19
|
+
...requiredSwDestPartial.shape,
|
|
20
|
+
...injectPartial.shape,
|
|
14
21
|
})
|
|
15
|
-
.
|
|
22
|
+
.omit({ disablePrecacheManifest: true });
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.strict("Do not pass invalid properties to NextInjectManifestOptions!");
|
|
24
|
+
assertType<Equals<InjectPartial, z.input<typeof injectPartial>>>();
|
|
25
|
+
assertType<Equals<InjectResolved, z.output<typeof injectPartial>>>();
|
|
26
|
+
assertType<Equals<InjectManifestOptions, z.input<typeof injectManifestOptions>>>();
|
|
27
|
+
assertType<Equals<InjectManifestOptionsComplete, z.output<typeof injectManifestOptions>>>();
|
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
|
-
};
|