1mod api;
42pub mod ast;
43mod compiler;
44pub mod cst;
45mod error;
46mod js;
47mod names;
48mod primitives;
49mod printing;
50mod source;
51
52pub use api::{
53 AsyncMarkupPreprocessor, AsyncTagPreprocessor, CompatibilityComponentApi, CompatibilityOptions,
54 CompileMetadata, CompileOptions, CompileResult, Compiler, CssHashGetterCallback, CssHashInput,
55 CssOutputMode, ErrorMode, ExperimentalOptions, FragmentStrategy, GenerateTarget,
56 MarkupPreprocessor, MigrateOptions, MigrateResult, ModernPrintTarget, Namespace,
57 OutputArtifact, ParseMode, ParseOptions, PreprocessAttribute, PreprocessAttributeValue,
58 PreprocessAttributes, PreprocessMarkup, PreprocessOptions, PreprocessOutput, PreprocessResult,
59 PreprocessTag, PreprocessorGroup, PrintOptions, PrintedOutput, SourceMap, TagPreprocessor,
60 VERSION, Warning, WarningFilterCallback,
61};
62pub use cst::parse_svelte;
63pub use error::{CompileError, DiagnosticKind, LineColumn, SourcePosition};
64pub use primitives::{BytePos, SourceId, Span};
65pub use source::SourceText;
66
67pub fn parse(source: &str, options: ParseOptions) -> Result<ast::Document, CompileError> {
69 compiler::phases::parse::parse_component(source, options)
70}
71
72pub fn print(ast: &ast::Document, options: PrintOptions) -> Result<PrintedOutput, CompileError> {
74 compiler::phases::transform::print_component(ast, options)
75}
76
77pub fn print_modern(
79 ast: ModernPrintTarget<'_>,
80 options: PrintOptions,
81) -> Result<PrintedOutput, CompileError> {
82 compiler::phases::transform::print_modern_target(ast, options)
83}
84
85pub fn compile(source: &str, options: CompileOptions) -> Result<CompileResult, CompileError> {
87 compiler::phases::transform::compile_component(source, options)
88}
89
90pub fn compile_module(
92 source: &str,
93 options: CompileOptions,
94) -> Result<CompileResult, CompileError> {
95 compiler::phases::transform::compile_module(source, options)
96}
97
98pub fn parse_css(source: &str) -> Result<ast::CssAst, CompileError> {
100 compiler::phases::parse::parse_css(source)
101}
102
103pub fn preprocess(
105 source: &str,
106 options: PreprocessOptions,
107) -> Result<PreprocessResult, CompileError> {
108 compiler::phases::preprocess::preprocess(source, options)
109}
110
111pub async fn preprocess_async(
113 source: &str,
114 options: PreprocessOptions,
115) -> Result<PreprocessResult, CompileError> {
116 compiler::phases::preprocess::preprocess_async(source, options).await
117}
118
119pub fn migrate(source: &str, options: MigrateOptions) -> Result<MigrateResult, CompileError> {
121 compiler::phases::migrate::migrate(source, options)
122}
123
124pub fn walk() -> ! {
126 panic!(
127 "'svelte/compiler' no longer exports a `walk` utility — please import it directly from `estree-walker` instead"
128 )
129}