sveltekit_shim_app_env_vars.ts

view source

Declarations
#

6 declarations

load_sveltekit_env_declarations
#

sveltekit_shim_app_env_vars.ts view source

(entry_id: string): 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 declarations module, from resolve_sveltekit_env_entry

type string

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, entry, env_module_specifier, fs_module_specifier, fs_paths_module_specifier, process_module_specifier, dev, env_dir }: 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 - the module reads them from the env files and ambient env, importing the declarations module and Gro's env module. The rendered module is the composition root of that read: it imports the fs host module and builds the FsPaths the env files are read through, and it imports the process host module for the ambient env, so $app/env/* shows its fs and env reach in its imports, while the shim's rendering, in the loader's hooks, never loads a host module.

__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';

dev and env_dir are rendered into the module, which loads the env when it runs.

inheritance

extends: Pick< LoadEnvOptions, 'dev' | 'env_dir' >

visibility

type EnvVisibility

entry

The project's env declarations module, null if it has none.

type SveltekitEnvEntry | null

env_module_specifier

How the rendered module imports Gro's env module, a file URL.

type string

fs_module_specifier

How the rendered module imports Gro's fs host module, a file URL.

type string

fs_paths_module_specifier

How the rendered module imports Gro's fs_paths module, a file URL.

type string

process_module_specifier

How the rendered module imports Gro's process host module, a file URL.

type string

resolve_sveltekit_env_entry
#

sveltekit_shim_app_env_vars.ts view source

(src_path: 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 the cwd

type string

returns

string | null

SVELTEKIT_APP_ENV_VARS_MATCHER
#

SveltekitEnvEntry
#

Depends on
#

Imported by
#