简体   繁体   中英

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

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() ....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM