xpost to StackOverflow, didn’t get anything.
I’m trying to repackage Gibberish.js for Meteor, and so far nothing is working. The package has its own npm dependencies. I first tried to fork it and then load it as a git submodule. I had this in my package.js:
Npm.depends({
"connect": "2.25.7",
"serve-static": "1.5.3",
"uglify-js": "2.4.15"
});
Package.onUse(function(api) {
api.versionsFrom('1.1.0.2');
api.addFiles('build/gibberish.js', ['client','server']);
});
It complained that Gibberish.init() wasn’t a function, so I’m guessing it didn’t see the package. So then I realized gibberish-dsp is its own npm package, so I tried to include it via npm. I used this:
package.js
Npm.depends({
"connect": "2.25.7",
"serve-static": "1.5.3",
"uglify-js": "2.4.15",
"gibberish-dsp": "2.3.2"
});
Package.onUse(function (api) {
api.addFiles([
'lib/gibberish.js',
], ['server']);
api.export([
'gibberish'
]);
lib/gibberish.js:
juice = Npm.require('gibberish-dsp');
That gave it a callback error. I guess Meteor can’t do callbacks with third party packages?! So I tried meteorhacks:npm, which apparently fixes the callback error. And I tried this:
if (Meteor.isServer) {
console.log('server');
var gibberish = new Gibberish();
var init = Async.wrap(init);
gibberish.init();
}
});
And with my gibberish submodule in my /packages/ folder, I get a SyntaxError: Unexpected token Y, referring to “Bad HTML” in the gibberish package. Apparently it’s trying to read it as a Meteor HTML file (i.e. without DOCTYPE etc.) I don’t want to change every single file in the package!
And I am using meteor add user:gibberish to add it.
I’ve probably spent about 20 hours on this already. Why is it so hard to load an external library?!?! What else can I do? I want to like Meteor but I’m ready to give up.