Closed pfmescher closed 10 years ago
Thanks for reporting this. Can you confirm that this is fixed in v0.1.7 or HEAD?
Fix confirmed. Works great now :)
However, I'm now trying to import an external file with a sibilant object into the main app and it's throwing again. I don't know if it is a bug, but the documentation doesn't explain how to add external .sibilant files so I'm not sure how to properly do this..
config.sl
{ secret "this is my secret" port 3000 }
console
pablo@linux-oto5:~/notes> sibilant -x app.sl
/home/pablo/notes/config.sl:1
nction (exports, require, module, __filename, __dirname) { { secret "this is m
^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected string
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/pablo/notes/app.sl:3:14)
at Module._compile (module.js:456:26)
at runInSandbox (/usr/local/lib/node_modules/sibilant/lib/cli.js:32:23)
at /usr/local/lib/node_modules/sibilant/lib/cli.js:133:18
I'm trying to import the file as you would an external JSON file. Changing the filename to .json and fixing the syntax works though, so it's nothing I can't live without.. just thought it would be nice
1) Sibilant only registers the .sibilant extension. require
-ing a .sl file won't be recognized as sibilant. I'm open to registering other extensions, but at the moment it's just .sibilant
.
2) If you put json in a .sibilant file and require it, sibilant will do exactly what node would do, which is to export an empty object because there are no module.exports
. If you want to export the contents of your file, you'll need to either (set module 'exports { secret "this is my secret" port 3000 })
or require it as json.
Potentially, I could add an extension for "sibilant-flavored json" but I'm not entirely convinced it's worth it. It would have to be a distinct extension from a sibilant/node module, though. Maybe something like .sjson
. So the short answer is "the feature you were expecting doesn't exist yet, and wouldn't work quite like that if it did"
Thanks for the clarification. As I said earlier, the documentation is not quite open about this.. We can keep the bug closed then :)
I'm currently trying to make a small api using sibilant and express and when I try to run the app using sibilant directly, it is not resolving the express import correctly.
Console output:
app.sl: