@@ -110,6 +110,7 @@ static JSValue load_standalone_module(JSContext *ctx)
110
110
static int eval_buf (JSContext * ctx , const void * buf , int buf_len ,
111
111
const char * filename , int eval_flags )
112
112
{
113
+ bool use_realpath ;
113
114
JSValue val ;
114
115
int ret ;
115
116
@@ -119,7 +120,8 @@ static int eval_buf(JSContext *ctx, const void *buf, int buf_len,
119
120
val = JS_Eval (ctx , buf , buf_len , filename ,
120
121
eval_flags | JS_EVAL_FLAG_COMPILE_ONLY );
121
122
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 ) {
123
125
js_std_dump_error (ctx );
124
126
ret = -1 ;
125
127
goto end ;
@@ -669,7 +671,8 @@ int main(int argc, char **argv)
669
671
JS_FreeValue (ctx , args [1 ]);
670
672
JS_FreeValue (ctx , args [2 ]);
671
673
} 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 ))
673
676
goto fail ;
674
677
} else if (optind >= argc ) {
675
678
/* interactive mode */
0 commit comments