Skip to main content Link Search Menu Expand Document (external link)

Compiler overview

Compiler is an all-in-one package for compile-time optimization and derivations of Typed libraries and applications.

Added in v1.0.0


Table of contents


utils

Compiler (class)

Compiler is an all-in-one cass for compile-time optimization and derivations of Typed libraries and applications.

Signature

export declare class Compiler { constructor(
    readonly directory: string,
    readonly tsConfig?: string,
    defaultCompilerTarget: CompilerTarget = "dom"
  ) }

Added in v1.0.0

parseTemplates (method)

Signature

parseTemplates(sourceFile: ts.SourceFile): Array<ParsedTemplate>

Added in v1.0.0

compileTemplates (method)

Signature

compileTemplates(
    sourceFile: ts.SourceFile,
    target?: CompilerTarget
  )

Added in v1.0.0

getTransformersByFileAndTarget (method)

Signature

private getTransformersByFileAndTarget(
    templates: Array<ParsedTemplate>,
    target: CompilerTarget
  ): Array<ts.TransformerFactory<ts.SourceFile>>

Added in v1.0.0

replaceDom (method)

Signature

private replaceDom(
    { parts, template }: ParsedTemplate,
    remaining: Array<ParsedTemplate>,
    imports: ImportDeclarationManager
  ): ts.Node

Added in v1.0.0

parseTemplateFromNode (method)

Signature

private parseTemplateFromNode(node: ts.TemplateLiteral): readonly [Template.Template, ReadonlyArray<ParsedPart>]

Added in v1.0.0

parsePart (method)

Signature

private parsePart(part: ts.Expression, index: number): ParsedPart

Added in v1.0.0

getPartType (method)

Signature

private getPartType(node: ts.Node, type: ts.Type): ParsedPart["kind"]

Added in v1.0.0

isPrimitiveType (method)

Signature

private isPrimitiveType(type: ts.Type)

Added in v1.0.0

project (property)

Signature

readonly project: Project

Added in v1.0.0

checker (property)

Signature

readonly checker: ts.TypeChecker

Added in v1.0.0

CompilerTarget (type alias)

Signature

export type CompilerTarget = "dom" | "server" | "static"

Added in v1.0.0

ParsedPart (type alias)

Signature

export type ParsedPart = SimpleParsedPart | ParsedTemplatePart

Added in v1.0.0

ParsedTemplate (interface)

Signature

export interface ParsedTemplate {
  readonly literal: ts.TemplateLiteral
  readonly parts: ReadonlyArray<ParsedPart>
  readonly template: Template.Template
}

Added in v1.0.0

ParsedTemplatePart (interface)

Signature

export interface ParsedTemplatePart extends Omit<SimpleParsedPart, "kind">, ParsedTemplate {
  readonly kind: "template"
}

Added in v1.0.0

SimpleParsedPart (type alias)

Signature

export type SimpleParsedPart = {
  readonly index: number
  readonly kind: "placeholder" | "fxEffect" | "fx" | "effect" | "primitive" | "directive"
  readonly node: ts.Expression
  readonly type: ts.Type
}

Added in v1.0.0