Unable to use Meteorhacks:SSR inside a private package

Any insights appreciate into challenges I am having using the Meteorhacks:SSR package, package is defined in my package.js

api.use([
‘accounts-password’,
‘email’,
‘meteorhacks:ssr’,
], ‘server’) ;

When I use SSR server side (server/sendemail.js) as below

SSR.compileTemplate( ‘htmlEmail’, Assets.getText(‘private/passwordResetPlainText.html’));

I get the below error

Exception while invoking method ‘sendEmail’ TypeError: Object # Object> has no method ‘compileTemplate’

When you added the file to your package, did you specify that it is server-only?

I did…

api.use([
‘accounts-password’,
‘email’,
'meteorhacks:ssr’,
], ‘server’) ;

Thanks!

Right, I’m talking about when you added server/sendemail.js with api.addFiles.

I did…

api.addFiles([
‘server/Accounts.validateLoginAttempts.js’,
‘server/startup.js’,
server/email/sendEmail.js’,
], ‘server’);

Well, I’m out of ideas :stuck_out_tongue:

Yeah me too, thanks anyways!

Is SSR defined on the server?

You can start a meteor shell and type SSR to check.

If not, try using api.imply('meteorhacks:ssr'); in your package.js to ensure its exports are available to your app.

SSR is definitely defined on Server. When I get all methods on the SSR I get only the

objectconsole.log(EmailGenerator.getAllMethods(SSR));

Here is my output

[ ‘render’ ]

For some reasons it only finds the render method and not the compilTemplate method. I am using SSR in a login “private” package which is used by main app.

https://github.com/meteorhacks/meteor-ssr/blob/master/lib/api.js

Looks like the package is resolved to an old version. Can you check your .meteor/versions file, which version is resolved for meteorhacks:ssr? if you will see something like meteorhacks:ssr@1.0.0, just change the line to meteorhacks:ssr@2.1.1 after that everything will be smooth… Give me know, cheers.

3 Likes

well done it solves the issue :slight_smile:
just use meteorhacks:ssr@2.1.1 and It will work :slight_smile: