Skip to main content

Compiler

@webda/compiler


Class: Compiler

Defined in: compiler.ts:103

Compiler

Builds an application on TypeScript 7.1 through @webda/content-mapper: the two-pass build emits the JavaScript — generated accessors, behaviours and WebdaQL rewrites included, type-checked as written — and the same process generates webda.module.json. See schema-backend.ts for why it runs out of process, and docs/contribute/TypeScript 7 Content Mappers.md for the migration.

Constructors​

Constructor​

new Compiler(project, resolveGenerator?): Compiler

Defined in: compiler.ts:131

Create a new compiler for the given project

Parameters​

project​

WebdaProject

the Webda project to compile

resolveGenerator?​

(name, appRoot) => string

locates generator packages; replaceable to simulate a missing one

Returns​

Compiler

Properties​

compiled​

compiled: boolean

Defined in: compiler.ts:107

If true the compiler has compiled already


project​

project: WebdaProject

Defined in: compiler.ts:132

the Webda project to compile

Methods​

compile()​

compile(force?): boolean

Defined in: compiler.ts:234

This is our main entry point

Parameters​

force?​

boolean = false

skip cache and force recompilation

Returns​

boolean

true if compilation succeeded


requireCompilation()​

requireCompilation(): boolean

Defined in: compiler.ts:153

Add a system to recompile if needed

Returns​

boolean

true if compilation is needed


stopWatch()​

stopWatch(): void

Defined in: compiler.ts:339

Stop watching for changes

Returns​

void


watch()​

watch(callback?): void

Defined in: compiler.ts:323

Launch compiler in watch mode

Rebuilds on any change under src/, debounced. The TypeScript 6 version drove a createWatchProgram; there is no incremental emit with generated code in 7.1's API, and a full two-pass build is fast enough — well under a second for @webda/core — that a resident incremental program is not worth its complexity yet.

Parameters​

callback?​

(event) => void

called with MODULE_GENERATION / MODULE_GENERATED around each rebuild, and with COMPILATION_ERROR when one fails

Returns​

void