import * as jsx from "./jsx"; import * as scss from "./scss"; import * as ts from "./ts"; import * as gjs from "./gjs"; import { Context } from "../context"; import { TransformError } from "./support/error"; export interface TransformResult { errors?: TransformError[]; } export class NoTransformerError extends Error { constructor() { super("No transformer found"); } } export type Transformer = (filename: string, context: Context) => Promise; const transformers = [jsx, scss, gjs, ts]; export function process(filename: string, context: Context): Promise { for (const transformer of transformers) { if (transformer.match(filename)) { return transformer.process(filename, context); } } throw new NoTransformerError(); }