sveltekit_shim_app_env_vars.ts

view source

Declarations
#

5 declarations

load_sveltekit_env_declarations
#

sveltekit_shim_app_env_vars.ts view source

(entry_id: string, fresh?: boolean): Promise<EnvVarDeclarations> import {load_sveltekit_env_declarations} from '@fuzdev/gro/sveltekit_shim_app_env_vars.js';

Imports the variables declared in a project's env entry module. The shims render static exports, so the declared names are needed before rendering - the values aren't, those resolve when the rendered module runs.

entry_id

the env entry module

type string

fresh

re-import the entry when it has changed on disk, for long-lived processes that rebuild, at the cost of a new module instance per change

type boolean
default false

returns

Promise<EnvVarDeclarations>

throws

  • if - the entry doesn't export a `variables` object, or declares an invalid name

render_sveltekit_shim_app_env_vars
#

sveltekit_shim_app_env_vars.ts view source

({ visibility, variables, entry_specifier, env_module_specifier, dev, env_dir, env_files, ambient_env }: RenderSveltekitShimAppEnvVarsOptions): string import {render_sveltekit_shim_app_env_vars} from '@fuzdev/gro/sveltekit_shim_app_env_vars.js';

Generates a module shim for SvelteKit's $app/env/public and $app/env/private. Values resolve when the module runs, validated against the declarations, so unlike SvelteKit's build, static vars aren't inlined - a bundled server reads them from its env files and ambient env at startup, and imports the declarations module and Gro's env module at runtime.

__0

returns

string

RenderSveltekitShimAppEnvVarsOptions
#

sveltekit_shim_app_env_vars.ts view source

RenderSveltekitShimAppEnvVarsOptions import type {RenderSveltekitShimAppEnvVarsOptions} from '@fuzdev/gro/sveltekit_shim_app_env_vars.js';

visibility

type EnvVisibility

variables

The declarations from load_sveltekit_env_declarations, null if the project has none.

type EnvVarDeclarations | null

entry_specifier

How the rendered module imports the env entry - a file URL for Node, a path for esbuild.

type string | null

env_module_specifier?

How the rendered module imports Gro's env module.

type string

default `'@fuzdev/gro/env.js'`

dev

type boolean

env_dir?

type string

env_files?

type string[]

ambient_env?

type Record<string, string | undefined>

resolve_sveltekit_env_entry
#

sveltekit_shim_app_env_vars.ts view source

(src_path: string, dir?: string): string | null import {resolve_sveltekit_env_entry} from '@fuzdev/gro/sveltekit_shim_app_env_vars.js';

The project's env var declarations module, like src/env.ts, if it has one. SvelteKit has no env vars without one, so neither does the shim.

src_path

the SvelteKit files.src, relative to dir

type string

dir

the project directory

type string
default process.cwd()

returns

string | null

SVELTEKIT_APP_ENV_VARS_MATCHER
#

Depends on
#

Imported by
#