API Reference
Every public export of @sigx/vite, grouped by entry point and kind.
Plugin (from @sigx/vite)
sigxPlugin
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/internalssubpaths — to theirsrcentry files so a single reactivity instance is shared. It excludes all@sigx/*packages fromoptimizeDepspre-bundling — the core tier plus every@sigx/*dependency declared in the project'spackage.json— and setsssr.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 default24678. - In build (
command === 'build') it dedupes the runtime tier, sets the samessr.noExternal, and forces those packages into a singlesigxmanual chunk to preserve singleton reactivity. - Its
transformhook injects the HMR runtime registration into any.ts/.tsx/.jsxsource file (outsidenode_modulesand/dist/) that contains acomponent<orcomponent(usage, whenhmristrueand in serve mode. - All of the above merges with (never replaces) your own
optimizeDeps.exclude,ssr.noExternal, andserver.hmrconfig.
Parameters
options—SigxPluginOptions. Optional; defaults to{}.
Returns — a Vite Plugin.
default
export default sigxPlugin;
The default export, an alias for sigxPlugin. Idiomatic usage:
import sigx from '@sigx/vite';
export default {
plugins: [sigx()],
};
installHMRPlugin
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.
Returns — Promise<void>.
registerHMRModule
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
moduleId—string. The id of the module being registered.
Returns — void.
Library Builds (from @sigx/vite/lib)
defineLibConfig
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 withemptyOutDiron. vite build --mode prod-distemits a parallel production dist into the sameoutDir(without emptying it):process.env.NODE_ENVis defined away to'production'so dev warnings and devtools plumbing are stripped, and every output file gets a.prod.jssuffix for the package'sproductionexport condition. Run it as a second pass after the default build.
Parameters
options—LibBuildOptions. Required.
Returns — a Vite UserConfigFnObject (a config function ({ mode }) => UserConfig), so the prod-dist mode branch resolves at build time.
defineConfig
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
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(orserver.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 })orsigx({ hmrPort: 24700 }).
LibBuildOptions
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
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
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.
