alongubkin / spider

Unsurprising JavaScript - No longer active
http://spiderlang.org
Apache License 2.0
1.34k stars 46 forks source link

ReferenceError: System is not defined #99

Closed sagiegurari closed 9 years ago

sagiegurari commented 9 years ago

when running under nodeJS (not browser), in spider.js you start with System.register but there is no var System = require(...) so System is not defined.

alongubkin commented 9 years ago

Are you compiling the script with spider -c and then run it on node, or execute the script through spider (spider script.spider)?

sagiegurari commented 9 years ago

running the spider.compile via node

sagiegurari commented 9 years ago

var spider = require('spider-script'); spider.compile(....);

see at: https://github.com/sagiegurari/node-spider-script/blob/master/lib/spider-loader.js

it works good with 0.0.6 and 0.0.7, but with the 0.1.x you changed to use that system.register that should be defined at begining of script file.

alongubkin commented 9 years ago

Okay, fixed in 0.1.3. Please note that the spider.compile has been refactored. It will be documented soon.

Usage:

var out = spider.compile({
  text: "var x = 5;",
  fileName: "test.spider",
  target: "ES5", // (or "ES6")
  generateSourceMap: true
});

The out object has 3 properties: errors, result and sourceMap.

To print errors, you can use the spider.formatErrors API. For example:

console.log(spider.formatErrors("test.spider", "var x = 5;", out.errors));

beatzlaha, and thanks for your plugin :)

sagiegurari commented 9 years ago

great. i'll try it out tomorrow and release a new version based on it. thanks for the quick fix.

sagiegurari commented 9 years ago

works good and I made the changes as per you comment. I saw the lang changed a bit (from func to fn) so I fixed my test cases as well.