API Reference#

Every public export of @sigx/vite, grouped by entry point and kind.

Plugin (from @sigx/vite)#

sigxPlugin#

TypeScript
export function sigxPlugin(options: SigxPluginOptions = {}): Plugin;

The main Vite plugin. Returns a Vite Plugin object with name: 'sigx' and enforce: 'pre'.

  • In dev (command === 'serve') it aliases the SignalX runtime packages — sigx, sigx/internals, sigx/jsx-runtime, sigx/jsx-dev-runtime, @sigx/reactivity, @sigx/runtime-core, @sigx/runtime-dom, @sigx/server-renderer, plus their /internals subpaths — to their src entry files so a single reactivity instance is shared. It excludes all @sigx/* packages from optimizeDeps pre-bundling — the core tier plus every @sigx/* dependency declared in the project's package.json — and sets ssr.noExternal: ['sigx', /^@sigx\//]. In middleware mode, if you have not pinned an HMR port, it assigns a free one so concurrent dev servers don't clash on Vite's default 24678.
  • In build (command === 'build') it dedupes the runtime tier, sets the same ssr.noExternal, and forces those packages into a single sigx manual chunk to preserve singleton reactivity.
  • Its transform hook injects the HMR runtime registration into any .ts/.tsx/.jsx source file (outside node_modules and /dist/) that contains a component< or component( usage, when hmr is true and in serve mode.
  • All of the above merges with (never replaces) your own optimizeDeps.exclude, ssr.noExternal, and server.hmr config.

Parameters

  • optionsSigxPluginOptions. Optional; defaults to {}.

Returns — a Vite Plugin.

default#

TypeScript
export default sigxPlugin;

The default export, an alias for sigxPlugin. Idiomatic usage:

TypeScript
import sigx from '@sigx/vite';

export default {
    plugins: [sigx()],
};

installHMRPlugin#

TypeScript
export function installHMRPlugin(): Promise<void>;

Re-exported from @sigx/vite/hmr through the main entry. Installs the browser-side SignalX HMR component plugin exactly once (guarded by an internal installed flag). It lazily imports registerComponentPlugin from sigx/internals to avoid a circular-init dependency, then registers an onDefine hook that assigns each component a stable __hmrId, re-binds live instances to the new setup/render function on reload, and tracks and cleans up instances. Auto-invoked when the HMR module loads, so manual calls are rarely needed.

ReturnsPromise<void>.

registerHMRModule#

TypeScript
export function registerHMRModule(moduleId: string): void;

Re-exported from @sigx/vite/hmr through the main entry. Injected at the top of each HMR-transformed module; it sets the current module id and resets that module's component index to 0 so component ids (moduleId:index) stay stable across re-executions. Normally injected automatically by the plugin's transform hook, not called by hand.

Parameters

  • moduleIdstring. The id of the module being registered.

Returnsvoid.

Library Builds (from @sigx/vite/lib)#

defineLibConfig#

TypeScript
export function defineLibConfig(options: LibBuildOptions): UserConfigFnObject;

Produces a Vite 8 / Rolldown library-build config function for @sigx/* packages. It normalizes the entry (string | record | LibEntry[]) into a Rolldown lib config (ES format only, file name ${entryName}.js), resolves alias paths against root (accepts a file:// URL or directory), and always prepends the SignalX runtime externals — sigx, @sigx/reactivity, @sigx/runtime-core, @sigx/runtime-dom, @sigx/server-renderer, and their subpaths — to the caller's external list (deduped) to preserve singleton reactivity.

It builds ES output only (file name ${entryName}.js), sets sourcemap (default true), minifies in place via Oxc (minify: 'oxc', or false), an optional output.banner, a node target (node18) when platform === 'node', and Oxc automatic JSX with import source sigx when jsx is true. The result is a config function (wrapped in Vite's defineConfig) that branches on --mode prod-dist:

  • Default build (vite build) emits the development dist with emptyOutDir on.
  • vite build --mode prod-dist emits a parallel production dist into the same outDir (without emptying it): process.env.NODE_ENV is defined away to 'production' so dev warnings and devtools plumbing are stripped, and every output file gets a .prod.js suffix for the package's production export condition. Run it as a second pass after the default build.

Parameters

  • optionsLibBuildOptions. Required.

Returns — a Vite UserConfigFnObject (a config function ({ mode }) => UserConfig), so the prod-dist mode branch resolves at build time.

defineConfig#

TypeScript
export { defineConfig };

A direct re-export of Vite's own defineConfig from the @sigx/vite/lib subpath, for convenience when composing custom configs alongside defineLibConfig.

Types#

SigxPluginOptions#

TypeScript
interface SigxPluginOptions {
    /**
     * Enable HMR support
     * @default true
     */
    hmr?: boolean;

    /**
     * Port for Vite's HMR websocket. Only relevant in middleware mode (the
     * standard SSR setup), where Vite's default 24678 collides when two dev
     * servers run on one machine. Unset: the plugin picks a free port
     * automatically. Explicit `server.hmr` settings always take precedence.
     */
    hmrPort?: number;
}

Options for sigxPlugin:

  • hmr — toggles HMR injection. Default true.
  • hmrPort — pins the HMR websocket port in middleware mode. When unset the plugin assigns a free port automatically; an explicit server.hmr.port (or server.hmr: false) in your Vite config wins.

Note. This interface is declared but not exported from the package — pass the options inline: sigx({ hmr: false }) or sigx({ hmrPort: 24700 }).

LibBuildOptions#

TypeScript
export interface LibBuildOptions {
    /** Single entry point or multiple entry points */
    entry: string | Record<string, string> | LibEntry[];
    /** Output directory @default 'dist' */
    outDir?: string;
    /** Enable sourcemaps @default true */
    sourcemap?: boolean;
    /** External dependencies (will not be bundled) @default [/@sigx\/.*/] */
    external?: (string | RegExp)[];
    /** Path aliases for bundling sibling packages. Keys are import paths, values are file paths relative to project root */
    alias?: Record<string, string>;
    /** Minify output in place via Oxc @default true */
    minify?: boolean;
    /** Banner to prepend to output (e.g., shebang for CLI tools) */
    banner?: string;
    /** Enable JSX transform for sigx @default false */
    jsx?: boolean;
    /** Platform target @default 'browser' */
    platform?: 'browser' | 'node' | 'neutral';
    /** The directory containing package.json (used to resolve aliases). Pass import.meta.url from your vite.config.ts */
    root?: string;
}

Options for defineLibConfig. Only entry is required; the rest use the documented defaults.

LibEntry#

TypeScript
export interface LibEntry {
    /** Entry name (becomes output filename without extension) */
    name: string;
    /** Entry file path relative to project root */
    entry: string;
}

A single named entry in the array form of LibBuildOptions.entry.

CLI#

sigx-types#

Terminal
pnpm dlx sigx-types [options]

Generates components.d.ts and components.ts for tag-named components. Exposed through the package's bin field, so npx sigx-types runs from any project with @sigx/vite installed. See the Commands guide for usage and flags.

See Also#