-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requiring service dependency declaration in engine.js
is fragile
#732
Comments
The "request" (what the I definitely think it would be reasonable to add an option to |
Having an option that ensures the service contracts between the host and engine is helpful for the part of the contract. Besides that, I was wondering if we can come up with a way that eliminates or automates the process of specifying services in |
Sounds good, happy to help folks with a PR to do this.
I've discussed this a bit with a few coworkers (@aghassemi). I'm not 100% opposed (and in fact I think @aghassemi has a spike that functions properly), but we have to be pretty careful here. The goal of ember-engines is to provide a level of isolation between the engine and the host application and a setting that effectively lets the engine access any arbitrary service from the host app would absolutely break any isolation that we have here. |
I think the ideal from my perspective is at minimum something that warns the developer if the app is not providing all of the services the engine has specified as dependencies. Combined with linting to ensure that the engine doesn't use any external services it hasn't declared as dependencies, this would make use of engines a lot more robust and eliminate the common pitfalls of having to specify the dependencies in two places (engine and app). Too often we see developers use new app-level services in their engines and fail to define them in dependencies, either for the engine's config or for on the consumption side. That said, I'm not sure what the concern is with allowing the engine to declare any arbitrary service as a dependency. If an engine says it needs |
Was seeing a couple of instances where forgetting to declare services in engine dependencies caused production issues. There isn't a check that ensures services invoked in engines are properly provided by the host application. So if the service is missed in the
engine.js
list, the service will not be provided by the app and might cause issues.I was thinking if there is a way that
ember-engine
checks and ensures the app provides services required automatically without requiring an explicit list of service dependencies, or at least checks services declared inengine.js
and throws errors if any service is missed during the build time. Any thoughts?The text was updated successfully, but these errors were encountered: