I found the problem. I also have to include "<script src='baselib.js'>...".
I am converting an existing project and at this point am compiling each file individually with make. None of them import baselib so it was never getting loaded.
But "import baselib" doesn't seem to work so I'm a little confused on how baselib gets included in a normal project. The baselib code is not added to any of my files.
On 01/20/2015 11:00 AM, Wiff wrote:
Sorry, I was not very clear.
I am including the file via "<script src='stdlib.js'>..."
I had not tried to use "import stdlib", but I just did and I still get the error.
I am using:
rapydscript $1 -p --comments all --screw-ie8 --output $2
I tried it without screw-ie8 and there was no change.
I am not yet trying to use any functionality of stdlib. I gets the error when the file is read:
"Uncaught ReferenceError: _$rapyd$_extends is not defined"
function IndexError() {
this.__init__.apply(this, arguments);
}
_$rapyd$_extends(IndexError, Error);
IndexError.prototype.__init__ = function __init__(message){
var self = this;
I see, --comments option is something I haven't tested much, so it's possible I broke it somewhere along the way. In fact, I don't even document it, because I got it as a freebie from using UglifyJS as a base. Is there a reason why you need to include those files in HTML separately rather than importing them all through RapydScript itself, which would take care of dependencies and baselib for you?
There are a few disadvantages to compiling files separately:- you'll need to manually include baselib unless you want it duplicated (compiling them together will cause no duplication)- you prevent RapydScript from automatically detecting classes from other modules (which will require you to either use the "new" keyword or declare @external class in each module that uses it)- if you want those modules to interact (in which case you should almost definitely compile them together), you'll need to use --bare compile option to prevent them from executing in a private scope (this option will leak all of your code into global scope)