ember.js icon indicating copy to clipboard operation
ember.js copied to clipboard

[Bug] Service injections doesn't work with `index` files

Open chancancode opened this issue 3 years ago β€’ 2 comments

🐞 Describe the Bug

In most other places, you can equivalently have foo.js and foo/index.js (except in controller and routes where "index" has a special meaning) and expect things to work. However, if you have app/services/foo/index.js instead of app/services/foo.js you will get an error. Seems like we should be able to make it work?

πŸ”¬ Minimal Reproduction

  1. Create app/services/foo.js
  2. Inject it into a component or something else
  3. Observe that it works
  4. Rename the service to app/services/foo/index.js
  5. Observe that it doesn't work
  6. Add back app/services/foo.js and re-export from the index file manually
  7. Observe that it works

πŸ˜• Actual Behavior

Step 5 throws an error.

πŸ€” Expected Behavior

Step 5 should Just Workβ„’.

🌍 Environment

  • Ember: 3.26
  • Node.js/npm: -
  • OS: -
  • Browser: -

chancancode avatar Jun 17 '21 23:06 chancancode

I've reproduced in ember-source 5.1.1 here https://github.com/elgordino/service-injection-index

elgordino avatar Aug 12 '23 20:08 elgordino

Subscribing since I'm interested in a fix

spuxx-dev avatar Nov 13 '23 12:11 spuxx-dev