{"id":18188,"library":"bundlebars","title":"Bundlebars","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"git@github.com:wallarm/bundlebars","tags":["javascript","handlebars","compile","precompile","bundle"],"install":[{"cmd":"npm install bundlebars","lang":"bash","label":"npm"},{"cmd":"yarn add bundlebars","lang":"bash","label":"yarn"},{"cmd":"pnpm add bundlebars","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required dependency for compiling and precompiling Handlebars templates","package":"handlebars","optional":false},{"reason":"Used to parse YAML data files for template compilation","package":"js-yaml","optional":true},{"reason":"Promise library used for asynchronous operations (deprecated in favor of native promises)","package":"q","optional":false}],"imports":[{"note":"Package uses CommonJS, but ESM import is supported in bundlers. The compile function returns a Promise.","wrong":"const compile = require('bundlebars').compile","symbol":"bundlebars.compile","correct":"import { compile } from 'bundlebars'"},{"note":"precompile is exported from the main module, not a subpath.","wrong":"const precompile = require('bundlebars/precompile')","symbol":"bundlebars.precompile","correct":"import { precompile } from 'bundlebars'"},{"note":"Default export is the module itself, no .default needed.","wrong":"const bundlebars = require('bundlebars').default","symbol":"bundlebars","correct":"import bundlebars from 'bundlebars'"}],"quickstart":{"code":"const bundlebars = require('bundlebars');\n\n// Compile a template with data\nconst template = 'Hello {{name}}!';\nconst data = { name: 'World' };\nbundlebars.compile(template, data).then(result => {\n  console.log(result); // Outputs: Hello World!\n}).catch(err => {\n  console.error(err);\n});\n\n// Precompile a template with AMD wrapper\nbundlebars.precompile(template, { wrapper: 'amd' }).then(result => {\n  console.log(result); // Precompiled AMD module string\n}).catch(err => {\n  console.error(err);\n});","lang":"javascript","description":"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."},"warnings":[{"fix":"Use the CLI or read the file with fs.readFileSync and pass the content string.","message":"The 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.","severity":"gotcha","affected_versions":"<=1.2.0"},{"fix":"No immediate fix needed, but consider using a newer library or manually overriding with native promises.","message":"The 'q' promise library is used internally. This is an outdated library; native Promises are recommended for new projects.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use an absolute path or ensure the relative path is correct from the working directory.","message":"The 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.","severity":"gotcha","affected_versions":"<=1.2.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install q --save or ensure bundlebars is installed properly (npm install bundlebars).","cause":"Missing dependency 'q' when using bundlebars in a project that doesn't have it installed.","error":"Error: Cannot find module 'q'"},{"fix":"Use proper import: import { compile } from 'bundlebars' or const { compile } = require('bundlebars').","cause":"Incorrect import or require statement. For example, using default import incorrectly in ESM.","error":"TypeError: bundlebars.compile is not a function"},{"fix":"Run npm install js-yaml --save if you need YAML support.","cause":"js-yaml is an optional dependency, but required when using YAML data files. It may not be installed automatically.","error":"Error: Cannot find module 'js-yaml'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}