[]previous and next page

@shadow-js/dusk/vite

The 93 exports of @shadow-js/dusk/vite: 33 functions, 2 classes, 48 interfaces, 6 types and 4 consts.

Everything @shadow-js/dusk/vite exports, from the TSDoc of its entry point.

Functions#

  • applyServerEnv: Puts variables from the env files into process.env, for server code that reads process.env.NAME (the same way production does, where the platform sets them).
  • bakeServerConfig: The server part of a validated configuration, as plain JSON.
  • checkEnvFiles: Refuses a name that is declared in a public file and also in a server file: its value would be public or not depending on which file wins, so the build fails instead.
  • clientEntrySource: The generated client entry: starts the app on the server's markup.
  • compileGlob: Compiles a glob to a predicate.
  • computeAssets: Computes what the server puts in the page for each route: the entry, the stylesheets every page needs, and per route the chunks and stylesheets of its lazily loaded UI that the entry does not already bring.
  • createDuskManifest: Builds the contents of dusk-manifest.json.
  • defineConfig: Typed identity for dusk.config.ts: `export default defineConfig({ ...
  • defineFonts: The stylesheet, the variables and the preloads of the given families.
  • discoverProject: Looks for the conventional files.
  • dusk: The Vite plugins of a Dusk app, in the order they must run: 1.
  • findForbiddenEnvReads: Finds import.meta.env.NAME reads of names the browser does not get.
  • fnId: Stable id of a server function: the first 128 bits of sha256(NFC(relative path) + "#" + export name) in base64url (22 characters).
  • fontPreloadsFor: The tags to preload on one route: those of every rule whose pattern matches the path, without a tag that preloads (the ones every page loads) already has and without repeats.
  • formatFontReport: The report as a table of text, one line per file, with the totals.
  • imageVariants: The imageVariants() Vite plugin.
  • importProtection: The import protection plugin.
  • loadBuiltServer: Loads the built server entry: its handler, and the prerenderRoutes it exports (the route functions, loaded lazily).
  • loadDuskConfigFile: Loads dusk.config.(ts\|mts\|js\|mjs) from the project root with Vite's config loader, and validates it.
  • loadServerEnv: Reads the env files of a mode for server code: .env.public, .env, .env.local and their mode variants, layered as described in readEnvFiles.
  • mergeBuildOptions: The precedence of build options: a `dusk({ ...
  • prerenderFile: The file a path is written to, inside clientDir: / is index.html, /about is about/index.html.
  • prerenderTargets: Which paths to prerender from literal settings: routes with export const prerender = true and a static path, export const prerender = ["/a", "/b"], routes with export const ssr = false (their shell), and the paths given in routes.
  • publicEnvNames: The names a browser may read among the given names: the prefixed ones and the ones declared in .env.public, sorted.
  • publicPrefixes: Prefixes the user configured, validated: a prefix that is empty or very short would expose almost every variable.
  • pwa: The pwa() Vite plugin.
  • readEnvFiles: Reads the env files of a mode from a folder.
  • resolvePrerenderTargets: Every page to prerender: the literal settings of prerenderTargets, the paths that the route functions produce, and entries.
  • routeMiddlewareSource: Builds the middleware source of a scan.
  • serverEntrySource: The server entry: imports the route tree, the app and the user's handler options, registers the API routes lazily and the server functions (lazily in the dev server, from static imports in a build), and exports handler (also as default).
  • subsetFonts: Cuts the local font files of some families into slices by Unicode range, and returns the families with the slices as their files.
  • transformServerFns: Finds the server functions of a module and, for the client and server targets, rewrites it.
  • validateDuskConfig: Validates the file's default export.

Classes#

  • PrerenderError: Why a prerender failed.
  • ServerFnError: A problem in a server function, with the position in the file and a code frame.

Interfaces#

Types#

  • BuildStepName: The phases of a production build, in the order they run.
  • CacheStrategy: How a runtime rule answers a request.
  • DuskEnvShape: Env declarations as written in the file: the same plain shape defineEnv takes.
  • ServerFnIssueCode: Diagnostics of the transform.
  • SubsetFontFn: The function that cuts a font down to the characters of a string, in the shape of subset-font: the font file, the text whose glyphs stay, and the options.
  • ViteManifest: Vite's client manifest.

Constants#

  • CLIENT_ENTRY_ID: Id of the generated client entry.
  • FONT_SUBSETS: The Unicode ranges of the usual scripts, the same slices Google Fonts serves, as unicode-range values.
  • PUBLIC_ENV_PREFIX: Prefix of the variables the browser may read.
  • SERVER_ENTRY_ID: Id of the server entry module (what a user of the plugin imports or builds).