Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@serwist/build

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serwist/build - npm Package Compare versions

Comparing version 9.0.0-preview.12 to 9.0.0-preview.13

dist/chunks/validationErrorMap.js

4

dist/chunks/glob.js

@@ -51,3 +51,3 @@ import { z } from 'zod';

}).strict("Do not pass invalid properties to GlobPartial!");
z.object({
const optionalGlobDirectoryPartial = z.object({
globDirectory: z.string().optional()

@@ -59,2 +59,2 @@ }).strict("Do not pass invalid properties to OptionalGlobDirectoryPartial!");

export { basePartial as b, globPartial as g, requiredGlobDirectoryPartial as r };
export { manifestTransform as a, basePartial as b, manifestTransformResult as c, globPartial as g, manifestEntry as m, optionalGlobDirectoryPartial as o, requiredGlobDirectoryPartial as r };

@@ -11,14 +11,14 @@ import { z } from 'zod';

const injectPartial = z.object({
const baseInjectPartial = z.object({
injectionPoint: z.string().default("self.__SW_MANIFEST"),
swSrc: z.string()
}).strict("Do not pass invalid properties to InjectPartial!");
const injectManifestOptions = basePartial.merge(globPartial).merge(injectPartial).merge(requiredSwDestPartial).merge(requiredGlobDirectoryPartial).strict("Do not pass invalid properties to InjectManifestOptions!");
const injectManifestOptions = basePartial.merge(globPartial).merge(baseInjectPartial).merge(requiredSwDestPartial).merge(requiredGlobDirectoryPartial).strict("Do not pass invalid properties to InjectManifestOptions!");
var injectManifest = /*#__PURE__*/Object.freeze({
__proto__: null,
injectManifestOptions: injectManifestOptions,
injectPartial: injectPartial
baseInjectPartial: baseInjectPartial,
injectManifestOptions: injectManifestOptions
});
export { injectManifest as a, injectPartial as i, optionalSwDestPartial as o, requiredSwDestPartial as r };
export { injectManifest as a, baseInjectPartial as b, injectManifestOptions as i, optionalSwDestPartial as o, requiredSwDestPartial as r };

@@ -12,5 +12,5 @@ import stringify from "fast-json-stable-stringify";

import { translateURLToSourcemapPaths } from "./lib/translate-url-to-sourcemap-paths.js";
import { validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions } from "./lib/validate-options.js";
export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringify, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions, };
import { validateGetManifestOptions, validateInjectManifestOptions } from "./lib/validate-options.js";
export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringify, transformManifest, translateURLToSourcemapPaths, validateGetManifestOptions, validateInjectManifestOptions, };
export type * from "./types.js";
//# sourceMappingURL=index.d.ts.map

@@ -10,3 +10,3 @@ import stringify from 'fast-json-stable-stringify';

import prettyBytes from 'pretty-bytes';
import { v as validationErrorMap, S as SerwistConfigError } from './chunks/serwist-config-error.js';
import { v as validationErrorMap, S as SerwistConfigError } from './chunks/validationErrorMap.js';
import { SourceMapGenerator, SourceMapConsumer } from 'source-map';

@@ -460,26 +460,2 @@ import 'zod';

};
const validateWebpackInjectManifestOptions = async (input)=>{
const result = await (await import('./chunks/webpack.js')).webpackInjectManifestOptions.spa(input, {
errorMap: validationErrorMap
});
if (!result.success) {
throw new SerwistConfigError({
moduleName: "@serwist/webpack-plugin",
message: JSON.stringify(result.error.format(), null, 2)
});
}
return result.data;
};
const validateViteInjectManifestOptions = async (input)=>{
const result = await (await import('./chunks/vite.js')).viteInjectManifestOptions.spa(input, {
errorMap: validationErrorMap
});
if (!result.success) {
throw new SerwistConfigError({
moduleName: "@serwist/vite",
message: JSON.stringify(result.error.format(), null, 2)
});
}
return result.data;
};

@@ -654,2 +630,2 @@ const getManifest = async (config)=>{

export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions };
export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, transformManifest, translateURLToSourcemapPaths, validateGetManifestOptions, validateInjectManifestOptions };

