DEV Community

Peter Mekhaeil
Peter Mekhaeil

Posted on • Updated on


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:

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.

Top comments (0)

Why You Need to Study Javascript Fundamentals

The harsh reality for JS Developers: If you don't study the fundamentals, you'll be just another “Coder”. Top learnings on how to get to the mid/senior level faster as a JavaScript developer by Dragos Nedelcu.