{"id":22052,"library":"rollup-plugin-hbs","title":"rollup-plugin-hbs","description":"A minimal Rollup plugin for bundling Handlebars templates. Version 1.2.6 is the latest stable release, last updated in 2020. It compiles .hbs (or custom extension) templates into precompiled JavaScript functions, integrating with Handlebars runtime. Compared to other Handlebars Rollup plugins like rollup-plugin-handlebars-plus, this package offers a simpler API, sourcemap support, partial detection based on filename prefix, and whitespace optimization. It requires Handlebars, Rollup >=0.62.0, and rollup-pluginutils as peer dependencies. Note that the plugin has not been updated for Rollup 2+/3+ and may be incompatible with modern Rollup versions; consider using @rollup/plugin-handlebars instead.","status":"deprecated","version":"1.2.6","language":"javascript","source_language":"en","source_url":"https://github.com/yohangz/rollup-plugin-hbs","tags":["javascript","rollup","rollup-plugin","handlebars","hbs","templating"],"install":[{"cmd":"npm install rollup-plugin-hbs","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-hbs","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-hbs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for template compilation and execution","package":"handlebars","optional":false},{"reason":"Peer dependency for Rollup integration","package":"rollup","optional":false},{"reason":"Provides utility functions for Rollup plugins","package":"rollup-pluginutils","optional":false}],"imports":[{"note":"ESM only; CommonJS require() will fail because package exports an ESM module.","wrong":"const hbs = require('rollup-plugin-hbs')","symbol":"hbs","correct":"import hbs from 'rollup-plugin-hbs'"},{"note":"The plugin exports a single default function; named import will be undefined.","wrong":"import { hbs } from 'rollup-plugin-hbs'","symbol":"default","correct":"import hbs from 'rollup-plugin-hbs'"},{"note":"Handlebars must be imported separately; it is not re-exported by this plugin.","wrong":"import Handlebars from 'rollup-plugin-hbs'","symbol":"Handlebars","correct":"import Handlebars from 'handlebars'"}],"quickstart":{"code":"// rollup.config.js\nimport hbs from 'rollup-plugin-hbs';\nimport resolve from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\n\nexport default {\n  input: 'src/main.js',\n  output: { file: 'bundle.js', format: 'iife' },\n  plugins: [\n    resolve(),\n    commonjs(),\n    hbs({\n      handlebars: {\n        id: 'handlebars',\n        options: { sourceMap: true },\n        optimize: true\n      },\n      templateExtension: '.hbs',\n      isPartial: (name) => name.startsWith('_')\n    })\n  ]\n};\n\n// src/main.js\nimport template from './template.hbs';\nconst html = template({ name: 'world' });\nconsole.log(html);\n\n// src/template.hbs\n<p>Hello {{name}}!</p>","lang":"javascript","description":"Configures Rollup to compile Handlebars templates, importing a template and rendering it with data."},"warnings":[{"fix":"Migrate to @rollup/plugin-handlebars or rollup-plugin-handlebars-plus","message":"Package is no longer maintained; no updates since 2020","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use an older version of Rollup (0.x) or switch to a maintained plugin","message":"Incompatible with Rollup >=2.0 due to plugin API changes","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure partials are imported explicitly or adjust isPartial logic","message":"Template filenames starting with '_' are automatically treated as partials and not included in output if not imported","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Disable sourcemaps or use alternatives","message":"Sourcemaps may be incomplete due to lack of Rollup 2+ support","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Not directly fixable; migrate to a plugin that uses modern Rollup APIs","message":"rollup-pluginutils is deprecated; plugin uses its functionality internally","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install rollup-plugin-hbs --save-dev","cause":"Package not installed or missing from node_modules","error":"Error: Cannot find module 'rollup-plugin-hbs'"},{"fix":"Use 'import hbs from 'rollup-plugin-hbs'' in an ESM context","cause":"Using CommonJS require() instead of ESM import","error":"TypeError: hbs is not a function"},{"fix":"Ensure rollup-plugin-hbs is added to plugins array and templateExtension matches file extension","cause":"Rollup cannot resolve .hbs files; plugin not configured correctly","error":"Error: Could not resolve './template.hbs' from 'src/main.js'"},{"fix":"npm install handlebars","cause":"Handlebars is a peer dependency not installed","error":"Error: The 'handlebars' module is not installed"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}