Registry / web-framework / bundlebars

bundlebars

JSON →
library1.2.0jsnpmunverified

Handlebars templates compiler and bundler that compiles static templates with JSON or YAML data and precompiles templates into AMD/Node/ES6/JST wrappers. Version 1.2.0 is the current stable release. Release cadence is low, with no recent updates. Key differentiators include a Promise-based API, CLI with Unix pipe support, and an integrated Grunt task, unlike standalone Handlebars or other precompilers that lack bundling or pipe capabilities. It supports both compilation to HTML and precompilation for SPA delivery.

npm install bundlebars
INSTALL
IMPORT
SIG · BUNDLEBARS
B
bundlebars
web-frameworkjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

bundlebars.compile
import { compile } from 'bundlebars'
const compile = require('bundlebars').compile
Package uses CommonJS, but ESM import is supported in bundlers. The compile function returns a Promise.
bundlebars.precompile
import { precompile } from 'bundlebars'
const precompile = require('bundlebars/precompile')
precompile is exported from the main module, not a subpath.
bundlebars
import bundlebars from 'bundlebars'
const bundlebars = require('bundlebars').default
Default export is the module itself, no .default needed.

Shows how to use compile and precompile functions with bundlebars. The compile function takes template string and data object, returns a Promise with rendered string. The precompile function takes template string and options object (e.g., wrapper: 'amd'), returns a Promise with precompiled template string.

const bundlebars = require('bundlebars'); // Compile a template with data const template = 'Hello {{name}}!'; const data = { name: 'World' }; bundlebars.compile(template, data).then(result => { console.log(result); // Outputs: Hello World! }).catch(err => { console.error(err); }); // Precompile a template with AMD wrapper bundlebars.precompile(template, { wrapper: 'amd' }).then(result => { console.log(result); // Precompiled AMD module string }).catch(err => { console.error(err); });
bundlebars --version
Debug
Known issues
gotchaThe compile function expects a template string as first argument and data object as second argument. If you pass a file path, it will treat it as a template string literal, not read the file.
fix
Use the CLI or read the file with fs.readFileSync and pass the content string.
affects: <=1.2.0
deprecatedThe 'q' promise library is used internally. This is an outdated library; native Promises are recommended for new projects.
fix
No immediate fix needed, but consider using a newer library or manually overriding with native promises.
affects: >=1.0.0
gotchaThe CLI option '--options' expects a path to a module that exports an object. If the path is relative, it must be relative to the current working directory, not the module location.
fix
Use an absolute path or ensure the relative path is correct from the working directory.
affects: <=1.2.0
Errors
Common errors & fixes
Error: Cannot find module 'q'
Missing dependency 'q' when using bundlebars in a project that doesn't have it installed.
fix
Run npm install q --save or ensure bundlebars is installed properly (npm install bundlebars).
TypeError: bundlebars.compile is not a function
Incorrect import or require statement. For example, using default import incorrectly in ESM.
fix
Use proper import: import { compile } from 'bundlebars' or const { compile } = require('bundlebars').
Error: Cannot find module 'js-yaml'
js-yaml is an optional dependency, but required when using YAML data files. It may not be installed automatically.
fix
Run npm install js-yaml --save if you need YAML support.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
handlebarsrequiredRequired dependency for compiling and precompiling Handlebars templates
js-yamloptionalUsed to parse YAML data files for template compilation
qrequiredPromise library used for asynchronous operations (deprecated in favor of native promises)
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
bundlebars — npm install bundlebars · libregistry