jerryscript-project / jerryscript

Ultra-lightweight JavaScript engine for the Internet of Things.
https://jerryscript.net
Apache License 2.0
6.89k stars 669 forks source link

[QUESTION] access module information from module_import_meta_callback #5038

Open FranckFreiburger opened 1 year ago

FranckFreiburger commented 1 year ago

I wondering if it is possible to get the module filename from the module_import_meta_callback My aim is to implement import.meta.url The first argument of the callback is const jerry_value_t module, but I don't know if I can get this information from here.

FranckFreiburger commented 1 year ago

Is jerry_source_name() suitable for this purpose, (even if it depends on JERRY_SOURCE_NAME) ?

zherczeg commented 1 year ago

Seems so. There is a test for that https://github.com/jerryscript-project/jerryscript/blob/master/tests/unit-core/test-source-name.c#L123