@ic-reactor/codegen
@ic-reactor/codegen contains the shared generation pipeline used by
@ic-reactor/cli and
@ic-reactor/vite-plugin. It is the advanced,
programmatic entry point for generating declarations, reactor files, and client
boilerplate from Candid definitions.
Installation
Section titled “Installation”pnpm add -D @ic-reactor/codegenMain Entry Point
Section titled “Main Entry Point”The primary API is runCanisterPipeline, which coordinates parsing, naming,
declaration generation, and reactor file generation.
import { runCanisterPipeline } from "@ic-reactor/codegen"
await runCanisterPipeline({ canisterConfig: { name: "backend", didFile: "./backend/backend.did", mode: "DisplayReactor", }, projectRoot: process.cwd(), globalConfig: { outDir: "src/declarations", clientManagerPath: "../../clients", target: "react", },})What It Exposes
Section titled “What It Exposes”runCanisterPipelinefor full end-to-end generation.- Naming helpers like
toPascalCase,getReactorName, andgetServiceTypeName. - Parser helpers like
parseDIDFileandextractMethods. - Lower-level generators when you need declarations, reactor files, or client files separately.
For each canister, the pipeline writes:
index.generated.ts: managed implementation, always regeneratedindex.ts: stable entry wrapper, preserved unless it still matches the default wrapper or an older generated scaffold that can be migrated
Reactor Modes
Section titled “Reactor Modes”Generated output can target any of these reactor classes:
DisplayReactorReactorCandidReactorCandidDisplayReactorMetadataDisplayReactor
Runtime Target
Section titled “Runtime Target”react(default): generates the reactor plus bound React hookscore: generates only the typed reactor exports with no React dependency
See Also
Section titled “See Also” @ic-reactor/cli Use the same codegen pipeline from the command line.
@ic-reactor/vite-plugin Run the same generation flow automatically inside Vite.
Codegen in Action Compare the output generated by the CLI and Vite plugin.