TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sveltejs/svelte/llms.txt
Use this file to discover all available pages before exploring further.
compile() function converts your .svelte source code into a JavaScript module that exports a component.
Signature
Parameters
The component source code
Compiler options. See Compiler Options for details.
Return Value
Returns aCompileResult object with the following properties:
Array of warning objects generated during compilation. Each warning has:
code: A string identifying the category of warningmessage: Human-readable descriptionstartandend: Location objects withline,column, andcharacterproperties (if applicable)
Metadata about the compiled component
Whether the file was compiled in runes mode, either because of an explicit option or inferred from usage
The abstract syntax tree of the component
Usage Examples
Basic Usage
With Vite Plugin
With Rollup
Server-Side Rendering
Custom Element
Related
- Compiler Options - Full list of compiler options
- preprocess() - Transform component source before compilation
- migrate() - Migrate Svelte 4 code to Svelte 5