Node-Boot module for Ahead-of-Time (AOT) compilation. Generates node-boot beans and OpenAPI schemas at compile time
npm install @nodeboot/aot@nodeboot/aot> ๐ง Ahead-of-Time (AOT) support for the Node-Boot framework โ enabling faster startup, intelligent component scanning, and OpenAPI-ready model schemas.
---
@nodeboot/aot provides a set of tools and decorators to optimize Node-Boot apps for production, by shifting expensive runtime operations to build-time via Ahead-of-Time (AOT) processing.
It includes:
- ๐ Bean Scanner & Generator (node-boot-aot-beans.js)
Scans compiled files for decorators like @Service, @Controller, etc., and generates a precomputed node-boot-beans.json.
- ๐ฆ Component Scanner Decorator (@EnableComponentScan)
Automatically imports application components at runtime from the prebuilt manifest or falls back to dynamic scanning.
- ๐งฌ Model Schema Generator (node-boot-aot-models.js)
Converts @Model-decorated classes into OpenAPI-compatible JSON Schemas.
---
``bash`
npm install @nodeboot/aot --save-dev
---
After building your app (tsc), run the AOT bean scanner to precompile metadata for your components:
`bash`
node node-boot-aot-beans.js
#### Add to package.json:
`json`
{
"scripts": {
"postbuild": "node node-boot-aot-beans.js"
}
}
This will output dist/node-boot-beans.json โ a list of all .js files that contain key decorators such as @Service, @Controller, etc.
---
To convert all @Model-decorated classes into OpenAPI-compatible schema:
`bash`
node node-boot-aot-models.js
This will generate:
dist/node-boot-models.json โ structured like:
`json`
{
"$schema": "http://json-schema.org/draft-07/schema#",
"components": {
"schemas": {
"UserModel": {
"type": "object",
"properties": {
"id": {"type": "string"},
"name": {"type": "string"}
}
}
}
}
}
Runs both scripts in one go. Ideal for post-build automation.
`shell`
node node-boot-aot.js
๐ก Suggested in package.json:
`json`
{
"scripts": {
"postbuild": "node node-boot-aot.js"
}
}
---
In your main application class, use the @EnableComponentScan() decorator to bootstrap bean registration:
`ts
import {EnableComponentScan} from "@nodeboot/aot";
@EnableComponentScan()
@NodeBootApplication()
export class MyApp implements NodeBootApp {
start(): Promise
return NodeBoot.run(ExpressServer);
}
}
`
`ts`
@EnableComponentScan({
customDecorators: [MyCustomBean, AnotherDecorator]
})
> โ
Automatically resolves the dist/ directory in production and performs active scanning in dev (or if no JSON file is found).
---
| Directory | Purpose |
| --------: | ------------------------------------------------------------- |
| src/ | Your TypeScript source files |dist/
| | Compiled output after tsc |.json
| | Output files: node-boot-beans.json, node-boot-models.json |
---
- node-boot-aot-beans.js:@Service
Scans compiled JS files for known decorators (, @Controller, etc.) and generates node-boot-beans.json.
- node-boot-aot-models.js:@Model()
Scans -decorated classes and generates a JSON Schema file (node-boot-models.json).
- node-boot-cycle-detector.js:
Detects circular dependencies in the bean graph, ensuring no infinite loops in component/service resolution.
- node-boot-aot.js:
Combines all AOT scripts into a single runner for convenience.
- @EnableComponentScan(options?: { customDecorators?: Function[] })`:
Scans and imports bean modules based on decorators. Uses prebuilt JSON for performance when available.
---
- Fast Startup: Avoids expensive runtime filesystem scans in production.
- Predictable Component Importing: Always imports only whatโs required.
- OpenAPI-Ready: JSON schema generation for API modeling & docs.
- Flexible: Supports custom decorators and intelligent fallbacks.
---
- CLI interface for all AOT operations
- Watch mode for development
- Decorator metadata validation
---
Manuel Santos
๐ง ney.br.santos@gmail.com
๐ GitHub
---
MIT โ feel free to use, modify, and contribute.