UNPKG

@storm-stack/core

Version:

A build toolkit and runtime used by Storm Software in TypeScript applications

94 lines (91 loc) 3.23 kB
import MagicString from 'magic-string'; import { CompilerInterface, LogFn, Context, CompilerOptions, TranspilerOptions, SourceFile, CompilerResult } from '../types/index.js'; import '@babel/core'; import '@babel/types'; import '@storm-stack/types/shared/error'; import '@stryke/types/base'; import '@storm-software/config-tools/types'; import '@stryke/types/configuration'; import 'hookable'; import '@storm-software/build-tools/types'; import '@storm-software/config/types'; import '@storm-software/esbuild/types'; import '@storm-software/unbuild/types'; import 'c12'; import 'esbuild'; import 'unbuild'; import '@deepkit/type'; import '../reflection-DTM1oT21.js'; import '@stryke/capnp'; import '@storm-stack/types/shared/log'; import '@stryke/env/get-env-paths'; import '@stryke/types/package-json'; import 'jest-worker'; import 'jiti'; import 'memfs'; import 'unimport'; import '../types/tsconfig.js'; import '@stryke/types/tsconfig'; import 'typescript'; import '../types/vfs.js'; import 'memfs/lib/volume'; import 'node:fs'; import 'unionfs'; declare class Compiler implements CompilerInterface { #private; /** * The logger function to use */ protected log: LogFn; /** * The cache directory */ protected cacheDir: string; /** * Create a new compiler instance. * * @param context - The compiler context. * @param options - The compiler options. */ constructor(context: Context, options?: CompilerOptions); /** * Transform the module. * * @param context - The compiler context. * @param fileName - The name of the file to compile. * @param code - The source code to compile. * @param options - The transpile options. * @returns The transpiled module. */ transform(context: Context, fileName: string, code: string | MagicString, options?: CompilerOptions): Promise<string>; /** * Transpile the module. * * @param context - The compiler context. * @param id - The name of the file to compile. * @param code - The source code to compile. * @returns The transpiled module. */ transpile(context: Context, id: string, code: string | MagicString, options?: TranspilerOptions): Promise<string>; /** * Compile the source code. * * @param context - The compiler context. * @param id - The name of the file to compile. * @param code - The source code to compile. * @returns The compiled source code and source map. */ compile(context: Context, id: string, code: string | MagicString, options?: CompilerOptions): Promise<string>; /** * Get the result of the compiler. * * @param sourceFile - The source file. * @param transpiled - The transpiled source code. * @returns The result of the compiler. */ getResult(sourceFile: SourceFile, transpiled?: string): CompilerResult; protected getCache(context: Context, sourceFile: SourceFile): Promise<string | undefined>; protected setCache(context: Context, sourceFile: SourceFile, transpiled?: string): Promise<void>; protected shouldSkip(context: Context, id: string, code: string | MagicString): Promise<boolean>; } export { Compiler };