An esbuild plugin for compiling Handlebars templates (.hbs, .handlebars) into JavaScript modules. Current stable version is 1.1.0. It resolves the 'Cannot read properties of undefined (reading call)' error common in other plugins, supports custom helpers/partials injection, and uses Handlebars precompilation for optimal performance. Key differentiators: fixes nested helper calls, integrates seamlessly with esbuild's build pipeline, and is lightweight with no extra runtime dependencies.
npm install esbuild-handlebarsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: require the plugin, create options with a filter and optional helpers, then add to esbuild plugins list.
Set the filter option to a RegExp that matches your Handlebars file extensions, e.g., /\.(hbs|handlebars)$/i.
Use absolute or relative paths to .js files that export the helper/partial, not inline functions.
Add a declaration file (e.g., 'esbuild-handlebars.d.ts') with: declare module 'esbuild-handlebars' { export default function hbsPlugin(options?: any): any; export const handlebarsPlugin: typeof hbsPlugin; }Update to esbuild-handlebars v1.1.0, which resolves this issue. Install the latest version: npm install -D esbuild-handlebars@latest.
Add the plugin to the 'plugins' array in your esbuild config: plugins: [require('esbuild-handlebars')(options)].No dependency data recorded yet.