Skip to content

← All changelogs

@typestyles/vite

packages/vite/CHANGELOG.md

0.9.0

Minor Changes

  • #350 3b624ad Thanks @dbanksdesign! - Extraction now resolves like the host bundler. runTypestylesExtract / runTypestylesBuild accept conditions and alias (passed to esbuild), and @typestyles/vite forwards the resolved config's custom resolve.conditions (SSR ones first) and string aliases. Hosts without custom resolution behave as before.

Patch Changes

0.8.0

Minor Changes

  • #338 54535af Thanks @dbanksdesign! - Add real CSS source maps for extracted CSS. Enable with extract.sourceMap: true in @typestyles/vite. Each extracted rule is mapped back to the recipe() / style() call site via a VLQ source map emitted as a companion .css.map asset, referenced by a /*# sourceMappingURL=... */ comment. The dev server also serves the map so the same mappings are available during development. The shared @typestyles/build-runner extraction pipeline now captures per-rule source locations and generates the map, and typestyles exposes getRegisteredCssForSourceMap() for consumers that need the raw mapping data. This complements extract.sourceComments and typestyles/inspect with a standard, tool-friendly source map.

Patch Changes

  • #336 9793af7 Thanks @dbanksdesign! - Add dev-only inspection helpers for runtime style debugging. The new typestyles/inspect entry point exports inspect(className), inspectClassList(classNames), and inspectElement(element), and registers window.__TYPESTYLES_INSPECT__ for console use. In attribute mode, opt in to data-ts-source attributes by setting globalThis.__TYPESTYLES_DEV_INSPECT__ = true (or { root } to relativize paths). This complements the existing extract.sourceComments option, which covers extracted CSS, by addressing the runtime injection path where CSSStyleSheet.insertRule strips comments. The Vite plugin now auto-imports typestyles/inspect in dev so the global is available without manual imports.
  • Updated dependencies [54535af]:

0.7.1

Patch Changes

0.7.0

