@serwist/build 8.4.4 → 9.0.0-preview.0
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/getManifest.js +6 -0
- package/dist/chunks/glob.js +60 -0
- package/dist/chunks/injectManifest.js +23 -0
- package/dist/chunks/serwist-config-error.js +57 -0
- package/dist/chunks/vite.js +7 -0
- package/dist/chunks/webpack.js +34 -0
- package/dist/get-manifest.d.ts +2 -1
- package/dist/get-manifest.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -813
- package/dist/index.next.d.ts +3 -0
- package/dist/index.next.d.ts.map +1 -0
- package/dist/index.next.js +35 -0
- package/dist/inject-manifest.d.ts +2 -1
- package/dist/inject-manifest.d.ts.map +1 -0
- package/dist/lib/additional-precache-entries-transform.d.ts +6 -5
- package/dist/lib/additional-precache-entries-transform.d.ts.map +1 -0
- package/dist/lib/errors.d.ts +1 -2
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/escape-regexp.d.ts +2 -1
- package/dist/lib/escape-regexp.d.ts.map +1 -0
- package/dist/lib/get-composite-details.d.ts +2 -1
- package/dist/lib/get-composite-details.d.ts.map +1 -0
- package/dist/lib/get-file-details.d.ts +2 -1
- package/dist/lib/get-file-details.d.ts.map +1 -0
- package/dist/lib/get-file-hash.d.ts +1 -0
- package/dist/lib/get-file-hash.d.ts.map +1 -0
- package/dist/lib/get-file-manifest-entries.d.ts +1 -0
- package/dist/lib/get-file-manifest-entries.d.ts.map +1 -0
- package/dist/lib/get-file-size.d.ts +1 -0
- package/dist/lib/get-file-size.d.ts.map +1 -0
- package/dist/lib/get-source-map-url.d.ts +1 -0
- package/dist/lib/get-source-map-url.d.ts.map +1 -0
- package/dist/lib/get-string-details.d.ts +1 -0
- package/dist/lib/get-string-details.d.ts.map +1 -0
- package/dist/lib/get-string-hash.d.ts +1 -0
- package/dist/lib/get-string-hash.d.ts.map +1 -0
- package/dist/lib/maximum-size-transform.d.ts +1 -0
- package/dist/lib/maximum-size-transform.d.ts.map +1 -0
- package/dist/lib/modify-url-prefix-transform.d.ts +1 -0
- package/dist/lib/modify-url-prefix-transform.d.ts.map +1 -0
- package/dist/lib/no-revision-for-urls-matching-transform.d.ts +1 -0
- package/dist/lib/no-revision-for-urls-matching-transform.d.ts.map +1 -0
- package/dist/lib/rebase-path.d.ts +1 -0
- package/dist/lib/rebase-path.d.ts.map +1 -0
- package/dist/lib/replace-and-update-source-map.d.ts +1 -0
- package/dist/lib/replace-and-update-source-map.d.ts.map +1 -0
- package/dist/lib/serwist-config-error.d.ts +7 -0
- package/dist/lib/serwist-config-error.d.ts.map +1 -0
- package/dist/lib/transform-manifest.d.ts +2 -1
- package/dist/lib/transform-manifest.d.ts.map +1 -0
- package/dist/lib/translate-url-to-sourcemap-paths.d.ts +1 -0
- package/dist/lib/translate-url-to-sourcemap-paths.d.ts.map +1 -0
- package/dist/lib/validate-next-options.d.ts +3 -0
- package/dist/lib/validate-next-options.d.ts.map +1 -0
- package/dist/lib/validate-options.d.ts +6 -8
- package/dist/lib/validate-options.d.ts.map +1 -0
- package/dist/schema/base.d.ts +169 -0
- package/dist/schema/base.d.ts.map +1 -0
- package/dist/schema/getManifest.d.ts +187 -0
- package/dist/schema/getManifest.d.ts.map +1 -0
- package/dist/schema/glob.d.ts +35 -0
- package/dist/schema/glob.d.ts.map +1 -0
- package/dist/schema/injectManifest.d.ts +206 -0
- package/dist/schema/injectManifest.d.ts.map +1 -0
- package/dist/schema/manifestEntry.d.ts +15 -0
- package/dist/schema/manifestEntry.d.ts.map +1 -0
- package/dist/schema/manifestTransform.d.ts +121 -0
- package/dist/schema/manifestTransform.d.ts.map +1 -0
- package/dist/schema/next.d.ts +243 -0
- package/dist/schema/next.d.ts.map +1 -0
- package/dist/schema/swDest.d.ts +16 -0
- package/dist/schema/swDest.d.ts.map +1 -0
- package/dist/schema/validationErrorMap.d.ts +3 -0
- package/dist/schema/validationErrorMap.d.ts.map +1 -0
- package/dist/schema/vite.d.ts +196 -0
- package/dist/schema/vite.d.ts.map +1 -0
- package/dist/schema/webpack.d.ts +231 -0
- package/dist/schema/webpack.d.ts.map +1 -0
- package/dist/types.d.ts +147 -175
- package/dist/types.d.ts.map +1 -0
- package/package.json +42 -28
- package/src/_types.js +112 -0
- package/src/get-manifest.ts +33 -0
- package/src/index.next.ts +3 -0
- package/{dist/index.d.cts → src/index.ts} +27 -2
- package/src/inject-manifest.ts +140 -0
- package/src/lib/additional-precache-entries-transform.ts +58 -0
- package/src/lib/errors.ts +99 -0
- package/src/lib/escape-regexp.ts +12 -0
- package/src/lib/get-composite-details.ts +31 -0
- package/src/lib/get-file-details.ts +68 -0
- package/src/lib/get-file-hash.ts +21 -0
- package/src/lib/get-file-manifest-entries.ts +126 -0
- package/src/lib/get-file-size.ts +23 -0
- package/src/lib/get-source-map-url.ts +17 -0
- package/src/lib/get-string-details.ts +18 -0
- package/src/lib/get-string-hash.ts +15 -0
- package/src/lib/maximum-size-transform.ts +29 -0
- package/src/lib/modify-url-prefix-transform.ts +55 -0
- package/src/lib/no-revision-for-urls-matching-transform.ts +32 -0
- package/src/lib/rebase-path.ts +22 -0
- package/src/lib/replace-and-update-source-map.ts +122 -0
- package/src/lib/serwist-config-error.ts +6 -0
- package/src/lib/transform-manifest.ts +158 -0
- package/src/lib/translate-url-to-sourcemap-paths.ts +38 -0
- package/src/lib/validate-next-options.ts +14 -0
- package/src/lib/validate-options.ts +47 -0
- package/src/schema/base.ts +16 -0
- package/src/schema/getManifest.ts +14 -0
- package/src/schema/glob.ts +41 -0
- package/src/schema/injectManifest.ts +23 -0
- package/src/schema/manifestEntry.ts +9 -0
- package/src/schema/manifestTransform.ts +15 -0
- package/src/schema/next.ts +35 -0
- package/src/schema/swDest.ts +14 -0
- package/src/schema/validationErrorMap.ts +36 -0
- package/src/schema/vite.ts +18 -0
- package/src/schema/webpack.ts +47 -0
- package/src/types.ts +407 -0
- package/dist/index.cjs +0 -1632
- package/dist/lib/cdn-utils.d.ts +0 -1
- package/dist/lib/copy-serwist-libraries.d.ts +0 -16
- package/dist/schema/index.d.ts +0 -605
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2021 Google LLC
|
|
3
|
+
|
|
4
|
+
Use of this source code is governed by an MIT-style
|
|
5
|
+
license that can be found in the LICENSE file or at
|
|
6
|
+
https://opensource.org/licenses/MIT.
|
|
7
|
+
*/
|
|
8
|
+
import { validationErrorMap } from "../schema/validationErrorMap.js";
|
|
9
|
+
import type {
|
|
10
|
+
GetManifestOptionsComplete,
|
|
11
|
+
InjectManifestOptionsComplete,
|
|
12
|
+
ViteInjectManifestOptionsComplete,
|
|
13
|
+
WebpackInjectManifestOptionsComplete,
|
|
14
|
+
} from "../types.js";
|
|
15
|
+
import { SerwistConfigError } from "./serwist-config-error.js";
|
|
16
|
+
|
|
17
|
+
export const validateGetManifestOptions = async (input: unknown): Promise<GetManifestOptionsComplete> => {
|
|
18
|
+
const result = await (await import("../schema/getManifest.js")).getManifestOptions.spa(input, { errorMap: validationErrorMap });
|
|
19
|
+
if (!result.success) {
|
|
20
|
+
throw new SerwistConfigError({ moduleName: "@serwist/build", message: JSON.stringify(result.error.format(), null, 2) });
|
|
21
|
+
}
|
|
22
|
+
return result.data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const validateInjectManifestOptions = async (input: unknown): Promise<InjectManifestOptionsComplete> => {
|
|
26
|
+
const result = await (await import("../schema/injectManifest.js")).injectManifestOptions.spa(input, { errorMap: validationErrorMap });
|
|
27
|
+
if (!result.success) {
|
|
28
|
+
throw new SerwistConfigError({ moduleName: "@serwist/build", message: JSON.stringify(result.error.format(), null, 2) });
|
|
29
|
+
}
|
|
30
|
+
return result.data;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const validateWebpackInjectManifestOptions = async (input: unknown): Promise<WebpackInjectManifestOptionsComplete> => {
|
|
34
|
+
const result = await (await import("../schema/webpack.js")).webpackInjectManifestOptions.spa(input, { errorMap: validationErrorMap });
|
|
35
|
+
if (!result.success) {
|
|
36
|
+
throw new SerwistConfigError({ moduleName: "@serwist/webpack-plugin", message: JSON.stringify(result.error.format(), null, 2) });
|
|
37
|
+
}
|
|
38
|
+
return result.data;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const validateViteInjectManifestOptions = async (input: unknown): Promise<ViteInjectManifestOptionsComplete> => {
|
|
42
|
+
const result = await (await import("../schema/vite.js")).viteInjectManifestOptions.spa(input, { errorMap: validationErrorMap });
|
|
43
|
+
if (!result.success) {
|
|
44
|
+
throw new SerwistConfigError({ moduleName: "@serwist/vite", message: JSON.stringify(result.error.format(), null, 2) });
|
|
45
|
+
}
|
|
46
|
+
return result.data;
|
|
47
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
import type { BasePartial, BaseResolved } from "../types.js";
|
|
4
|
+
import { manifestEntry } from "./manifestEntry.js";
|
|
5
|
+
import { manifestTransform } from "./manifestTransform.js";
|
|
6
|
+
|
|
7
|
+
export const basePartial = z
|
|
8
|
+
.object({
|
|
9
|
+
additionalPrecacheEntries: z.array(z.union([z.string(), manifestEntry])).optional(),
|
|
10
|
+
disablePrecacheManifest: z.boolean().default(false),
|
|
11
|
+
dontCacheBustURLsMatching: z.instanceof(RegExp).optional(),
|
|
12
|
+
manifestTransforms: z.array(manifestTransform).optional(),
|
|
13
|
+
maximumFileSizeToCacheInBytes: z.number().default(2097152),
|
|
14
|
+
modifyURLPrefix: z.record(z.string(), z.string()).optional(),
|
|
15
|
+
})
|
|
16
|
+
.strict("Do not pass invalid properties to BasePartial!") satisfies z.ZodType<BaseResolved, z.ZodObjectDef, BasePartial>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
|
|
3
|
+
import type { GetManifestOptions, GetManifestOptionsComplete } from "../types.js";
|
|
4
|
+
import { basePartial } from "./base.js";
|
|
5
|
+
import { globPartial, requiredGlobDirectoryPartial } from "./glob.js";
|
|
6
|
+
|
|
7
|
+
export const getManifestOptions = basePartial
|
|
8
|
+
.merge(globPartial)
|
|
9
|
+
.merge(requiredGlobDirectoryPartial)
|
|
10
|
+
.strict("Do not pass invalid properties to GetManifestOptions!") satisfies z.ZodType<
|
|
11
|
+
GetManifestOptionsComplete,
|
|
12
|
+
z.ZodObjectDef,
|
|
13
|
+
GetManifestOptions
|
|
14
|
+
>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type {
|
|
3
|
+
GlobPartial,
|
|
4
|
+
GlobResolved,
|
|
5
|
+
OptionalGlobDirectoryPartial,
|
|
6
|
+
OptionalGlobDirectoryResolved,
|
|
7
|
+
RequiredGlobDirectoryPartial,
|
|
8
|
+
RequiredGlobDirectoryResolved,
|
|
9
|
+
} from "../types.js";
|
|
10
|
+
|
|
11
|
+
export const globPartial = z
|
|
12
|
+
.object({
|
|
13
|
+
globFollow: z.boolean().default(true),
|
|
14
|
+
globIgnores: z.array(z.string()).default(["**/node_modules/**/*"]),
|
|
15
|
+
globPatterns: z.array(z.string()).default(["**/*.{js,css,html}"]),
|
|
16
|
+
globStrict: z.boolean().default(true),
|
|
17
|
+
templatedURLs: z.record(z.string(), z.union([z.string(), z.array(z.string())])).optional(),
|
|
18
|
+
})
|
|
19
|
+
.strict("Do not pass invalid properties to GlobPartial!") satisfies z.ZodType<GlobResolved, z.ZodObjectDef, GlobPartial>;
|
|
20
|
+
|
|
21
|
+
export const optionalGlobDirectoryPartial = z
|
|
22
|
+
.object({
|
|
23
|
+
globDirectory: z.string().optional(),
|
|
24
|
+
})
|
|
25
|
+
.strict("Do not pass invalid properties to OptionalGlobDirectoryPartial!") satisfies z.ZodType<
|
|
26
|
+
OptionalGlobDirectoryResolved,
|
|
27
|
+
z.ZodObjectDef,
|
|
28
|
+
OptionalGlobDirectoryPartial
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
// This needs to be set when using GetManifest or InjectManifest. This is
|
|
32
|
+
// enforced via runtime validation, and needs to be documented.
|
|
33
|
+
export const requiredGlobDirectoryPartial = z
|
|
34
|
+
.object({
|
|
35
|
+
globDirectory: z.string(),
|
|
36
|
+
})
|
|
37
|
+
.strict("Do not pass invalid properties to RequiredGlobDirectoryPartial!") satisfies z.ZodType<
|
|
38
|
+
RequiredGlobDirectoryResolved,
|
|
39
|
+
z.ZodObjectDef,
|
|
40
|
+
RequiredGlobDirectoryPartial
|
|
41
|
+
>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { InjectManifestOptions, InjectManifestOptionsComplete, InjectPartial, InjectResolved } from "../types.js";
|
|
3
|
+
import { basePartial } from "./base.js";
|
|
4
|
+
import { globPartial, requiredGlobDirectoryPartial } from "./glob.js";
|
|
5
|
+
import { requiredSwDestPartial } from "./swDest.js";
|
|
6
|
+
|
|
7
|
+
export const injectPartial = z
|
|
8
|
+
.object({
|
|
9
|
+
injectionPoint: z.string().default("self.__SW_MANIFEST"),
|
|
10
|
+
swSrc: z.string(),
|
|
11
|
+
})
|
|
12
|
+
.strict("Do not pass invalid properties to InjectPartial!") satisfies z.ZodType<InjectResolved, z.ZodObjectDef, InjectPartial>;
|
|
13
|
+
|
|
14
|
+
export const injectManifestOptions = basePartial
|
|
15
|
+
.merge(globPartial)
|
|
16
|
+
.merge(injectPartial)
|
|
17
|
+
.merge(requiredSwDestPartial)
|
|
18
|
+
.merge(requiredGlobDirectoryPartial)
|
|
19
|
+
.strict("Do not pass invalid properties to InjectManifestOptions!") satisfies z.ZodType<
|
|
20
|
+
InjectManifestOptionsComplete,
|
|
21
|
+
z.ZodObjectDef,
|
|
22
|
+
InjectManifestOptions
|
|
23
|
+
>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
import { manifestEntry } from "./manifestEntry.js";
|
|
4
|
+
|
|
5
|
+
export const manifestTransformResult = z
|
|
6
|
+
.object({
|
|
7
|
+
manifest: z.array(manifestEntry.merge(z.object({ size: z.number() }))),
|
|
8
|
+
warnings: z.array(z.string()).optional(),
|
|
9
|
+
})
|
|
10
|
+
.strict("Do not pass invalid properties to ManifestTransformResult!");
|
|
11
|
+
|
|
12
|
+
export const manifestTransform = z.function(
|
|
13
|
+
z.tuple([z.array(manifestEntry.merge(z.object({ size: z.number() }))), z.unknown().optional()]),
|
|
14
|
+
z.union([z.promise(manifestTransformResult), manifestTransformResult]),
|
|
15
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type {
|
|
3
|
+
NextInjectManifestOptions,
|
|
4
|
+
NextInjectManifestOptionsComplete,
|
|
5
|
+
NextInjectManifestPartial,
|
|
6
|
+
NextInjectManifestResolved,
|
|
7
|
+
} from "../types.js";
|
|
8
|
+
import { requiredSwDestPartial } from "./swDest.js";
|
|
9
|
+
import { webpackInjectManifestOptions } from "./webpack.js";
|
|
10
|
+
|
|
11
|
+
export const nextInjectManifestPartial = z
|
|
12
|
+
.object({
|
|
13
|
+
cacheOnFrontEndNav: z.boolean().default(false),
|
|
14
|
+
disable: z.boolean().default(false),
|
|
15
|
+
register: z.boolean().default(true),
|
|
16
|
+
reloadOnOnline: z.boolean().default(true),
|
|
17
|
+
scope: z.string().optional(),
|
|
18
|
+
swUrl: z.string().default("/sw.js"),
|
|
19
|
+
globPublicPatterns: z.array(z.string()).default(["**/*"]),
|
|
20
|
+
})
|
|
21
|
+
.strict("Do not pass invalid properties to NextInjectManifestPartial!") satisfies z.ZodType<
|
|
22
|
+
NextInjectManifestResolved,
|
|
23
|
+
z.ZodObjectDef,
|
|
24
|
+
NextInjectManifestPartial
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
export const nextInjectManifestOptions = webpackInjectManifestOptions
|
|
28
|
+
.merge(requiredSwDestPartial)
|
|
29
|
+
.merge(nextInjectManifestPartial)
|
|
30
|
+
.omit({ disablePrecacheManifest: true })
|
|
31
|
+
.strict("Do not pass invalid properties to NextInjectManifestOptions!") satisfies z.ZodType<
|
|
32
|
+
NextInjectManifestOptionsComplete,
|
|
33
|
+
z.ZodObjectDef,
|
|
34
|
+
NextInjectManifestOptions
|
|
35
|
+
>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { OptionalSwDestPartial, OptionalSwDestResolved, RequiredSwDestPartial, RequiredSwDestResolved } from "../types.js";
|
|
3
|
+
|
|
4
|
+
export const optionalSwDestPartial = z
|
|
5
|
+
.object({
|
|
6
|
+
swDest: z.string().optional(),
|
|
7
|
+
})
|
|
8
|
+
.strict("Do not pass invalid properties to OptionalSwDest!") satisfies z.ZodType<OptionalSwDestResolved, z.ZodObjectDef, OptionalSwDestPartial>;
|
|
9
|
+
|
|
10
|
+
export const requiredSwDestPartial = z
|
|
11
|
+
.object({
|
|
12
|
+
swDest: z.string(),
|
|
13
|
+
})
|
|
14
|
+
.strict("Do not pass invalid properties to RequiredSwDest!") satisfies z.ZodType<RequiredSwDestResolved, z.ZodObjectDef, RequiredSwDestPartial>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const validationErrorMap: z.ZodErrorMap = (error, ctx) => {
|
|
4
|
+
/*
|
|
5
|
+
This is where you override the various error codes
|
|
6
|
+
*/
|
|
7
|
+
switch (error.code) {
|
|
8
|
+
case z.ZodIssueCode.invalid_type: {
|
|
9
|
+
return { message: `${error.message ?? "Received invalid type"}: expected ${error.expected}, received ${error.received}.` };
|
|
10
|
+
}
|
|
11
|
+
case z.ZodIssueCode.invalid_literal: {
|
|
12
|
+
return { message: `${error.message ?? "Received invalid literal"}: expected ${error.expected}, received ${error.received}.` };
|
|
13
|
+
}
|
|
14
|
+
case z.ZodIssueCode.unrecognized_keys: {
|
|
15
|
+
return { message: `${error.message ?? "Received unrecognized keys"}: ${error.keys.join(",")}` };
|
|
16
|
+
}
|
|
17
|
+
case z.ZodIssueCode.invalid_arguments: {
|
|
18
|
+
return {
|
|
19
|
+
message: `${error.message ?? "Received invalid arguments"}: ${error.argumentsError.errors.map((e) => validationErrorMap(e, ctx)).join(",")}.`,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
case z.ZodIssueCode.invalid_return_type: {
|
|
23
|
+
return {
|
|
24
|
+
message: `${error.message ?? "Received invalid return type"}: ${error.returnTypeError.errors
|
|
25
|
+
.map((e) => validationErrorMap(e, ctx))
|
|
26
|
+
.join(",")}.`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
case z.ZodIssueCode.custom: {
|
|
30
|
+
return { message: error.message ?? ctx.defaultError };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Fallback to the default message.
|
|
35
|
+
return { message: ctx.defaultError };
|
|
36
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { ViteInjectManifestOptions, ViteInjectManifestOptionsComplete } from "../types.js";
|
|
3
|
+
import { basePartial } from "./base.js";
|
|
4
|
+
import { globPartial } from "./glob.js";
|
|
5
|
+
import { requiredGlobDirectoryPartial } from "./glob.js";
|
|
6
|
+
import { injectPartial } from "./injectManifest.js";
|
|
7
|
+
import { requiredSwDestPartial } from "./swDest.js";
|
|
8
|
+
|
|
9
|
+
export const viteInjectManifestOptions = basePartial
|
|
10
|
+
.merge(globPartial)
|
|
11
|
+
.merge(injectPartial)
|
|
12
|
+
.merge(requiredSwDestPartial)
|
|
13
|
+
.merge(requiredGlobDirectoryPartial)
|
|
14
|
+
.strict("Do not pass invalid properties to ViteInjectManifestPartial!") satisfies z.ZodType<
|
|
15
|
+
ViteInjectManifestOptionsComplete,
|
|
16
|
+
z.ZodObjectDef,
|
|
17
|
+
ViteInjectManifestOptions
|
|
18
|
+
>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type {
|
|
3
|
+
WebpackInjectManifestOptions,
|
|
4
|
+
WebpackInjectManifestOptionsComplete,
|
|
5
|
+
WebpackInjectManifestPartial,
|
|
6
|
+
WebpackInjectManifestResolved,
|
|
7
|
+
WebpackPartial,
|
|
8
|
+
WebpackResolved,
|
|
9
|
+
} from "../types.js";
|
|
10
|
+
import { basePartial } from "./base.js";
|
|
11
|
+
import { injectPartial } from "./injectManifest.js";
|
|
12
|
+
import { optionalSwDestPartial } from "./swDest.js";
|
|
13
|
+
|
|
14
|
+
export const webpackPartial = z
|
|
15
|
+
.object({
|
|
16
|
+
chunks: z.array(z.string()).optional(),
|
|
17
|
+
exclude: z
|
|
18
|
+
.array(z.union([z.string(), z.instanceof(RegExp), z.function(z.tuple([z.any()]), z.boolean())]))
|
|
19
|
+
.default([/\.map$/, /^manifest.*\.js$/]),
|
|
20
|
+
excludeChunks: z.array(z.string()).optional(),
|
|
21
|
+
include: z.array(z.union([z.string(), z.instanceof(RegExp), z.function(z.tuple([z.any()]), z.boolean())])).optional(),
|
|
22
|
+
mode: z.string().nullable().optional(),
|
|
23
|
+
})
|
|
24
|
+
.strict("Do not pass invalid properties to WebpackPartial!") satisfies z.ZodType<WebpackResolved, z.ZodObjectDef, WebpackPartial>;
|
|
25
|
+
|
|
26
|
+
export const webpackInjectManifestPartial = z
|
|
27
|
+
.object({
|
|
28
|
+
compileSrc: z.boolean().default(true),
|
|
29
|
+
swDest: z.string().optional(),
|
|
30
|
+
webpackCompilationPlugins: z.array(z.any()).optional(),
|
|
31
|
+
})
|
|
32
|
+
.strict("Do not pass invalid properties to WebpackInjectManifestPartial!") satisfies z.ZodType<
|
|
33
|
+
WebpackInjectManifestResolved,
|
|
34
|
+
z.ZodObjectDef,
|
|
35
|
+
WebpackInjectManifestPartial
|
|
36
|
+
>;
|
|
37
|
+
|
|
38
|
+
export const webpackInjectManifestOptions = basePartial
|
|
39
|
+
.merge(webpackPartial)
|
|
40
|
+
.merge(injectPartial)
|
|
41
|
+
.merge(optionalSwDestPartial)
|
|
42
|
+
.merge(webpackInjectManifestPartial)
|
|
43
|
+
.strict("Do not pass invalid properties to WebpackInjectManifestOptions!") satisfies z.ZodType<
|
|
44
|
+
WebpackInjectManifestOptionsComplete,
|
|
45
|
+
z.ZodObjectDef,
|
|
46
|
+
WebpackInjectManifestOptions
|
|
47
|
+
>;
|