@serwist/turbopack
Version:
A module that integrates Serwist into your Next.js / Turbopack application.
96 lines (95 loc) • 3.89 kB
text/typescript
import { BasePartial, GlobPartial, InjectPartial, OptionalGlobDirectoryPartial } from "@serwist/build";
import { Prettify } from "@serwist/utils";
import { NextResponse } from "next/server.js";
import { NextConfig } from "next";
import { BuildOptions } from "esbuild";
import { BuildOptions as BuildOptions$1 } from "esbuild-wasm";
//#region src/lib/constants.d.ts
declare const SUPPORTED_ESBUILD_OPTIONS: readonly ["sourcemap", "legalComments", "sourceRoot", "sourcesContent", "format", "globalName", "target", "supported", "define", "treeShaking", "minify", "mangleProps", "reserveProps", "mangleQuoted", "mangleCache", "drop", "dropLabels", "minifyWhitespace", "minifyIdentifiers", "minifySyntax", "lineLimit", "charset", "ignoreAnnotations", "jsx", "jsxFactory", "jsxFragment", "jsxImportSource", "jsxDev", "jsxSideEffects", "pure", "keepNames", "absPaths", "color", "logLevel", "logLimit", "logOverride", "tsconfigRaw", "bundle", "splitting", "preserveSymlinks", "external", "packages", "alias", "loader", "resolveExtensions", "mainFields", "conditions", "allowOverwrite", "tsconfig", "outExtension", "publicPath", "inject", "banner", "footer", "plugins"];
//#endregion
//#region src/types.d.ts
type EsbuildSupportedOptions = (typeof SUPPORTED_ESBUILD_OPTIONS)[number];
type EsbuildWasmOptions = Prettify<any extends BuildOptions$1 ? never : Pick<BuildOptions$1, EsbuildSupportedOptions>>;
type EsbuildNativeOptions = Prettify<any extends BuildOptions ? never : Pick<BuildOptions, EsbuildSupportedOptions>>;
interface NextConfig$1 extends Pick<NextConfig, "basePath" | "distDir"> {
/**
* The Next.js `assetPrefix` config option.
*
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix
*/
assetPrefix?: string;
/**
* The Next.js `basePath` config option.
*
* @default "/"
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath
*/
basePath?: string;
/**
* The Next.js `distDir` config option.
*
* @default ".next"
* @see https://nextjs.org/docs/app/api-reference/config/next-config-js/distDir
*/
distDir?: string;
}
interface TurboPartial {
/**
* The path to your working directory.
*
* @default process.cwd()
*/
cwd?: string;
/**
* A copy of your Next.js configuration. This option has been deprecated
* and is no longer necessary, as Serwist can load the Next.js configuration
* itself. It will be removed in Serwist 10.
*
* @deprecated
*/
nextConfig?: Prettify<NextConfig$1>;
/**
* Whether to use the native `esbuild` package instead of
* `esbuild-wasm` for bundling the service worker. Defaults
* to `false` if not on Windows, `true` otherwise.
*/
useNativeEsbuild?: boolean;
/**
* Whether to automatically rebuild when source file changes
* while in development mode.
*
* @default true
*/
rebuildOnChange?: boolean;
/**
* Options to configure the esbuild instance used to bundle
* the service worker.
*/
esbuildOptions?: EsbuildNativeOptions | EsbuildWasmOptions;
}
type InjectManifestOptions = Prettify<Omit<BasePartial & GlobPartial & InjectPartial & OptionalGlobDirectoryPartial & TurboPartial, "disablePrecacheManifest">>;
//#endregion
//#region src/index.d.ts
/**
* Creates a Route Handler for Serwist files.
* @param options Options for {@linkcode getFileManifestEntries}.
*/
declare const createSerwistRoute: (options: InjectManifestOptions) => {
dynamic: "force-static";
dynamicParams: false;
revalidate: false;
generateStaticParams: () => Promise<{
path: string;
}[]>;
GET: (_: Request, {
params
}: {
params: Promise<{
path: string;
}>;
}) => Promise<NextResponse<unknown>>;
};
declare const withSerwist: (nextConfig?: NextConfig) => NextConfig;
//#endregion
export { createSerwistRoute, withSerwist };
//# sourceMappingURL=index.d.mts.map