Registry / web-framework / rollup-plugin-handlebars-plus

rollup-plugin-handlebars-plus

JSON →
library0.4.2jsnpmunverified

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.

npm install rollup-plugin-handlebars-plus
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-HAND
R
rollup-plugin-handlebars-plus
web-frameworkjavascriptv0.4.2
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

handlebars
import handlebars from 'rollup-plugin-handlebars-plus'
const handlebars = require('rollup-plugin-handlebars-plus')
Default import is the plugin function. Works in both ESM and CJS environments.
handlebars
import { default as handlebars } from 'rollup-plugin-handlebars-plus'
const { handlebars } = require('rollup-plugin-handlebars-plus')
Named export not available; use default import.
Template
import Template from './template.hbs'
const Template = require('./template.hbs')
Imported templates are functions (precompiled). CJS require will not have the transformation unless wrapped.

Shows a basic rollup config using the plugin, importing a .hbs template and rendering it.

// main.js import handlebars from 'rollup-plugin-handlebars-plus'; import rootImport from 'rollup-plugin-root-import'; // rollup.config.js export default { input: 'main.js', plugins: [ rootImport({ root: [`${__dirname}/src/views`], }), handlebars({ handlebars: { id: 'handlebars', }, helpers: ['/utils/helpers.js'], partialRoot: [`${__dirname}/src/views`], }), ], output: { format: 'esm', file: 'bundle.js', }, }; // template.hbs <h1>{{title}}</h1> // Use in main.js import tmpl from './template.hbs'; document.body.innerHTML = tmpl({title: 'Hello'});
Debug
Known issues
deprecatedPlugin has no updates since 2020; consider alternatives like @rollup/plugin-handlebars or vite-plugin-handlebars.
fix
Migrate to @rollup/plugin-handlebars or use a different bundler plugin.
affects: >=0.4.2
breakingIn version 0.4.0, the plugin requires the `handlebars` option object with `id` or `module`; omitting it breaks the build.
fix
Provide handlebars option: { id: 'handlebars' } or { module: require('handlebars') }.
affects: >=0.4.0
gotchaIf using helpers option, the helper module must export a function that accepts Handlebars runtime as argument, else it fails silently.
fix
Ensure helper modules export default function(Handlebars) { ... }.
affects: >=0.0.0
deprecatedThe plugin includes a bundled Handlebars runtime that may be outdated; security vulnerabilities have been reported in older Handlebars versions.
fix
Update to >=0.4.1 which bumps handlebars dependency to 4.6.0, or provide custom handlebars via handlebars.module option.
affects: <0.4.1
Errors
Common errors & fixes
Error: Could not resolve 'handlebars' (from ...)
Missing rollup-plugin-node-resolve and rollup-plugin-commonjs to resolve the runtime.
fix
Add plugins: nodeResolve({ browser: true }), commonjs() to your rollup config.
Error: Cannot find module 'handlebars'
Handlebars runtime not installed or not in node_modules.
fix
Run: npm install handlebars
TypeError: helpers is not a function
Helper module does not export a function that accepts Handlebars as argument.
fix
Export default function(Handlebars) { ... } from your helper module.
Error: Partial 'path/to/partial' not found
partialRoot not set or incorrect paths.
fix
Set partialRoot to absolute directories containing partials; also register with rollup-plugin-root-import.
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies
rollup-plugin-node-resolveoptionalRequired to resolve the Handlebars runtime module (commonjs)
rollup-plugin-commonjsoptionalRequired to convert Handlebars runtime CJS module to ESM
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-handlebars-plus — npm install rollup-plugin-handlebars-plus · libregistry