Rollup plugin that precompiles Handlebars templates into ES modules. Version 1.0.2 requires Node >=18 and Handlebars as a peer dependency. Generates ESM-only modules with TypeScript support, automatic partial detection, source maps, and convenient DOM integration via exported RawTemplate and Template functions. Unlike other Handlebars rollup plugins, it outputs DocumentFragment-ready modules with type definitions.
npm install rollup-plugin-handlebars-precompilerVerified import paths — ran on the pinned version, not inferred.
Shows rollup config with plugin setup and usage of imported Handlebars template to append a DocumentFragment to the DOM.
Use Node 18+ and import via ESM syntax only.
Run 'npm install handlebars' or 'pnpm add handlebars' in your project.
Make sure your bundler resolves the runtime; it is included automatically if rollup processes node_modules.
Validate template compilation with the plugin's specific configuration for partials and helpers.
Change require() to import and ensure rollup.config.js uses ESM (e.g., rename to .mjs or set type: module in package.json).
Run 'npm install handlebars' or 'pnpm add handlebars' in your project.
Add a global type declaration: declare module '*.hbs' { import type { TemplateFunction } from 'rollup-plugin-handlebars-precompiler'; const tmpl: TemplateFunction; export default tmpl; export const RawTemplate: (context?: any, options?: any) => string; }