{"id":22048,"library":"rollup-plugin-handlebars-plus","title":"rollup-plugin-handlebars-plus","description":"Rollup plugin to precompile and resolve Handlebars templates, including support for partials, helpers, and optional rendering to jQuery collections. Current stable version is 0.4.2 (2020-09-09). The plugin integrates with Rollup's module system, allowing import of .hbs templates as ES6 modules, and precompiles templates so only the Handlebars runtime is needed. Key differentiators: includes Handlebars runtime, supports partial roots with rollup-plugin-root-import, and can render to jQuery objects directly. Requires rollup-plugin-node-resolve and rollup-plugin-commonjs for runtime support. Maintenance status: appears unmaintained since last release in 2020, with known security issues in older Handlebars versions.","status":"maintenance","version":"0.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/mixmaxhq/rollup-plugin-handlebars-plus","tags":["javascript","rollup","plugin","Handlebars","templates","partials","jQuery"],"install":[{"cmd":"npm install rollup-plugin-handlebars-plus","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-handlebars-plus","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-handlebars-plus","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to resolve the Handlebars runtime module (commonjs)","package":"rollup-plugin-node-resolve","optional":true},{"reason":"Required to convert Handlebars runtime CJS module to ESM","package":"rollup-plugin-commonjs","optional":true}],"imports":[{"note":"Default import is the plugin function. Works in both ESM and CJS environments.","wrong":"const handlebars = require('rollup-plugin-handlebars-plus')","symbol":"handlebars","correct":"import handlebars from 'rollup-plugin-handlebars-plus'"},{"note":"Named export not available; use default import.","wrong":"const { handlebars } = require('rollup-plugin-handlebars-plus')","symbol":"handlebars","correct":"import { default as handlebars } from 'rollup-plugin-handlebars-plus'"},{"note":"Imported templates are functions (precompiled). CJS require will not have the transformation unless wrapped.","wrong":"const Template = require('./template.hbs')","symbol":"Template","correct":"import Template from './template.hbs'"}],"quickstart":{"code":"// main.js\nimport handlebars from 'rollup-plugin-handlebars-plus';\nimport rootImport from 'rollup-plugin-root-import';\n\n// rollup.config.js\nexport default {\n  input: 'main.js',\n  plugins: [\n    rootImport({\n      root: [`${__dirname}/src/views`],\n    }),\n    handlebars({\n      handlebars: {\n        id: 'handlebars',\n      },\n      helpers: ['/utils/helpers.js'],\n      partialRoot: [`${__dirname}/src/views`],\n    }),\n  ],\n  output: {\n    format: 'esm',\n    file: 'bundle.js',\n  },\n};\n\n// template.hbs\n<h1>{{title}}</h1>\n\n// Use in main.js\nimport tmpl from './template.hbs';\ndocument.body.innerHTML = tmpl({title: 'Hello'});","lang":"javascript","description":"Shows a basic rollup config using the plugin, importing a .hbs template and rendering it."},"warnings":[{"fix":"Migrate to @rollup/plugin-handlebars or use a different bundler plugin.","message":"Plugin has no updates since 2020; consider alternatives like @rollup/plugin-handlebars or vite-plugin-handlebars.","severity":"deprecated","affected_versions":">=0.4.2"},{"fix":"Provide handlebars option: { id: 'handlebars' } or { module: require('handlebars') }.","message":"In version 0.4.0, the plugin requires the `handlebars` option object with `id` or `module`; omitting it breaks the build.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Ensure helper modules export default function(Handlebars) { ... }.","message":"If using helpers option, the helper module must export a function that accepts Handlebars runtime as argument, else it fails silently.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Update to >=0.4.1 which bumps handlebars dependency to 4.6.0, or provide custom handlebars via handlebars.module option.","message":"The plugin includes a bundled Handlebars runtime that may be outdated; security vulnerabilities have been reported in older Handlebars versions.","severity":"deprecated","affected_versions":"<0.4.1"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add plugins: nodeResolve({ browser: true }), commonjs() to your rollup config.","cause":"Missing rollup-plugin-node-resolve and rollup-plugin-commonjs to resolve the runtime.","error":"Error: Could not resolve 'handlebars' (from ...)"},{"fix":"Run: npm install handlebars","cause":"Handlebars runtime not installed or not in node_modules.","error":"Error: Cannot find module 'handlebars'"},{"fix":"Export default function(Handlebars) { ... } from your helper module.","cause":"Helper module does not export a function that accepts Handlebars as argument.","error":"TypeError: helpers is not a function"},{"fix":"Set partialRoot to absolute directories containing partials; also register with rollup-plugin-root-import.","cause":"partialRoot not set or incorrect paths.","error":"Error: Partial 'path/to/partial' not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}