@trousers/compiler
@trousers/compiler
analyzeStyles
SourceCompile one JavaScript or TypeScript module. Returns undefined when it has no Trousers imports.
function analyzeStyles(file: string, source: string, loader?: string): CompiledModule | undefined;
CompiledModule
SourceSource edits and extracted styles returned by the Rust compiler.
export interface CompiledModule {
imports: {
start: number;
end: number;
replacement: string;
}[];
styles: {
start: number;
end: number;
value: string;
marker: string;
rules: {
css: string;
retain: boolean;
start: number;
}[];
}[];
}
CompileError
SourceCompiler diagnostic with the source range that triggered it.
const CompileError: typeof CompileError;
sourcePositions
SourceCreate a lookup from source offsets to zero-based lines and columns.
function sourcePositions(source: string): (offset: number) => { line: number; character: number; };