SpacebarsCompiler is undefined

I am not sure if this is the right place to ask but…

I use a package for server side rendering called meteorhacks:ssr. It is old but has worked reliably for years. Apparently blaze is undergoing active development again, because there are updates to it, spacebars-compiler and related packages. When I try update with --all-packages meteorhacks:ssr breaks with SpacebarsCompiler is undefined. Apparently this was a variable in global scope? Anyway, I pulled the source and I can see how to fix it for now with a kludge, but my question is

Is there a better more modern way to do SSR with blaze instead of this ancient package I am using? My specific use case is generating html and text as string for email templates using templates that use spacebars.


Meteor update informs me

Newer versions of the following indirect dependencies are available:
 * blaze 2.3.4 (2.4.0 is available)
 * blaze-tools 1.0.10 (1.1.0 is available)
 * caching-html-compiler 1.1.3 (1.2.0 is available)
 * html-tools 1.0.11 (1.1.0 is available)
 * htmljs 1.0.11 (1.1.0 is available)
 * spacebars 1.0.15 (1.1.0 is available)
 * spacebars-compiler 1.1.3 (1.2.0 is available)
 * templating 1.3.2 (1.4.0 is available)
 * templating-compiler 1.3.3 (1.4.0 is available)
 * templating-runtime 1.3.2 (1.4.0 is available)
 * templating-tools 1.1.2 (1.2.0 is available)
These versions may not be compatible with your project.
To update one or more of these packages to their latest
compatible versions, pass their names to `meteor update`,
or just run `meteor update --all-packages

So I try the updates. I get an exception on run from a package I use meteorhacks:ssr which is pretty old but has worked well for years.

ReferenceError: SpacebarsCompiler is not defined
    at packages/meteorhacks_ssr.js:195:18
    at packages/meteorhacks_ssr.js:226:4
    at packages/meteorhacks_ssr.js:235:3
    at /home/shartman/glo/dev/.meteor/local/build/programs/server/boot.js:401:38
    at Array.forEach (<anonymous>)
    at /home/shartman/glo/dev/.meteor/local/build/programs/server/boot.js:226:21
    at /home/shartman/glo/dev/.meteor/local/build/programs/server/boot.js:464:7
    at (/home/shartman/glo/dev/.meteor/local/build/programs/server/profile.js:280:14)
    at /home/shartman/glo/dev/.meteor/local/build/programs/server/boot.js:463:13
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.

The answer for me with the latest blaze updates is

meteor add spacebars-compiler

import { SpacebarsCompiler } from “meteor/spacebars-compiler”;

1 Like

same solution worked for me too.

  1. meteor add spacebars-compiler
  2. download meteor-ssr into the packages folder
  3. add import { SpacebarsCompiler } from “meteor/spacebars-compiler” to the top of api.js file
1 Like

In my case, I got this error:

W20210414-16:57:55.470(-5)? (STDERR) packages/meteorhacks_ssr.js:193
W20210414-16:57:55.470(-5)? (STDERR) import { SpacebarsCompiler } from 'meteor/spacebars-compiler';
W20210414-16:57:55.470(-5)? (STDERR) ^^^^^^
W20210414-16:57:55.470(-5)? (STDERR) 
W20210414-16:57:55.471(-5)? (STDERR) SyntaxError: Cannot use import statement outside a module

Also, I tried to use this way:

var SpacebarsCompiler=Package['meteor/spacebars-compiler'];

But I got another error, where SpacebarsCompiler is undefined.

Any suggestion?


  • I use Typescript.
  • Meteor 2.1.1
  • Node 12.18

Figured this might be useful info from the Meteor Community slack workspace…



Someone opened the issue on github. See the solution there. Same concept I recommended but better code: Basically replaces the meteorhacks:ssr package.

[2.1.1] SpacebarsCompiler is not defined · Issue #11387 · meteor/meteor · GitHub

1 Like

Hi, this is fixed.

See the new versions here Re-add exports by zodern · Pull Request #328 · meteor/blaze · GitHub

Sorry for the trouble :wink: