Giles Butler
Giles Butler

Reputation: 1001

Trying to create a Meteor Package

I've been trying to create a Smart Package for the SkelJS framework. The file is being loaded by the browser but when I try and access the object it exports it says its undefined. I'm using the following code in package.js:

Package.describe({
  summary: "SkelJS for Meteor"
});

Package.on_use(function (api) {
  api.use('jquery', 'client');
  api.add_files(['skel.js'], 'client');

  api.export('skel', 'client');
});

Also trying to access Package.skeljs.skel returns undefined as well.

In smart.json I'm using:

{
  "name": "skeljs",
  "description": "SkelJS for Meteor",
  "homepage": "",
  "author": "Giles Butler  (http://giles.io)",
  "version": "0.1.0",
  "git": ""
}

I know SkelJS has been loaded because it logs to the console no configuration detected, waiting for manual init but then when I try and run skel.init() it returns undefined.

Any help or tips would be really appreciated.

Thanks

Giles

Upvotes: 0

Views: 505

Answers (1)

Tarang
Tarang

Reputation: 75945

You also need to modify the first line of skel.min.js/skel.js

Within packages variable scoping still applies so you have to remove the var keyword if you want the file to let other files (such as package.js for api.export) access its variables.

The fix would be to change:

var skel=function() ....

to

skel=function() ....

Upvotes: 5

Related Questions