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 | build, css, json, js, tailwind, ios, android, lint, 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/outputs | Renderer functions, builders (css, json, js, tailwind, ios, android), defineRenderer, outputTree, isOutputTree + all types | Custom renderers, outputs |
dispersa/preprocessors | Preprocessor type | Custom preprocessors |
dispersa/errors | All 8 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: build, buildOrThrow, buildPermutation, resolveTokens, lint, resolveAllPermutations, generateTypes, 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, FileFunction, 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, StrokeStyleValueObject, TokenValue, TokenValueReference, renderer options types, builder config types
import { build, css, json, defineRenderer } from 'dispersa'import { isColorToken, isDimensionToken } from 'dispersa'import type { BuildConfig, ResolvedToken, CssBuilderConfig } from 'dispersa'Use for full build setups. Includes all build functions, 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, 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/outputs
Section titled “dispersa/outputs”Values: cssRenderer, jsRenderer, jsonRenderer, tailwindRenderer, iosRenderer, androidRenderer, outputTree, isOutputTree, defineRenderer, css, json, js, tailwind, ios, android
Types: Renderer, RenderContext, RenderMeta, PermutationData, RenderOutput, FormatOptions, OutputTree, BuildResult, BuildOutput, BuildError, ErrorCode, SelectorFunction, MediaQueryFunction, CssRendererOptions, JsonRendererOptions, JsModuleRendererOptions, TailwindRendererOptions, IosRendererOptions, AndroidRendererOptions, builder config types
import { defineRenderer, outputTree } from 'dispersa/outputs'import type { RenderContext, Renderer } from 'dispersa/outputs'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, 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.