I'm using Bun, and I would like to get the module path from a React component.
I'm looking for something like this:
const myComponent = <MyComponent />
const myComponentPath = myComponent.getPath()
Obviously my example does not work.
How can I get the path so I could dynamically import this module later?
For example:
const { default: MyComponent } = await import(myComponentPath)
const myComponent = <MyComponent />
If you mean in code at runtime, you can't. The module specifier (path) isn't stored anywhere on components exported from modules.