Vize

Compiler Configuration Reference

For the canonical config location, see Configuration. Standalone file discovery, scopes, and analysis settings remain in the standalone reference.

Compiler Options

Pass these options as compiler inside the direct defineConfig({ ... }).withVue({ ... }) export; not every integration consumes every field.

Option Values Common use
sourceMap boolean Enable source maps in the Vite plugin
ssr boolean Compile for SSR when not relying on Vite's SSR build flag
vapor boolean Enable Vapor-mode compilation
jsxMode "vdom" or "vapor" Default output backend for .jsx/.tsx components
customRenderer boolean Treat lowercase non-HTML tags as custom renderer elements
customElements string[] Tag patterns compiled as custom elements (Tres* for TresJS)
templateSyntax "standard", "strict", or "quirks" Choose warning, error, or Vue-quirk handling for template syntax
whitespace "condense", "preserve", "vue2-line-breaks", "vue2-preserve" Template whitespace; see Whitespace
scriptExt "ts" or "js" Preserve TS output or downcompile to JS in the npm build command
mode "module" or "function" Lower-level compiler output mode
prefixIdentifiers boolean Prefix template identifiers with _ctx
hoistStatic boolean Control static node hoisting
cacheHandlers boolean Control event handler caching
comments boolean Keep template comments; unset keeps them in development only
isTs boolean Parse script blocks as TypeScript
runtimeModuleName string Override runtime import module
runtimeGlobalName string Override runtime global for function/IIFE-style output

For Vite projects, direct plugin options override shared config:

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
  compiler: {
    vapor: true,
    sourceMap: true,
    customRenderer: true,
    templateSyntax: "standard",
  },
});

Experimental Vue RFC and backend flags live under top-level experimentals; see Experimentals. Omitted keys, false, and null are off.

Whitespace

compiler.whitespace defaults to "condense". Select a mode explicitly when migrating Vue 2 templates to a Vue 3 build:

Mode Text and interpolation runs Whitespace-only runs
"condense" Collapse ASCII whitespace runs to one space. Drop leading/trailing runs and line breaks between elements; otherwise keep one space.
"preserve" Keep mixed text as written, using Vue 3 whitespace rules. Drop leading/trailing runs; keep one space between meaningful siblings.
"vue2-line-breaks" Use condense, but retain one line break after text or interpolation before the next sibling where condensing would insert a space. All other condense rules still apply. This is the narrow migration mode.
"vue2-preserve" Use Vue 2.7 whitespace: "preserve" rules: keep a contiguous text/interpolation run as written, including its leading and trailing whitespace. Drop runs at the edges of a child list; collapse runs between elements to one space.

Whitespace here means space, tab, line feed, form feed and carriage return. Non-breaking spaces are not collapsed. "vue2-preserve" also follows Vue 2's comment boundaries and removes whitespace at the end of a component's default-slot content before named <template #slot> children.

For example, "vue2-preserve" keeps both line breaks and indentation around {{ value }} in <span>\n {{ value }}\n</span>. "vue2-line-breaks" does not preserve that entire run and is not a replacement for Vue 2's preserve mode.

These options do not change the special handling of <pre> and <textarea>: the HTML first-newline rule still applies, and <pre> normalizes CRLF to LF without reflowing its content. v-pre continues to treat directives and {{ }} as literal content; it does not choose a whitespace mode.

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  compiler: { whitespace: "vue2-preserve" },
});

For Nuxt, use vize.compiler.whitespace; see migrating from Nuxt 2.

Template Syntax

compiler.templateSyntax defaults to "standard".

  • "standard" accepts recoverable invalid syntax and emits warnings. The only input it rewrites is a non-void HTML element written self-closing, such as <div /> (see below).
  • "strict" reports invalid syntax as compilation errors.
  • "quirks" preserves template syntax compatibility quirks without additional warnings.

