Registry / serialization / rollup-plugin-hbs

rollup-plugin-hbs

JSON →
library1.2.6jsnpmunverified

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.

npm install rollup-plugin-hbs
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-HBS
R
rollup-plugin-hbs
serializationjavascriptv1.2.6
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.

hbs
import hbs from 'rollup-plugin-hbs'
const hbs = require('rollup-plugin-hbs')
ESM only; CommonJS require() will fail because package exports an ESM module.
default
import hbs from 'rollup-plugin-hbs'
import { hbs } from 'rollup-plugin-hbs'
The plugin exports a single default function; named import will be undefined.
Handlebars
import Handlebars from 'handlebars'
import Handlebars from 'rollup-plugin-hbs'
Handlebars must be imported separately; it is not re-exported by this plugin.

Configures Rollup to compile Handlebars templates, importing a template and rendering it with data.

// rollup.config.js import hbs from 'rollup-plugin-hbs'; import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; export default { input: 'src/main.js', output: { file: 'bundle.js', format: 'iife' }, plugins: [ resolve(), commonjs(), hbs({ handlebars: { id: 'handlebars', options: { sourceMap: true }, optimize: true }, templateExtension: '.hbs', isPartial: (name) => name.startsWith('_') }) ] }; // src/main.js import template from './template.hbs'; const html = template({ name: 'world' }); console.log(html); // src/template.hbs <p>Hello {{name}}!</p>
Debug
Known issues
deprecatedPackage is no longer maintained; no updates since 2020
fix
Migrate to @rollup/plugin-handlebars or rollup-plugin-handlebars-plus
affects: >=1.0.0
breakingIncompatible with Rollup >=2.0 due to plugin API changes
fix
Use an older version of Rollup (0.x) or switch to a maintained plugin
affects: >=1.0.0
gotchaTemplate filenames starting with '_' are automatically treated as partials and not included in output if not imported
fix
Ensure partials are imported explicitly or adjust isPartial logic
affects: >=1.0.0
gotchaSourcemaps may be incomplete due to lack of Rollup 2+ support
fix
Disable sourcemaps or use alternatives
affects: >=1.0.0
deprecatedrollup-pluginutils is deprecated; plugin uses its functionality internally
fix
Not directly fixable; migrate to a plugin that uses modern Rollup APIs
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-hbs'
Package not installed or missing from node_modules
fix
npm install rollup-plugin-hbs --save-dev
TypeError: hbs is not a function
Using CommonJS require() instead of ESM import
fix
Use 'import hbs from 'rollup-plugin-hbs'' in an ESM context
Error: Could not resolve './template.hbs' from 'src/main.js'
Rollup cannot resolve .hbs files; plugin not configured correctly
fix
Ensure rollup-plugin-hbs is added to plugins array and templateExtension matches file extension
Error: The 'handlebars' module is not installed
Handlebars is a peer dependency not installed
fix
npm install handlebars
Upgrade
Version history
1.2.6latest on npm
Audit
Dependencies
handlebarsrequiredRuntime dependency for template compilation and execution
rolluprequiredPeer dependency for Rollup integration
rollup-pluginutilsrequiredProvides utility functions for Rollup plugins
Agent activity
2 hits · last 30 days
node
2
Resources
rollup-plugin-hbs — npm install rollup-plugin-hbs · libregistry