{"id":25721,"library":"handlebars-transpiler","title":"Handlebars Transpiler","description":"Handlebars Transpiler is a Node.js module for compiling Handlebars templates along with partials, JSON data, and custom helpers into static HTML files. Version 1.0.3 is the latest stable release; the package is actively maintained with a focus on simplicity for generating static sites from Handlebars templates. It differentiates itself from other build tools by being a lightweight, zero-config CLI and programmatic API specifically for Handlebars, with no dependency on larger frameworks like Gulp or Grunt. It supports custom output paths and partials registration. It is not suitable for dynamic rendering or runtime caching.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/dprea/handlebars-transpiler","tags":["javascript"],"install":[{"cmd":"npm install handlebars-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add handlebars-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add handlebars-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"required Handlebars runtime for compiling and executing templates","package":"handlebars","optional":false}],"imports":[{"note":"ESM default export only; named import 'transpile' is the expected API.","wrong":"const { transpile } = require('handlebars-transpiler')","symbol":"transpile","correct":"import { transpile } from 'handlebars-transpiler'"},{"note":"Named export for synchronous transpilation; do not use default import.","wrong":"import transpileSync from 'handlebars-transpiler'","symbol":"transpileSync","correct":"import { transpileSync } from 'handlebars-transpiler'"},{"note":"TypeScript type export; use 'import type' to avoid runtime inclusion.","wrong":"import { TranspilerOptions } from 'handlebars-transpiler'","symbol":"TranspilerOptions","correct":"import type { TranspilerOptions } from 'handlebars-transpiler'"}],"quickstart":{"code":"import { transpile } from 'handlebars-transpiler';\n\nconst config = {\n  template: 'template.hbs',\n  data: 'data.json',\n  partials: ['partials/header.hbs', 'partials/footer.hbs'],\n  helpers: {\n    uppercase: (str) => str.toUpperCase()\n  },\n  output: 'index.html'\n};\n\ntranspile(config).then(() => {\n  console.log('Static HTML generated successfully');\n}).catch(err => {\n  console.error('Transpilation failed:', err);\n});","lang":"typescript","description":"Demonstrates transpiling a Handlebars template with data, partials, and a custom helper to a static HTML file."},"warnings":[{"fix":"Provide absolute or relative paths to .hbs files; partials are automatically registered with their filename (without extension).","message":"The 'partials' option expects an array of file paths, not Handlebars partial registration strings.","severity":"gotcha","affected_versions":">=1.0.0 <2.0.0"},{"fix":"Replace any call to 'compile' with 'transpile' using the same API.","message":"The 'compile' function is deprecated in favor of 'transpile'.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Create a separate JSON file and pass its path as the 'data' option.","message":"The 'data' option only accepts a JSON file path; inline data objects are not supported.","severity":"gotcha","affected_versions":">=1.0.0 <2.0.0"},{"fix":"Update imports to use named exports: import { transpile } from 'handlebars-transpiler'.","message":"Version 1.0.0 changed the exported API from a default function to named exports ('transpile', 'transpileSync').","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install handlebars' in your project.","cause":"Handlebars is a peer dependency that must be installed separately.","error":"Error: Cannot find module 'handlebars'"},{"fix":"Ensure the 'template' option is a valid file path string.","cause":"The 'template' option provided is not a string (e.g., object or undefined).","error":"TypeError: template must be a string"},{"fix":"Verify the path to your JSON data file is correct relative to the working directory.","cause":"The 'data' file path is incorrect or the file does not exist.","error":"Error: ENOENT: no such file or directory, open 'data.json'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}