@@ -1,6 +0,4 @@

import type { GetManifestOptionsComplete, InjectManifestOptionsComplete, ViteInjectManifestOptionsComplete, WebpackInjectManifestOptionsComplete } from "../types.js";
import type { GetManifestOptionsComplete, InjectManifestOptionsComplete } from "../types.js";
export declare const validateGetManifestOptions: (input: unknown) => Promise<GetManifestOptionsComplete>;
export declare const validateInjectManifestOptions: (input: unknown) => Promise<InjectManifestOptionsComplete>;
export declare const validateWebpackInjectManifestOptions: (input: unknown) => Promise<WebpackInjectManifestOptionsComplete>;
export declare const validateViteInjectManifestOptions: (input: unknown) => Promise<ViteInjectManifestOptionsComplete>;
//# sourceMappingURL=validate-options.d.ts.map
export type Equals<T, S> = [T] extends [S] ? ([S] extends [T] ? true : false) : false;
export type Assignable<T, U> = [U] extends [T] ? true : false;
export declare function assertType<_T extends true>(): void;
//# sourceMappingURL=assertType.d.ts.map
import { z } from "zod";
export declare const injectPartial: z.ZodObject<{
export declare const baseInjectPartial: z.ZodObject<{
injectionPoint: z.ZodDefault<z.ZodString>;

@@ -132,4 +132,4 @@ swSrc: z.ZodString;

swSrc: string;
globDirectory: string;
swDest: string;
globDirectory: string;
additionalPrecacheEntries?: (string | {

@@ -167,4 +167,4 @@ revision: string | null;

swSrc: string;
globDirectory: string;
swDest: string;
globDirectory: string;
disablePrecacheManifest?: boolean | undefined;

@@ -171,0 +171,0 @@ maximumFileSizeToCacheInBytes?: number | undefined;

import type { Require } from "@serwist/utils";
import type { Pattern as GlobPattern } from "fast-glob";
import type { PackageJson } from "type-fest";

@@ -148,33 +147,2 @@ import type { z } from "zod";

export type InjectResolved = Require<InjectPartial, "injectionPoint">;
export interface WebpackPartial {
/**
* One or more chunk names whose corresponding output files should be included
* in the precache manifest.
*/
chunks?: string[];
/**
* One or more specifiers used to exclude assets from the precache manifest.
* This is interpreted following
* [the same rules](https://webpack.js.org/configuration/module/#condition)
* as webpack's standard `exclude` option.
* @default
* ```
* [/\.map$/, /^manifest.*\.js$]
* ```
*/
exclude?: (string | RegExp | ((arg0: any) => boolean))[];
/**
* One or more chunk names whose corresponding output files should be excluded
* from the precache manifest.
*/
excludeChunks?: string[];
/**
* One or more specifiers used to include assets in the precache manifest.
* This is interpreted following
* [the same rules](https://webpack.js.org/configuration/module/#condition)
* as webpack's standard `include` option.
*/
include?: (string | RegExp | ((arg0: any) => boolean))[];
}
export type WebpackResolved = Require<WebpackPartial, "exclude">;
export interface RequiredSwDestPartial {

@@ -197,107 +165,2 @@ /**

export type OptionalSwDestResolved = OptionalSwDestPartial;
export interface WebpackInjectManifestPartial {
/**
* When `true` (the default), the `swSrc` file will be compiled by webpack.
* When `false`, compilation will not occur (and `webpackCompilationPlugins`
* can't be used.) Set to `false` if you want to inject the manifest into,
* e.g., a JSON file.
* @default true
*/
compileSrc?: boolean;
/**
* Optional webpack plugins that will be used when compiling the `swSrc`
* input file. Only valid if `compileSrc` is `true`.
*/
webpackCompilationPlugins?: any[];
}
export type WebpackInjectManifestResolved = Require<WebpackInjectManifestPartial, "compileSrc">;
export interface NextInjectManifestPartial {
/**
* Enables additional route caching when users navigate through pages with
* `next/link`. This improves the user experience in some cases but it
* also adds a bit of overhead due to additional network calls.
* @default false
*/
cacheOnNavigation?: boolean;
/**
* Whether Serwist should be disabled.
* @default false
*/
disable?: boolean;
/**
* Whether `@serwist/next` should automatically register the service worker for you. If
* you want to register the service worker yourself, set this to `false` and run
* `window.serwist.register()` in `componentDidMount` or `useEffect`.
* @example
* ```tsx
* // app/register-pwa.tsx
* "use client";
* import { useEffect } from "react";
* import type { Serwist } from "@serwist/window";
*
* declare global {
* interface Window {
* serwist: Serwist;
* }
* }
*
* export default function RegisterPWA() {
* useEffect(() => {
* if ("serviceWorker" in navigator && window.serwist !== undefined) {
* window.serwist.register();
* }
* }, []);
* return <></>;
* }
*
* // app/layout.tsx
* import RegisterPWA from "./register-pwa";
*
* export default function RootLayout({
* children,
* }: {
* children: React.ReactNode;
* }) {
* return (
* <html lang="en">
* <head />
* <body>
* <RegisterPWA />
* {children}
* </body>
* </html>
* );
* }
* ```
* @default true
*/
register?: boolean;
/**
* Whether Serwist should reload the app when it goes online.
* @default true
*/
reloadOnOnline?: boolean;
/**
* The service worker's URL scope. Set to `/foo/` so that paths under `/foo/` are under the service
* worker's control while others are not.
* @default nextConfig.basePath
*/
scope?: string;
/**
* The URL to the service worker.
* @default "/sw.js"
*/
swUrl?: string;
/**
* Files in the public directory matching any of these patterns
* will be included in the precache manifest. For more information,
* see [`node-glob`'s Glob Primer](https://github.com/isaacs/node-glob#glob-primer).
* @default
* ```
* ["**\/*"]
* ```
*/
globPublicPatterns?: GlobPattern | GlobPattern[];
}
export type NextInjectManifestResolved = Require<NextInjectManifestPartial, "cacheOnNavigation" | "disable" | "register" | "reloadOnOnline" | "swUrl" | "globPublicPatterns">;
export type GetManifestOptions = BasePartial & GlobPartial & RequiredGlobDirectoryPartial;

@@ -307,8 +170,2 @@ export type GetManifestOptionsComplete = BaseResolved & GlobResolved & RequiredGlobDirectoryResolved;

export type InjectManifestOptionsComplete = BaseResolved & GlobResolved & InjectResolved & RequiredSwDestResolved & RequiredGlobDirectoryResolved;
export type WebpackInjectManifestOptions = BasePartial & WebpackPartial & InjectPartial & OptionalSwDestPartial & WebpackInjectManifestPartial;
export type WebpackInjectManifestOptionsComplete = BaseResolved & WebpackResolved & InjectResolved & OptionalSwDestResolved & WebpackInjectManifestResolved;
export type ViteInjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSwDestPartial & RequiredGlobDirectoryPartial;
export type ViteInjectManifestOptionsComplete = BaseResolved & GlobResolved & InjectResolved & RequiredSwDestResolved & RequiredGlobDirectoryResolved;
export type NextInjectManifestOptions = Omit<WebpackInjectManifestOptions & RequiredSwDestPartial & NextInjectManifestPartial, "disablePrecacheManifest">;
export type NextInjectManifestOptionsComplete = Omit<WebpackInjectManifestOptionsComplete & RequiredSwDestResolved & NextInjectManifestResolved, "disablePrecacheManifest">;
export interface GetManifestResult {

@@ -315,0 +172,0 @@ count: number;

{
"name": "@serwist/build",
"version": "9.0.0-preview.12",
"version": "9.0.0-preview.13",
"type": "module",

@@ -31,4 +31,4 @@ "description": "A module that integrates into your build process, helping you generate a manifest of local files that should be precached.",

"*": {
"next": [
"./dist/index.next.d.ts"
"schema": [
"./dist/index.schema.d.ts"
]

@@ -42,5 +42,5 @@ }

},
"./next": {
"types": "./dist/index.next.d.ts",
"default": "./dist/index.next.js"
"./schema": {
"types": "./dist/index.schema.d.ts",
"default": "./dist/index.schema.js"
},

@@ -51,3 +51,2 @@ "./package.json": "./package.json"

"common-tags": "1.8.2",
"fast-glob": "3.3.2",
"fast-json-stable-stringify": "2.1.0",

@@ -57,14 +56,7 @@ "fs-extra": "11.2.0",

"pretty-bytes": "6.1.1",
"rollup": "4.9.6",
"rollup": "4.12.0",
"source-map": "0.8.0-beta.0",
"upath": "2.0.1",
"zod": "3.22.4",
"@serwist/background-sync": "9.0.0-preview.12",
"@serwist/broadcast-update": "9.0.0-preview.12",
"@serwist/cacheable-response": "9.0.0-preview.12",
"@serwist/core": "9.0.0-preview.12",
"@serwist/expiration": "9.0.0-preview.12",
"@serwist/google-analytics": "9.0.0-preview.12",
"@serwist/precaching": "9.0.0-preview.12",
"@serwist/routing": "9.0.0-preview.12"
"@serwist/core": "9.0.0-preview.13"
},

@@ -74,8 +66,8 @@ "devDependencies": {

"@types/fs-extra": "11.0.4",
"@types/node": "20.11.16",
"@types/node": "20.11.24",
"@types/stringify-object": "4.0.5",
"type-fest": "4.10.2",
"typescript": "5.4.0-dev.20240206",
"@serwist/constants": "9.0.0-preview.12",
"@serwist/utils": "9.0.0-preview.12"
"type-fest": "4.11.0",
"typescript": "5.5.0-dev.20240304",
"@serwist/constants": "9.0.0-preview.13",
"@serwist/utils": "9.0.0-preview.13"
},

@@ -82,0 +74,0 @@ "peerDependencies": {

@@ -20,3 +20,3 @@ /*

import { translateURLToSourcemapPaths } from "./lib/translate-url-to-sourcemap-paths.js";
import { validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions } from "./lib/validate-options.js";
import { validateGetManifestOptions, validateInjectManifestOptions } from "./lib/validate-options.js";

@@ -35,7 +35,6 @@ export {

translateURLToSourcemapPaths,
validateGetManifestOptions,
validateInjectManifestOptions,
validateViteInjectManifestOptions,
validateWebpackInjectManifestOptions,
};
export type * from "./types.js";

@@ -0,1 +1,2 @@

import { SerwistConfigError } from "../schema/serwistConfigError.js";
/*

@@ -9,9 +10,3 @@ Copyright 2021 Google LLC

import { validationErrorMap } from "../schema/validationErrorMap.js";
import type {
GetManifestOptionsComplete,
InjectManifestOptionsComplete,
ViteInjectManifestOptionsComplete,
WebpackInjectManifestOptionsComplete,
} from "../types.js";
import { SerwistConfigError } from "./serwist-config-error.js";
import type { GetManifestOptionsComplete, InjectManifestOptionsComplete } from "../types.js";

@@ -33,17 +28,1 @@ export const validateGetManifestOptions = async (input: unknown): Promise<GetManifestOptionsComplete> => {

};
export const validateWebpackInjectManifestOptions = async (input: unknown): Promise<WebpackInjectManifestOptionsComplete> => {
const result = await (await import("../schema/webpack.js")).webpackInjectManifestOptions.spa(input, { errorMap: validationErrorMap });
if (!result.success) {
throw new SerwistConfigError({ moduleName: "@serwist/webpack-plugin", message: JSON.stringify(result.error.format(), null, 2) });
}
return result.data;
};
export const validateViteInjectManifestOptions = async (input: unknown): Promise<ViteInjectManifestOptionsComplete> => {
const result = await (await import("../schema/vite.js")).viteInjectManifestOptions.spa(input, { errorMap: validationErrorMap });
if (!result.success) {
throw new SerwistConfigError({ moduleName: "@serwist/vite", message: JSON.stringify(result.error.format(), null, 2) });
}
return result.data;
};
export type Equals<T, S> = [T] extends [S] ? ([S] extends [T] ? true : false) : false;
export type Assignable<T, U> = [U] extends [T] ? true : false;
export function assertType<_T extends true>() {
// Do nothing
}

@@ -8,3 +8,3 @@ import { z } from "zod";

export const injectPartial = z
export const baseInjectPartial = z
.object({

@@ -18,3 +18,3 @@ injectionPoint: z.string().default("self.__SW_MANIFEST"),

.merge(globPartial)
.merge(injectPartial)
.merge(baseInjectPartial)
.merge(requiredSwDestPartial)

@@ -24,5 +24,5 @@ .merge(requiredGlobDirectoryPartial)

assertType<Equals<InjectPartial, z.input<typeof injectPartial>>>();
assertType<Equals<InjectResolved, z.output<typeof injectPartial>>>();
assertType<Equals<InjectPartial, z.input<typeof baseInjectPartial>>>();
assertType<Equals<InjectResolved, z.output<typeof baseInjectPartial>>>();
assertType<Equals<InjectManifestOptions, z.input<typeof injectManifestOptions>>>();
assertType<Equals<InjectManifestOptionsComplete, z.output<typeof injectManifestOptions>>>();
import type { Require } from "@serwist/utils";
import type { Pattern as GlobPattern } from "fast-glob";
import type { PackageJson } from "type-fest";

@@ -164,39 +163,2 @@ import type { z } from "zod";

export interface WebpackPartial {
/**
* One or more chunk names whose corresponding output files should be included
* in the precache manifest.
*/
chunks?: string[];
// We can't use the @default annotation here to assign the value via AJV, as
// an (RegExp)[] can't be serialized into JSON.
// The default value of [/\.map$/, /^manifest.*\.js$/] will be assigned by
// the validation function, and we need to reflect that in the docs.
/**
* One or more specifiers used to exclude assets from the precache manifest.
* This is interpreted following
* [the same rules](https://webpack.js.org/configuration/module/#condition)
* as webpack's standard `exclude` option.
* @default
* ```
* [/\.map$/, /^manifest.*\.js$]
* ```
*/
exclude?: (string | RegExp | ((arg0: any) => boolean))[];
/**
* One or more chunk names whose corresponding output files should be excluded
* from the precache manifest.
*/
excludeChunks?: string[];
/**
* One or more specifiers used to include assets in the precache manifest.
* This is interpreted following
* [the same rules](https://webpack.js.org/configuration/module/#condition)
* as webpack's standard `include` option.
*/
include?: (string | RegExp | ((arg0: any) => boolean))[];
}
export type WebpackResolved = Require<WebpackPartial, "exclude">;
export interface RequiredSwDestPartial {

@@ -223,117 +185,2 @@ /**

export interface WebpackInjectManifestPartial {
/**
* When `true` (the default), the `swSrc` file will be compiled by webpack.
* When `false`, compilation will not occur (and `webpackCompilationPlugins`
* can't be used.) Set to `false` if you want to inject the manifest into,
* e.g., a JSON file.
* @default true
*/
compileSrc?: boolean;
// This can only be set if `compileSrc` is true, but that restriction can't be
// represented in TypeScript. It's enforced via custom runtime validation
// logic and needs to be documented.
/**
* Optional webpack plugins that will be used when compiling the `swSrc`
* input file. Only valid if `compileSrc` is `true`.
*/
webpackCompilationPlugins?: any[];
}
export type WebpackInjectManifestResolved = Require<WebpackInjectManifestPartial, "compileSrc">;
export interface NextInjectManifestPartial {
/**
* Enables additional route caching when users navigate through pages with
* `next/link`. This improves the user experience in some cases but it
* also adds a bit of overhead due to additional network calls.
* @default false
*/
cacheOnNavigation?: boolean;
/**
* Whether Serwist should be disabled.
* @default false
*/
disable?: boolean;
/**
* Whether `@serwist/next` should automatically register the service worker for you. If
* you want to register the service worker yourself, set this to `false` and run
* `window.serwist.register()` in `componentDidMount` or `useEffect`.
* @example
* ```tsx
* // app/register-pwa.tsx
* "use client";
* import { useEffect } from "react";
* import type { Serwist } from "@serwist/window";
*
* declare global {
* interface Window {
* serwist: Serwist;
* }
* }
*
* export default function RegisterPWA() {
* useEffect(() => {
* if ("serviceWorker" in navigator && window.serwist !== undefined) {
* window.serwist.register();
* }
* }, []);
* return <></>;
* }
*
* // app/layout.tsx
* import RegisterPWA from "./register-pwa";
*
* export default function RootLayout({
* children,
* }: {
* children: React.ReactNode;
* }) {
* return (
* <html lang="en">
* <head />
* <body>
* <RegisterPWA />
* {children}
* </body>
* </html>
* );
* }
* ```
* @default true
*/
register?: boolean;
/**
* Whether Serwist should reload the app when it goes online.
* @default true
*/
reloadOnOnline?: boolean;
/**
* The service worker's URL scope. Set to `/foo/` so that paths under `/foo/` are under the service
* worker's control while others are not.
* @default nextConfig.basePath
*/
scope?: string;
/**
* The URL to the service worker.
* @default "/sw.js"
*/
swUrl?: string;
/**
* Files in the public directory matching any of these patterns
* will be included in the precache manifest. For more information,
* see [`node-glob`'s Glob Primer](https://github.com/isaacs/node-glob#glob-primer).
* @default
* ```
* ["**\/*"]
* ```
*/
globPublicPatterns?: GlobPattern | GlobPattern[];
}
export type NextInjectManifestResolved = Require<
NextInjectManifestPartial,
"cacheOnNavigation" | "disable" | "register" | "reloadOnOnline" | "swUrl" | "globPublicPatterns"
>;
export type GetManifestOptions = BasePartial & GlobPartial & RequiredGlobDirectoryPartial;

@@ -347,24 +194,2 @@

export type WebpackInjectManifestOptions = BasePartial & WebpackPartial & InjectPartial & OptionalSwDestPartial & WebpackInjectManifestPartial;
export type WebpackInjectManifestOptionsComplete = BaseResolved &
WebpackResolved &
InjectResolved &
OptionalSwDestResolved &
WebpackInjectManifestResolved;
export type ViteInjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSwDestPartial & RequiredGlobDirectoryPartial;
export type ViteInjectManifestOptionsComplete = BaseResolved & GlobResolved & InjectResolved & RequiredSwDestResolved & RequiredGlobDirectoryResolved;
export type NextInjectManifestOptions = Omit<
WebpackInjectManifestOptions & RequiredSwDestPartial & NextInjectManifestPartial,
"disablePrecacheManifest"
>;
export type NextInjectManifestOptionsComplete = Omit<
WebpackInjectManifestOptionsComplete & RequiredSwDestResolved & NextInjectManifestResolved,
"disablePrecacheManifest"
>;
export interface GetManifestResult {

@@ -371,0 +196,0 @@ count: number;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc