@@ -110,6 +110,7 @@ static JSValue load_standalone_module(JSContext *ctx)
110110static int eval_buf (JSContext * ctx , const void * buf , int buf_len ,
111111 const char * filename , int eval_flags )
112112{
113+ bool use_realpath ;
113114 JSValue val ;
114115 int ret ;
115116
@@ -119,7 +120,8 @@ static int eval_buf(JSContext *ctx, const void *buf, int buf_len,
119120 val = JS_Eval (ctx , buf , buf_len , filename ,
120121 eval_flags | JS_EVAL_FLAG_COMPILE_ONLY );
121122 if (!JS_IsException (val )) {
122- if (js_module_set_import_meta (ctx , val , true, true) < 0 ) {
123+ use_realpath = (* filename != '<' ); // ex. "<cmdline>"
124+ if (js_module_set_import_meta (ctx , val , use_realpath , true) < 0 ) {
123125 js_std_dump_error (ctx );
124126 ret = -1 ;
125127 goto end ;
@@ -669,7 +671,8 @@ int main(int argc, char **argv)
669671 JS_FreeValue (ctx , args [1 ]);
670672 JS_FreeValue (ctx , args [2 ]);
671673 } else if (expr ) {
672- if (eval_buf (ctx , expr , strlen (expr ), "<cmdline>" , 0 ))
674+ int flags = module ? JS_EVAL_TYPE_MODULE : 0 ;
675+ if (eval_buf (ctx , expr , strlen (expr ), "<cmdline>" , flags ))
673676 goto fail ;
674677 } else if (optind >= argc ) {
675678 /* interactive mode */
0 commit comments