dependency of variable name "Jscex"
Closed this issue · 3 comments
Is it possible to use other variable name instead of "Jscex" while importing jscex module in nodejs? For example:
var asynco = require("jscex");
require("jscex-jit").init(asynco);
require("jscex-async").init(asynco);
require("jscex-async-powerpack").init(asynco);
asynco.logger.level = 3;
var async_fn = eval(asynco.compile("async", function() {
console.log("hello async");
}));
async_fn().start();
The code above fails with error:
undefined:2
var _builder_$0 = Jscex.builders["async"];
^
ReferenceError: Jscex is not defined
at eval at <anonymous> (W:\a.js:9:28)
at Object.<anonymous> (W:\a.js:13:1)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)
at EventEmitter._tickCallback (node.js:190:38)
No we can't, at least for now. You could notice that the generated code has use the Jscex
expression directly. I've also thought about the same requirement but finally I decided to go with the current approach. That's a trade off considering the usability and the strange stuff the library does.
I'm going to close the issue, but feel free to continue posting comments and kindly giving your ideas and advice here.
While writing code like var root = require('jscex');
, it's natural to believe that all depenencies are put inside the "root" namespace. So an additional global "Jscex" dependency might bring some feeling of "unperfect", especially when I'm forced to write var Jscex = require("jscex");
.
If the existance of the global name "Jscex" is a must for jscex library, is it possible to create it automatically inside the library initialization code?
It might be the perfectionism of my own, but I don't think the global name dependency is a good idea.
Thanks for your efforts on this library, it's so good and I should not ask more.
I agree with you that it's not perfect to force the user to choose Jscex
as root name, but it's really a trade-off and hard decision after thinking during several weeks, but any other choices seem even worse for a user to define Jscex functions.
I'll keep thinking about it and thanks for your ideas.