Open elwayman02 opened 2 days ago
it's a common practice to properly namespace service injections
via @
? is that supported by ember? (like, would it work in embroider/webpack/vite?)
are there docs or an RFC on this?
The @
doesn't work under embroider with staticAddonTrees enabled (which will be a default in the next major). I wouldn't recommend anybody use it.
I appreciate the desire to make it clearer where a service is coming from but that needs to happen via a real import, like in ember-polaris-service. Otherwise you're just making the "Ember apps are hard to build and optimize because they don't use real imports" problem worse.
In the current Ember world where we don't yet have a specific pattern for importing a service class and injecting it directly, it's a common practice to properly namespace service injections so you know where they're coming from. Since many addons provide services that may have duplicate names, this is the only way to ensure you're using the service instance you expected to inject.
However, the way
setupBrowserFakes
is written doesn't account for this possibility, causing test mocking to fail.Given the following service injection:
setupBrowserFakes
will not correctly replace the proxy values, because it registers the browser fakes tobrowser/navigator
rather thanember-browser-services@browser/navigator
(and so on for the other services).This can be seen here: https://github.com/CrowdStrike/ember-browser-services/blob/main/ember-browser-services/src/test-support/index.ts#L39-L66
We need to devise a way to support both injection patterns within this addon's test-support.