coz-bud-compiler
raw JSON → 3.0.4 verified Fri May 01 auth: no javascript
coz-bud-compiler is a plugin for the coz build system that compiles coz bud definitions into rendering instructions. Version 3.0.4 is the latest stable release, supporting Node >=8 and npm >=5. It provides a compiler object that processes bud configurations and returns compiled buds. Compared to other build tools, it specializes in the coz ecosystem and relies on external template resolvers and engine resolvers. The package is relatively niche and has a limited maintenance history.
Common errors
error TypeError: cozBudCompiler is not a function ↓
cause Missing default import or incorrect require
fix
Use correct import: import cozBudCompiler from 'coz-bud-compiler'
error Cannot find module 'engine-handlebars' ↓
cause resolveEngine returns a module that is not installed
fix
Install the required engine package or provide correct path
error Bud must have a 'tmpl' property ↓
cause Bud object missing required field tmpl
fix
Ensure bud.tmpl is defined
Warnings
breaking coz-bud-compiler@3 drops support for Node <8, requires async/await for compile method ↓
fix Ensure Node >=8 and use async/await or promises with compile
deprecated The old-style synchronous compile method or callback-based API is removed in v3 ↓
fix Use the async compile method or promise chain
gotcha The resolveTmpl and resolveEngine callbacks must return strings or modules, not promises (though they can be async) ↓
fix Ensure these callbacks are synchronous or return a Promise if needed
Install
npm install coz-bud-compiler yarn add coz-bud-compiler pnpm add coz-bud-compiler Imports
- default wrong
const cozBudCompiler = require('coz-bud-compiler')correctimport cozBudCompiler from 'coz-bud-compiler' - compile
import { compile } from 'coz-bud-compiler' - createCompiler wrong
import { Compiler } from 'coz-bud-compiler'correctimport { createCompiler } from 'coz-bud-compiler'
Quickstart
import cozBudCompiler from 'coz-bud-compiler'
const compiler = cozBudCompiler({
resolveTmpl: (filename) => `./templates/${filename}.hbs`,
resolveEngine: (name) => require(`engine-${name}`)
})
async function build() {
const bud = {
mode: 'render',
path: './output/file.txt',
data: { name: 'example' },
tmpl: 'my-template'
}
const compiled = await compiler.compile(bud)
console.log(compiled)
}
build().catch(console.error)