I would like to generate some code from my object tree. In order to generate the required import statements, I need to find out the source code location for a given class from a class instance.
I am already able to get the expected name MyClass
with
var name = instance.constructor.name;
but not the source code location
'/src/package/myClass.js'
=>How to do so?
For Java it would work like described here:
Find where java class is loaded from
If I inspect the constructor in Chrome developer tools with dir(constructor), I can see some property
[[FunctionLocation]]: myClass.js:3
and if I hover over it, I can see the wanted path. How can I get that property programmatically?
Edit
Just found that [[FunctionLocation]] is not accessible: