@goodie-ts/transformer
v0.7.0
Published
Compile-time TypeScript transformer for goodie-ts dependency injection
Readme
@goodie-ts/transformer
Compile-time TypeScript transformer for goodie-ts dependency injection.
Install
pnpm add -D @goodie-ts/transformerOverview
Scans your TypeScript source for decorated classes at build time using ts-morph, resolves the dependency graph, and generates a typed wiring file (AppContext.generated.ts). No runtime reflection needed.
Pipeline
Scanner → Resolver → GraphBuilder → Codegen- Scanner — reads ts-morph AST, discovers
@Singleton,@Injectable,@Module,@Provides - Resolver — resolves types, constructor params, field injections, and
InjectionTokenreferences - GraphBuilder — validates the dependency graph, expands modules, detects cycles
- Codegen — emits typed
BeanDefinition[], factory functions, and token exports
Usage
Most users should use @goodie-ts/vite-plugin which calls the transformer automatically. For direct use:
import { transform } from '@goodie-ts/transformer';
await transform({
tsConfigPath: './tsconfig.json',
outputPath: './src/AppContext.generated.ts',
});Generated Output
The generated file exports:
- Typed
InjectionTokendeclarations for interfaces, generics, and primitives - A
definitionsarray ofBeanDefinition[] createContext()— async factory returning anApplicationContextapp— aGoodie.build(definitions)instance ready to.start()
Library Mode
For packages that ship pre-scanned beans, use transformLibrary() (via goodie generate --mode library). It serializes bean definitions to beans.json and also scans for createAopDecorator<{...}>() calls, including AOP config in the manifest. Consumers auto-discover beans and AOP mappings at build time.
