List all importable modules in an Ember project
by Ryan Toronto
Have you ever
- forgotten the absolute path to
/config/environment.js
? - wondered what files an addon adds to your import path?
- gotten an error that looks like this?
Error: Could not find module 'some-addon/foo' imported from
'embermap-cms/pods/components/date-picker/component'
Here's a trick that will list every importable module in your Ember app. In the console, type
requirejs.entries
This will show you an object whose keys contain all importable paths.
If I'm looking for something specific (say, all modules provided by the ember-modal-dialog
addon), I might use Object.keys
and write a simple filter:
Object.keys(requirejs.entries).filter(n => n.includes("ember-modal-dialog"))
Just be aware that requirejs.entries
is considered private, so you shouldn't write any code that depends on it. Instead, think of it as a useful debugging tool.