{"id":27410,"library":"spacebars-compiler","title":"Spacebars Compiler","description":"Spacebars Compiler compiles Spacebars templates (Handlebars-based syntax used in Meteor) into JavaScript modules compatible with Node.js and browser bundlers. Currently at version 1.6.0. It provides both CLI and programmatic usage for transforming templates into renderable JS functions. Key differentiator: it targets Meteor's Spacebars dialect, not general Handlebars, and supports i18n. Release cadence appears low as the author eface2face maintains it sporadically. Use when migrating Meteor templates to standalone Node/browser apps.","status":"active","version":"1.6.0","language":"javascript","source_language":"en","source_url":"git@github.com:eface2face/spacebars-compiler","tags":["javascript"],"install":[{"cmd":"npm install spacebars-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add spacebars-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add spacebars-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is the compile function, but named export 'compile' is also available and preferred for ESM.","wrong":"const compile = require('spacebars-compiler').compile","symbol":"compile","correct":"import { compile } from 'spacebars-compiler'"},{"note":"Require returns an object that includes compile, so destructuring is needed; direct call fails.","wrong":"const compile = require('spacebars-compiler')","symbol":"default","correct":"import compile from 'spacebars-compiler'"},{"note":"For CommonJS, destructure to get the compile function, otherwise you get the namespace object.","wrong":"const compile = require('spacebars-compiler')","symbol":"compile","correct":"const { compile } = require('spacebars-compiler')"}],"quickstart":{"code":"import { compile } from 'spacebars-compiler';\nconst source = '{{#each items}}<li>{{name}}</li>{{/each}}';\nconst options = { isBody: true, useGlobalScope: false };\nconst output = compile(source, options);\nconsole.log(output);","lang":"typescript","description":"Compile a basic Spacebars template string into a JavaScript function string."},"warnings":[{"fix":"Ensure your templates are Meteor Spacebars templates; use a different compiler for Handlebars.","message":"The compile function expects Spacebars-specific syntax (e.g., {{#each}}, {{#with}}), not standard Handlebars.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Check file permissions and use --dir to specify an existing directory.","message":"If using the CLI, ensure the output file path is writable and directories exist.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Add declare module 'spacebars-compiler' or install community typings.","message":"The package does not ship bundled type definitions; TypeScript users need to provide their own or use @types/spacebars-compiler if available.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install spacebars-compiler' and ensure it's in your dependencies.","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'spacebars-compiler'"},{"fix":"Use const { compile } = require('spacebars-compiler');","cause":"Importing the default export incorrectly in CommonJS (require returns an object).","error":"TypeError: compile is not a function"},{"fix":"Validate template strictly against Spacebars grammar.","cause":"Template contains syntax not valid Spacebars; may be using standard Handlebars helpers.","error":"Unexpected identifier: '...'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}