Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: A bit more modularization

$
0
0
Hello ClearScript,

what I initially wanted was something like require in node.js:
Node.js
var app = require('modulename');

app.Method(...)

MyApp
externals.use('modulename'); // loads the script modulename and put it by _Evaluate_ to the running instance of the script engine

... usage...
I hoped to get a little more separation what it is in the app variable. Instead of require I had a package manager, who compiled the script that modulename refers. But I didn't find any way to use it (i.e. call a method explicit within the compiled script). I may add the compiled script to any script engine instance of the same runtime, but I cannot see any other usage for this scenario.

Meanwhile I think this approach is problematically. Because the compile method compiles only the script that's in the parameter and it will not been executed, something like a composition of scripts will fail when it refer to other objects and/or scripts and will bring to unexpected results because its never apparent what code is currently within the engine execution.

So it seems like I have to put down my idea and use it as it looks like: compile once and use it in many instances of the script engine.

Kindly regards,
Torsten

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>