sveltejs/svelte
Configuration
Active contributors: Rich Harris, Simon H
Compile options
CompileOptions and ModuleCompileOptions are validated by packages/svelte/src/compiler/validate-options.js (~10 KB). The schemas are also documented at https://svelte.dev/docs/svelte/svelte-compiler#CompileOptions. Most-used keys:
| Option | Default | Effect |
|---|---|---|
filename |
undefined |
Used in error messages and source maps. |
generate |
'client' |
'client' or 'server'. Switches transform target. |
dev |
false |
Enables DEV-only checks ($inspect, ownership, HMR markers, etc.). |
runes |
auto-detect | Force runes vs legacy mode regardless of source. |
css |
'external' |
'external' (default) or 'injected'. Whether to emit a separate CSS file. |
cssHash |
({ hash, css }) => ... |
Function that produces the scope hash for :scope-based encapsulation. |
customElement |
false |
Compile to a Custom Element class. |
accessors |
false |
Generate get/set accessors on the component class. |
immutable |
false |
Treat object props as immutable (legacy mode optimisation). |
discloseVersion |
true |
Emit import 'svelte/internal/disclose-version' so SvelteKit can detect the package version. |
hmr |
false |
Emit HMR markers (used by vite-plugin-svelte). |
tracing |
false |
Enable $inspect.trace runtime tracking. |
legacy |
{ componentApi: false } |
Legacy compatibility toggle for the v4 component class API. |
modernAst |
false (Svelte 5) |
Returns the modern AST shape from parse() instead of the legacy v4 shape. |
Runtime flags
These are JS modules under packages/svelte/src/internal/flags/. The compiler imports them only when they're needed, so an app that doesn't use the feature pays no cost:
| Flag module | Default | Set when |
|---|---|---|
internal/flags/async.js |
false |
Component uses async rune features. Compiler emits import 'svelte/internal/flags/async'. |
internal/flags/legacy.js |
false |
Component is in legacy mode. |
internal/flags/tracing.js |
false |
Component uses $inspect.trace(...). |
Environment variables (test/dev)
| Variable | Effect |
|---|---|
SVELTE_NO_ASYNC=true |
Disables async-mode reactivity (forces async_mode_flag = false). Used by the TestNoAsync CI job. |
UPDATE_SNAPSHOTS=true |
Vitest snapshot suites write expected output instead of comparing. |
FILTER=<name> |
Drop tests not matching <name> from a suite (faster than vitest -t). |
CI=true |
Set by GitHub Actions; disables interactive prompts in some scripts. |
NODE_ENV=production |
Used by pnpm bench to mirror production deopts. |
Preprocess options
preprocess(source, transformers, options) (packages/svelte/src/compiler/preprocess/index.js):
transformers— single transformer or array. Each is{ name?, markup?, script?, style? }.options.filename— for source maps.
Top-level package metadata
packages/svelte/package.json#engines.node→>= 18. CI matrix tests 18, 20, 22, 24.packages/svelte/package.json#packageManager→ unset (declared at root:pnpm@10.4.0).
See also
- Data models — the shapes produced by the compiler.
- Compiler — what each phase actually does with these options.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.