Addon that can inspect and import app code

I’m looking at building something that can help to detect code no longer in use in an app. I wrote up some of my ideas at Hooks available for finding dead code · Issue #5364 · ember-cli/ember-cli · GitHub. The suggestion there is to open an RFC, before I go down that path I was trying ot prototype it as an addon. I wanted to try to import the router and then go checking that controllers, views etc fall within the current routes.

I was hopeful that the addon hooks would give me a convenient point to try this, but haven’t found a good solution yet. If I try to do it as part of a custom command, and go and source the router file directly, its going to be ES6 and not importable. If I try to do it during the build command, none of the hooks seem to have the level of detail I’m looking for, or even an intermediate transpiled file path I can use.

My next idea is to try GitHub - ModuleLoader/es-module-loader: Polyfill for the ES Module Loader to help just loading router files, and I’ll see how far I can get with that.

Any ideas would be appreciated here. I get the feeling there’s something in the broccoli process that might be useful for me, but haven’t found it so far.