Subpath Exports
Dispersa exposes a main entry point and several subpath exports. Use subpaths to keep bundles small and import only what you need.
Export Summary
Section titled “Export Summary”| Subpath | Key exports | Typical usage |
|---|---|---|
dispersa | Dispersa, builders, defineRenderer, outputTree, isOutputTree, type guards, error classes, all public types | Main entry; full builds |
dispersa/transforms | colorToHex, nameKebabCase, dimensionToRem, etc. (23 factories) + Transform type | Per-output or global transforms |
dispersa/filters | byType, byPath, isAlias, isBase + Filter type | Token filtering |
dispersa/builders | css, json, js, tailwind, ios, android + builder config types | Output configuration only |
dispersa/renderers | defineRenderer, outputTree, isOutputTree + all renderer/build types | Custom renderers |
dispersa/preprocessors | Preprocessor type | Custom preprocessors |
dispersa/errors | All 10 error classes | Error handling |
dispersa/config | defineConfig, CliConfig | CLI config files |
dispersa/cli | CLI entry point | Internal CLI runner |
dispersa (main)
Section titled “dispersa (main)”Values: Dispersa, css, json, js, tailwind, ios, android, defineRenderer, outputTree, isOutputTree, type guards (isColorToken, isDimensionToken, isShadowToken, isTypographyToken, isBorderToken, isDurationToken, isTransitionToken, isGradientToken), error classes
Types: OutputConfig, BuildConfig, BuildResult, BuildOutput, BuildError, ErrorCode, LifecycleHooks, DispersaOptions, ValidationOptions, ValidationMode, ResolvedToken, ResolvedTokens, TokenType, ModifierInputs, ResolverDocument, Transform, Filter, Preprocessor, Renderer, RenderContext, RenderMeta, PermutationData, RenderOutput, FormatOptions, OutputTree, SelectorFunction, MediaQueryFunction, DesignTokenValue, ColorToken, DimensionToken, ShadowToken, DurationToken, TypographyToken, BorderToken, TransitionToken, GradientToken, ColorValueObject, ColorValue, ColorSpace, ColorComponent, DimensionValue, DurationValue, ShadowValueObject, TypographyValue, BorderValue, TransitionValue, GradientValue, GradientStop, FontFamilyValue, FontWeightValue, CubicBezierValue, StrokeStyleValue, TokenValue, TokenValueReference, renderer options types, builder config types
import { Dispersa, css, json, defineRenderer } from 'dispersa'import { isColorToken, isDimensionToken } from 'dispersa'import type { BuildConfig, ResolvedToken, CssBuilderConfig } from 'dispersa'Use for full build setups. Includes the Dispersa class, all builders, renderer utilities, type guard functions, error classes, and all public types.
dispersa/transforms
Section titled “dispersa/transforms”Values: colorToHex, colorToRgb, colorToHsl, colorToOklch, colorToOklab, colorToLch, colorToLab, colorToHwb, colorToColorFunction, dimensionToPx, dimensionToRem, dimensionToUnitless, nameKebabCase, nameCamelCase, nameSnakeCase, namePascalCase, nameConstantCase, namePrefix, nameSuffix, nameCssVar, fontWeightToNumber, durationToMs, durationToSeconds
Types: Transform
import { colorToHex, nameKebabCase, dimensionToRem } from 'dispersa/transforms'import type { Transform } from 'dispersa/transforms'Use when you only need transforms. Keeps the main bundle smaller if you configure outputs elsewhere.
dispersa/filters
Section titled “dispersa/filters”Values: byType, byPath, isAlias, isBase
Types: Filter
import { byType, byPath } from 'dispersa/filters'import type { Filter } from 'dispersa/filters'Use when you only need filters for token inclusion.
dispersa/builders
Section titled “dispersa/builders”Values: css, json, js, tailwind, ios, android
Types: CssBuilderConfig, JsonBuilderConfig, JsBuilderConfig, TailwindBuilderConfig, IosBuilderConfig, AndroidBuilderConfig
import { css, json } from 'dispersa/builders'import type { CssBuilderConfig } from 'dispersa/builders'Use when you need only the builder functions, e.g. in a shared config file.
dispersa/renderers
Section titled “dispersa/renderers”Values: defineRenderer, outputTree, isOutputTree
Types: Renderer, RenderContext, RenderMeta, PermutationData, RenderOutput, FormatOptions, OutputTree, BuildResult, BuildOutput, BuildError, ErrorCode, SelectorFunction, MediaQueryFunction, CssRendererOptions, JsonRendererOptions, JsModuleRendererOptions, TailwindRendererOptions, IosRendererOptions, AndroidRendererOptions
import { defineRenderer, outputTree } from 'dispersa/renderers'import type { RenderContext, Renderer } from 'dispersa/renderers'Use when building custom renderers. Lighter than the main entry if you don’t need Dispersa or builders. Also re-exports build result types and all renderer option types for convenience.
dispersa/preprocessors
Section titled “dispersa/preprocessors”Exports: Preprocessor type
import type { Preprocessor } from 'dispersa/preprocessors'Use when implementing custom preprocessors.
dispersa/errors
Section titled “dispersa/errors”Exports: DispersaError, TokenReferenceError, CircularReferenceError, ValidationError, ColorParseError, DimensionFormatError, FileOperationError, ConfigurationError, BasePermutationError, ModifierError
import { TokenReferenceError, ValidationError } from 'dispersa/errors'Use when you need to catch or handle specific error types, or implement custom error handling.
dispersa/config
Section titled “dispersa/config”Exports: defineConfig, CliConfig
import { defineConfig } from 'dispersa/config'Use in dispersa.config.ts to define a typed CLI configuration. defineConfig is an identity function that provides type checking and editor autocompletion.
dispersa/cli
Section titled “dispersa/cli”Exports: CLI entry point
This is the internal entry point used by the dispersa CLI binary. You typically don’t import from this directly.