Unable to use Meteorhacks:SSR inside a private package


#1

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’


#2

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


#3

I did…

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

Thanks!


#4

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


#5

I did…

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


#6

Well, I’m out of ideas :stuck_out_tongue:


#7

Yeah me too, thanks anyways!


#8

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.


#9

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


#10

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.


#11

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