Minor Changes

  • #310 ad6fe59 Thanks @dbanksdesign! - Add an experimental compile-time transform (compile: true) for zero-runtime client bundles.

    Extraction now records a small JSON plan per recipe() — base classes, slots, dimensions and defaults, i.e. everything a call needs — in the same Node run that produces the CSS (runTypestylesExtract returns { css, plans }; runTypestylesBuild is unchanged). With compile: true, the Vite, Rollup, esbuild (and Bun), and webpack (and Rspack) integrations replace recipe({ name, ... }) definitions in client bundles with createAttrsRecipeFromPlan(<plan>) from the new typestyles/lite entry (under 1 KB gzipped), and mark calls of style factories imported from typestyles (createTypeStyles, createStyles, createTokens, createGlobal) as pure. The style configs, token tables and CSS machinery they referenced then tree-shake away. Class names, data-* attributes and the emitted CSS are unchanged.

    Plans cover attribute-mode dimensioned and slot recipes, flat and multi-slot recipes, and the class-name modes (semantic, bem, template, hashed, compact, atomic) for dimensioned recipes (with compound variants) plus slot recipes in semantic/bem/template. Parity with the real runtime is tested across a grid of selections. Calls that can't be planned (non-literal names, spreads in the recipe config, a name used in more than one scope, themes/tokens whose results are read at runtime, recipes in unsupported shapes) keep the runtime, and the Vite and Rollup integrations warn when a substantial part of it remains.

    On var-ui's bundle fixtures this removes about 80–105 KB of minified JS (button-only 312.7 → 230.2 KB, form-kit 457.9 → 367.3 KB, date-kit 512.9 → 421.7 KB).

    @typestyles/vite returns two plugins when compile: true (the transform must run after Vite's own TypeScript transform); otherwise it still returns a single plugin. Rewritten modules keep accurate source maps, still go through duplicate-namespace checks, and are re-transformed in watch mode and with webpack's cache so plans never go stale. Plans are only recorded while extraction runs (getClientPlans() is empty in normal runtime builds), and extraction now returns its result through a temp file, so style modules that log to stdout no longer affect it. @typestyles/build-runner gains the shared transform (transformRecipeCalls, indexPlans, …) and acorn, magic-string and @jridgewell/remapping dependencies.

  • #307 429d477 Thanks @dbanksdesign! - Zero-runtime client builds now ship no CSS insertion runtime — for every typestyles entry point.

    typestyles publishes its stylesheet module (dist/sheet.js) next to a no-op sibling (dist/sheet-noop.js) that exports the same API but does nothing. Every other module reaches the sheet through that one file, so in mode: 'build' the bundler integrations just redirect it in client bundles. The stylesheet state, CSSOM/DOM plumbing, insertion registry and dev-time collision bookkeeping never enter the module graph, while class names and data attributes are computed identically.

    • One module graph, one registry: typestyles, typestyles/css, typestyles/color, … are all covered, with nothing to import differently and no specifier rewriting.
    • @typestyles/vite (and @typestyles/astro) and @typestyles/rollup: resolveId hook (client builds only for Vite). @typestyles/esbuild: onResolve hook (skipped for platform: 'node'). @typestyles/webpack and @typestyles/next/build: module-factory hook (non-node targets / client bundles only; server bundles keep the real runtime for SSR collection).
    • mode: 'runtime' / 'hybrid', development builds, and server/SSR/node builds keep the full runtime.
    • Vite, Rollup and webpack warn at build time if the real sheet still ends up in a zero-runtime client bundle.
    • Development diagnostics (namespace/class-name collision tracking) are gated behind the sheet, so they are absent from zero-runtime bundles.
    • @typestyles/build-runner exports toZeroRuntimeSheetId, isSheetRequest, findRealSheetModules, zeroRuntimeLeakMessage and ZeroRuntimeSheetWebpackPlugin for custom integrations.
    • The package also declares a conservative sideEffects allowlist (hmr, server, build, testing).

Patch Changes

0.6.0

Minor Changes

  • #306 6b862ab Thanks @dbanksdesign! - Add opt-in extract.sourceComments to precede each extracted CSS rule with a /* path:line */ comment naming the recipe() / style() call that registered it. @typestyles/vite passes the option through to the extract; paths are relative to the project root. Runtime injection is unchanged because insertRule drops comments.

  • #300 1266ee6 Thanks @dbanksdesign! - Emit Vite extracted CSS as a content-hashed asset by default so production deploys cannot pair new JavaScript with a cached typestyles.css. Dev still serves the stable /typestyles.css URL. Set extract.fileName to a literal path to opt out, or use [hash] placeholders for a custom name.

    @typestyles/astro keeps the stable typestyles.css name by default, because Astro pages do not pass through Vite's HTML rewrite.

Patch Changes

0.5.4

Patch Changes

  • #297 c894838 Thanks @dbanksdesign! - Fail vite build when a local module reachable from the app calls recipe() and is missing from the extract entry. Set coverage: false to extract a subset on purpose.
  • Updated dependencies [c894838]:

0.5.3

Patch Changes

  • #287 7979a45 Thanks @dbanksdesign! - Build with tsdown (via Vite+) instead of tsup. Public exports and types are unchanged; the output no longer includes JSDoc comments, and @typestyles/next now shares code between its entry points instead of duplicating it.

  • Updated dependencies [7979a45]:

0.5.2

Patch Changes

0.5.1

Patch Changes

0.5.0

Minor Changes

  • #251 35afeef Thanks @dbanksdesign! - Public API redesign: createTypeStyles returns a flat { style, hash, recipe, tokens, global, … } surface; nested layers: { order, token, style, global? }; global.rule / global.rules; remove root styles / tokens / global singletons. Migrate codemod emits style / recipe via createTypeStyles. Cache-bust extract module imports so Next route CSS re-runs register styles.

Patch Changes

0.4.5

Patch Changes

0.4.4

Patch Changes

  • #139 f68e5ab Thanks @dbanksdesign! - Auto-inject <link rel="stylesheet"> for extracted typestyles.css into HTML entry points during dev and build, fixing silent unstyled production builds when the manual link step is skipped (#133).

  • Updated dependencies []:

0.4.3

Patch Changes

0.4.2

Patch Changes

0.4.1

Patch Changes

  • #97 468375c Thanks @dbanksdesign! - Add shared convention entry discovery across Rollup, esbuild, and webpack plugins; ship @typestyles/esbuild and @typestyles/webpack; extend discovery to .js entry files; add Vue, Svelte, esbuild, and Parcel examples with build verification.

  • #98 e17b8a0 Thanks @dbanksdesign! - Add npm landing-page READMEs for every published package, an examples index with contributor guidance, and doc-to-example cross-links (P2.13).

  • Updated dependencies [468375c, e17b8a0, f5b9c6d]:

0.4.0

Minor Changes

  • #75 8bf64b0 Thanks @dbanksdesign! - Add shared convention entry discovery: discoverDefaultExtractModules and DEFAULT_EXTRACT_MODULE_CANDIDATES (including styles/typestyles-entry.ts and styles/typestyles.ts after the src/… paths).

    @typestyles/vite re-exports these from @typestyles/build-runner and resolves optional extract.modules using the same list.

    @typestyles/next depends on @typestyles/build-runner, aligns buildTypestylesForNext with that discovery, defaults cssOutFile to app/typestyles.css and manifest output unless overridden, adds withTypestyles for production config when a convention file exists, and re-exports the discovery helpers.

    withTypestyles now passes root through to extraction internals so webpack resolution uses the same project root as convention discovery.

    Breaking (Next): BuildTypestylesForNextOptions no longer requires modules or cssOutFile; pass them explicitly when you need non-default behavior.

  • #77 28a3f82 Thanks @dbanksdesign! - Breaking: Duplicate logical styles.component / styles.class namespaces across different modules are now build errors (via this.error) instead of Rollup warnings, so overlapping registrations fail fast during vite build / Rollup.

    The warnDuplicates option still defaults to true; set warnDuplicates: false to skip the check. Namespace extraction now includes styles.class('…') calls so they participate in the same cross-module duplicate detection as styles.component.

Patch Changes

0.3.0

Minor Changes

  • #49: Add ESLint configuration across all packages, examples, and docs. Create shared eslint.base.js config with TypeScript rules and add lint scripts to all package.json files. Update CI workflow to run lint via turbo.

  • #60: @typestyles/vite: When extract.modules is set and mode is omitted, default mode is now 'build': vite dev keeps runtime injection and HMR; vite build emits the CSS asset and disables client injection (same as explicit mode: 'build'). Pass mode: 'runtime' to keep the previous “extract config present but runtime-only” behavior. Vitest: plugin tests extended; runtime/build parity moved to build-parity.test.ts with skipIf when build-runner dist is missing.

    @typestyles/next: README documents applying withTypestylesExtract only in production so development keeps client runtime injection.

    Docs (vite-plugin, zero-runtime, getting-started) and roadmap.md describe dev-runtime / prod-extraction; examples/vite-app, examples/typewind, and examples/next-app (next.config.mjs) follow the recommended wiring.

Patch Changes

  • #50: Add lint-staged for prettier formatting on pre-commit hook and format entire codebase

  • #54: Unify multi-variant styling on styles.component with a CVA-style return value: call it for a composed class string (base always applied) or destructure named class strings. Supports dimensioned variants (variants, compoundVariants, defaultVariants), flat variant maps, and slot-based configs.

    Remove styles.create from the public styles API; use styles.component instead.

    Update Vite and Rollup static namespace extraction to match styles.component(...) only (no longer scans styles.create(...)).

  • Updated dependencies [#49]

  • Updated dependencies [#50]

0.2.0

Minor Changes

  • #25: Updating bundler integrations and adding examples

Patch Changes

0.1.1

Patch Changes

  • #15: Add additional test coverage for vite plugin

0.1.0

Minor Changes

  • #4: Add styles.component() API for multi-variant component styles with support for base styles, variant dimensions, compound variants, and default variants. Add global.style() and global.fontFace() APIs for applying styles to arbitrary CSS selectors and declaring @font-face rules. Update the Vite plugin to support HMR for the new APIs.

0.0.2

Patch Changes

  • #1: Initial release of typestyles - CSS-in-TypeScript that embraces CSS instead of hiding from it.

    Features:

    • Core typestyles library with type-safe CSS styling
    • Server-side rendering support
    • Vite plugin for HMR support