Here's the basic process I followed for implementing the "Show Route Components" feature in the demo apps I showed in my Remix conf talk.
Someone could probably generalize/improve this further and make it into a drop-in library :)
See the files below for the specifics, but here's the TL;DR:
- Add some css to make
[data-filepath]
look how you want - Annotate each route component with
data-filepath={__filename}
- (optional) Make a toggle component
- (optional) Make the path links clickable
- Make
__filename
resolve correctly for CRA (webpack config) - Make
__filename
resolve correctly for Remix (esbuild hackery)