[quickjs-devel] Re: Partially eval script excluding global code

  • From: Jason Cahill <jason@xxxxxxxxxxxx>
  • To: "quickjs-devel@xxxxxxxxxxxxx" <quickjs-devel@xxxxxxxxxxxxx>
  • Date: Sun, 19 Jan 2020 18:20:33 +0000

It sounds like you want module import with side-effects:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

That’s a standard JavaScript feature.

On Jan 18, 2020, at 1:49 AM, JM <jeevhi@xxxxxxxxx> wrote:


Hi, Is it possible to eval the script excluding the global code? I am 
essentially trying to load scripts with functions that can be called later. 
However, if script has any global statement, I do not want them to be executed. 
I need to do this at runtime since the scripts will be loaded by users.

For example,  if I have script like this

function myFunction() {  <--- this can be called later

}

x = 1 + 2; <----- this should not be executed



Other related posts: