Need a way to determine the engine rendering the view

I’m poking at adding better webpacker support for engines. As part of that, I’ve been hunting around for ways to determine which engine is currently rendering a given view, and I’m coming up empty. The idea is this (and it may be stupid/too much magic, feel free to share your thoughts): if the view is in the main app, it should default to using the webpacker instance from the main app. If the view is in an engine, it should default to using the webpacker instance from the engine. My challenge is that, from the javascript_pack_tag (and similar helpers) I see no clean way to determine the engine rendering that view, so I don’t know which webpacker instance to use.

I have two questions:

  1. Is there a way to do this today that I missed? Routes seem to work like this, but I’ve found that codebase a tad opaque.
  2. If not, and folks would be amenable to such a feature, can I get some pointers for where to start?
2 Likes