Expand description
Vue Single File Component (.vue) compiler.
This module follows the Vue.js core structure for parsing and compilation:
parse- SFC parsing into descriptor blockscompile_script- Script/script setup compilationcompile_template- Template block compilation (DOM and Vapor)compile- Main SFC compilation orchestrationstyle- Style block compilation with scoped CSScss- Low-level CSS compilation with LightningCSS
§Example
ⓘ
use vize_atelier_sfc::{parse_sfc, compile_sfc, SfcParseOptions, SfcCompileOptions};
let source = r#"
<script setup>
import { ref } from 'vue'
const count = ref(0)
</script>
<template>
<button @click="count++">{{ count }}</button>
</template>
"#;
let descriptor = parse_sfc(source, SfcParseOptions::default()).unwrap();
let result = compile_sfc(&descriptor, SfcCompileOptions::default()).unwrap();
println!("{}", result.code);Re-exports§
pub use native_vapor::NativeVaporSfcCompilation;pub use native_vapor::NativeVaporSfcCompileError;pub use native_vapor::NativeVaporSfcCompileOptions;pub use native_vapor::NativeVaporSfcOutput;pub use native_vapor::compile_native_vapor_sfc;pub use native_vapor_setup::NativeVaporSetupSfcCompilation;pub use native_vapor_setup::NativeVaporSetupSfcCompileError;pub use native_vapor_setup::NativeVaporSetupSfcOutput;pub use native_vapor_setup::compile_native_vapor_setup_sfc;pub use bundler::BundlerCustomBlock;pub use bundler::BundlerStyleBlock;pub use bundler::SfcBlockAttribute;pub use bundler::SfcSrcInfo;pub use bundler::TemplateAssetTagRule;pub use bundler::TemplateAssetUrl;pub use bundler::collect_template_asset_urls;pub use bundler::extract_custom_blocks;pub use bundler::extract_src_info;pub use bundler::extract_style_blocks;pub use bundler::generate_bundler_scope_id;pub use bundler::has_scoped_style;pub use bundler::is_importable_asset_url;pub use bundler::strip_css_comments_for_scoped;pub use bundler::wrap_scoped_preprocessor_style;pub use compile::compile_sfc_with_vue_parser_quirks;Deprecated pub use compile::ScriptCompileResult;pub use compile::compile_sfc;pub use compile_script::props::script_setup_has_semantic_validator_candidates;pub use compile_script::props::validate_script_setup_semantics;pub use compile_script::props::validate_script_setup_semantics_located;pub use css::CssAstResult;pub use css::CssCompileOptions;pub use css::CssCompileResult;pub use css::CssTargets;pub use css::bundle_css;pub use css::compile_css;pub use css::compile_style_block;pub use css::parse_css_ast;pub use css::print_css_ast;pub use native::NativeSfcCompilation;pub use native::NativeSfcCompileError;pub use native::NativeSfcCompileOptions;pub use native::NativeSfcOutput;pub use native::compile_native_sfc;pub use native_scoped_ssr::NativeScopedSsrSfcCompilation;pub use native_scoped_ssr::NativeScopedSsrSfcCompileError;pub use native_scoped_ssr::NativeScopedSsrSfcCompileOptions;pub use native_scoped_ssr::NativeScopedSsrSfcOutput;pub use native_scoped_ssr::compile_native_scoped_ssr_sfc;pub use native_ssr::NativeSsrSfcCompilation;pub use native_ssr::NativeSsrSfcCompileError;pub use native_ssr::NativeSsrSfcCompileOptions;pub use native_ssr::NativeSsrSfcOutput;pub use native_ssr::compile_native_ssr_sfc;pub use parse::parse_sfc;pub use script::TypeResolutionBatchGuard;pub use script::begin_type_resolution_batch;pub use types::PropsDestructure;pub use types::ScriptCompileOptions;pub use types::SfcCompileExperimentalOptions;pub use types::SfcCompileOptions;pub use types::SfcCompileResult;pub use types::SfcMacroArtifact;pub use types::StyleCompileOptions;pub use types::TemplateCompileOptions;
Modules§
- bundler
- compile
- SFC compilation implementation.
- compile_
script - Script compilation for Vue SFCs.
- compile_
template - Template compilation for Vue SFCs.
- croquis
- Shared Croquis analysis for SFC consumers.
- css
- CSS compilation using LightningCSS.
- module_
shape - The shape of an emitted SFC module, so the JS plugins do not have to re-derive it by parsing that module again with oxc (#3425).
- native
- Explicit native SFC entry for bounded scriptless, setup and empty-option DOM.
- native_
scoped_ ssr - Explicit original scriptless scoped CSS and complete SSR component output.
- native_
ssr - Explicit scriptless SSR compilation retaining the once-observed whole SFC.
- native_
vapor - Explicit scriptless Vue-source SFC compilation to the pinned Vapor runtime. The once-selected original SFC/File observation survives every target refusal.
- native_
vapor_ setup - Explicit primitive setup Vue-source SFC compilation to the pinned Vapor runtime. The once-selected original SFC/File observation survives every target refusal.
- parse
- Backward-compatible SFC parser module. Preserve the public descriptor while admitting a bounded native container.
- rewrite_
default - Rewrite default export to a variable declaration.
- script
- Script block analysis and compilation.
- style
- Style block processing and scoped CSS.
- types
- SFC type definitions.
- vite_
plugin - Native request classification for the Vite plugin.
Structs§
- Binding
Metadata - Binding metadata from script setup
- Block
Location - Source location of an SFC block.
- Compiler
Error - Compiler error
- Native
Selected Setup SfcDom Compilation - The original whole Descriptor, normally owned Program and actual template File stay owned even when script or target emission refuses. This is additive; the compiler’s default/legacy entry is unchanged.
- Native
Selected SfcDom Compilation - One original SFC and the output derived only from its own complete template. Caller-paired Descriptor/File/output fields cannot construct this result.
- Native
Selected SfcDom Options - Native
Selected SfcDom Output - Native
Setup SsrSfc Compilation - The original whole descriptor, Program and completed/partial File stay owned. Maps always derive this original root; no external source pair is accepted.
- SfcCustom
Block - Custom block such as
<i18n>or<docs>. - SfcDescriptor
- Parsed result of a Vue Single File Component.
- SfcError
- SFC error/warning
- SfcParse
Options - SFC parse options.
- SfcScript
Block - Script block.
- SfcStyle
Block - Style block.
- SfcTemplate
Block - Template block.
Enums§
- Binding
Type - Binding type from script setup.
- Native
DomMode - Owns the observable runtime spelling of generated development comments. Existing emitters keep their development behavior unless explicitly selected.
- Native
Selected Setup SfcDom Error - Native
Selected SfcDom Error - Refusal never returns a partial component or falls back to legacy compilation.
- Native
Setup SsrSfc Compile Error - PadOption
- Padding option for source-map alignment.
Functions§
- compile_
native_ selected_ setup_ sfc_ dom - Observe the original SFC once; consume its same-owner setup and DOM decisions. Direct normalized Identifier/primitive literal template roots are bounded reads. One root primitive original For may repeat an attribute-free native Element with empty/static text or one bare current value-alias interpolation. A two-alias head requires one bare current key-alias interpolation and emits both original callback parameters in source order. One root If may read a direct setup BooleanLiteral binding and own one attribute-free native Element with empty/static text or one bare primitive setup interpolation in the same File scope. An adjacent original valueless Else may own another Element with the same bounded body shape. Either paired branch may also combine one original literal Text and one bare primitive setup interpolation in their authored order. One original root input may bind a bare Model Identifier to a genuine direct mutable setup declaration with primitive initial value. Its same-File Model record grants the distinct read/write receipt; ordinary reads remain read-only. Imports, wider TS, compound reads, outer handler accesses and nested/mixed-body For families remain precise lower/target refusals with no partial module.
- compile_
native_ selected_ setup_ sfc_ dom_ with_ mode - Select genuine development or production runtime comment behavior while keeping the original setup/template owner and all existing source policies. The default entry retains its development spelling and options layout.
- compile_
native_ selected_ sfc_ dom - Observe once and compile through the actual selected File’s sole L3 walk. Scripts/styles/custom/external blocks and unsupported source profiles are explicit lower refusals; target controls/aliases, runtime reads and broader events remain typed target refusals. This additive entry never changes the default compiler or existing ordinary/setup/style product contracts.
- compile_
native_ setup_ ssr_ sfc - One original JS/TS setup owner, external SSR function and full component. Bounded primitive declarations and one root primitive/Identifier interpolation beside comments or static markup, or a sole direct interpolation child of one non-void HTML root, uses Vue’s actual sixth setup-state argument. Original HTML listeners stay owned and are omitted without evaluation. A sole attribute-free input Model may read its actual direct mutable primitive setup binding; real fallthrough type/value props use the pinned server renderer’s dynamic Model rules. This SSR read adds no update handler. Adjacent root text runs, deeper/mixed children, extra roots, For/components/dynamic markup and unsupported original scripts/styles/profiles remain typed refusals with no partial module. This additive entry does not replace default compiler routing or add Vite’s SSR-context registration, HMR or upstream raw-map parity.
- compile_
template - Compile a Vue template for DOM with default options