DEV Community

Peter Mekhaeil
Peter Mekhaeil

Posted on • Edited on

6 4

Svelte components have file location meta data

Svelte nodes have a __svelte_meta object in development mode that contains the file location of the component that rendered that node.

{
    "loc": {
        "file": "src/routes/index.svelte",
        "line": 18,
        "column": 4,
        "char": 358
    }
}
Enter fullscreen mode Exit fullscreen mode

You an try it out on StackBlitz. Inspect an element using the Chrome Dev Tools and use the console:

$0.__svelte_meta
Enter fullscreen mode Exit fullscreen mode

Screenshot 2022-05-07 at 9 25 47 AM

($0 references the last selected DOM element. It is part of the DevTool's Console API)

Learn more about __svelte_meta:

Today I Learned
I share what I learn on Today I Learned.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay