Upgrading Meteor v1.0 to v1.2: server not recognized under Meteor methods under /lib


#1

The following code architecture works in up to Meteor 1.0 but breaks in Meteor 1.2
Any insights/suggestions are appreciated.

in server/file1.coffee:

class ClassA
    {code for the class} 
@MyObj = new ClassA()

in /lib/collections/file2.coffee:

Meteor.methods 
   myFunction : ->
      if Meteor.isServer
          console.log 'isServer'
      if MyObj?
        {do stuff}

Note that while myFunction is defined in /lib directory and called from /client it runs on the server in Meteor version 1.0, as evidenced by logs printed from within that function under Meteor.isServer. This is not the case in version 1.2. Under 1.2, Meteor.isServer is never true and it’s log doesn’t print.

Has anyone seen anything like this issue ?

EDIT: this post seems to be similar: https://github.com/meteor/meteor/issues/5113 but it doesn’t have an apparent resolution.

Thanks!


#2

If this was working I’m pretty sure it would have been a bug. Regardless, it won’t work anymore. Anything defined under a client directory/sub-directory is excluded from being bundled for Node. This means client/ code will only run client side, and anything running client side will always have Meteor.isServer set to false.


#3

Thank you for your response. I had a typo in my question. Please note that the meteor method was defined under /lib not client/lib. Please see updated question.