In every mode, a component template keeps its authored element structure, as Vue's compiler builds it. Vize does not apply the browser's HTML tree construction to it: no implied end tags (<p> before a block or another <p>, <li>, <dt>, <dd>, <option>, table cells and rows), no implied <tbody> or <tr>, no repair of a nested <form>, <a> or <button>, no adoption agency for misnested formatting tags, and no foster parenting out of a <table>. So <form><form>, <a><a>, <p><ul>, <p><p>, <table><div> and <table><tr> compile as written, with every element and its handlers in place.

  • Invalid HTML nesting is reported by lint rules such as vue/permitted-contents, not by the compiler.
  • A misnested end tag, such as <b><i></b></i>, is a compile error, as it is in Vue.
  • An omitted optional end tag, such as <li>a<li>b, nests as in Vue. Vue also reports "Element is missing end tag." for it; Vize does not, and vue/html-end-tags reports it instead.
  • Standalone HTML documents keep the browser's tree.
  • Vapor (vapor: true) still applies the browser's repairs, because the browser parses its template strings again. There, a nested <form>, <p><ul>, <p><div>, <p><p> and <table><div> fail to compile, a nested <a> or <button> becomes two siblings, an omitted <li> end tag is implied, and a direct <tr> gains a <tbody>. Vue 3.6 Vapor instead splits each of these into separate templates and keeps the authored tree (#13310).

The known cases where the modes differ are:

  • v-for aliases with an unmatched edge parenthesis. Vue strips a leading ( or trailing ) from the alias before it splits value, key, and index; standard and strict modes report those aliases as malformed, while quirk mode mirrors Vue.
  • Non-void HTML elements written with self-closing syntax, such as <div /> or <span />. Standard mode warns and rewrites them as empty elements, strict mode errors, and quirk mode keeps them as self-closing leaves.
<template>
  <!-- Standard/strict reject this. Quirk mode compiles it as `item in items`. -->
  <div v-for="item in items">{{ item }}</div>

  <!-- Standard/strict reject this. Quirk mode compiles it as `item in items`. -->
  <div v-for="item in items">{{ item }}</div>

  <!-- Standard warns and rewrites this as `<div></div>`. Strict errors. Quirk keeps it as a leaf. -->
  <div />
</template>

Vue upstream implementation:

See Troubleshooting for the HTML strict-mode behavior behind invalid self-closing tags.

JSX & TSX Output Mode

For the full authoring API, scoped styles, type-checking, editor support, and limitations, see the JSX & TSX guide. This section covers only the output-mode config keys.

Vize compiles .jsx/.tsx Vue components to either Virtual DOM or Vapor output. compiler.jsxMode selects the global default for components that do not opt in explicitly; it defaults to "vdom".

// vite.config.ts
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  compiler: {
    // Default every .jsx/.tsx component to Vapor output.
    jsxMode: "vapor",
  },
});

jsxMode is independent of compiler.vapor: vapor toggles Vapor for .vue SFCs, while jsxMode controls the default backend for JSX/TSX. A project can keep SFCs on VDOM while defaulting JSX to Vapor, or vice versa. The Vite plugin also accepts jsxMode directly as a plugin option, which overrides the shared config.

Per-component directives

An individual component overrides the default with a directive prologue, mirroring "use strict":

// Compiled to Vapor regardless of the configured default.
const Fast = () => {
  "use vue:vapor";
  return <div class="fast" />;
};

// Compiled to Virtual DOM regardless of the configured default.
const Classic = () => {
  "use vue:vdom";
  return <div class="classic" />;
};

Because each component is routed independently, a single module can mix both backends:

// withVue({ compiler: { jsxMode: "vapor" } }) sets the default.

// No directive -> takes the configured default (Vapor here).
export const Dashboard = () => <main>{/* ... */}</main>;

// Opts back into Virtual DOM just for this component.
export const LegacyWidget = () => {
  "use vue:vdom";
  return <aside>{/* ... */}</aside>;
};

Precedence

The output mode for a component resolves in this order:

  1. A per-component "use vue:vapor" / "use vue:vdom" directive.
  2. The compiler.jsxMode default from config (or the plugin's jsxMode option).
  3. The built-in fallback, "vdom".

Diagnostics

A directive that begins with "use vue:" but does not name a known mode (a typo such as "use vue:vdomx") is reported as a compile error rather than silently ignored, and two conflicting mode directives in one component ("use vue:vapor" followed by "use vue:vdom") are likewise diagnosed. Unrelated prologues such as "use strict" are left untouched.

Vue Dialect

dialect selects the Vue dialect profile for standalone HTML documents (.html/.htm):

// vite.config.ts
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  dialect: "petite-vue",
});
  • "vue" treats standalone HTML documents as plain Vue-from-CDN documents.
  • "petite-vue" opts standalone HTML documents into the petite-vue dialect (v-scope/v-effect completions and petite-vue-aware IDE features).

When the key is absent, the dialect is detected structurally per document: a <script src> resolving to the petite-vue package, an inline ES import of petite-vue, or a PetiteVue.createApp call. Mentions of petite-vue in comments or prose never switch the dialect, and single-file components always use the standard Vue dialect.