-
Notifications
You must be signed in to change notification settings - Fork 140
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
Managing common dependancies between the host app and engines #502
Comments
We are having the same issue, and would benefit from some extra documentation/clarification. (+@dgeb) |
@dgeb Is there a solution for this? or does a feature need to be created for it? |
@MelSumner you found any solutions to this? |
We are thinking on our side to use Problem we have left with that is that we would still need to run every engine's tests together with the parent app tests, to make sure the new common addon version doesn't actually break the engines. Anyone knows how to do that? |
This might not work for everyone, but we've recently moved our app + engines to a yarn workspace, roughly following this guide: https://medium.com/square-corner-blog/ember-and-yarn-workspaces-fca69dc5d44a Now we run the tests for the host app & all engines in CI whenever we make a change to any of the engines. |
So there seems to be some unpredictable behaviour with common addon dependencies in lazy loaded engines with host version modules (of the same addon). We've seen the host version modules being overridden with the engine's version causing bugs. Would the solution be for engines to build its dependencies into it's own namespace? |
I wanted to leave a note that this issue has caused my company a lot of confusion as well. What is happening is that if you have multiple lazy-loading engines, and each engine has a shared dependency on a common addon whichever engine loads first will get its version of the addon defined for every other engine and even the HOST APP if it invokes the same component name. This is an issue if you are using engines to spread domain concerns down to individual teams because they all have to be in lock step with what version of this shared addon they use or else risk errors when component APIs change and a user doesn't load a particular engine first. Most interestingly the code for all versions of the shared addon does exists within the engine-vendor.js source, however the namespace for its |
@nmcclay happy to help with this as well. i'll do some digging. |
So I played around with this and I have what seems to be a solution. Basically its a two part solution, first the shared addon needs a namespace configuration in its index.js:
Then you can provide this namespace to your addon from your engine's
Finally, in your engine's addon directory, you can declare a uniquely named component that will export this namespaced version of the addon declared in your
(edit: cleaned up index.js implementation) |
Thanks for the discussion so far, and apologies for taking so long to get involved myself. I'd like to share a helpful repo from @CodeOfficer that explores dependency conflicts between apps, engines, and addons: https://github.com/CodeOfficer/demo-engine-addon-dependency-conflicts The README clearly lays out several types of conflicts that can be reproduced. Some conflicts are very difficult to solve in a general case, but I believe we need to start with clear warnings as part of the build process. @CodeOfficer's suggestion to use ember-cli-dependency-lint is a good first step. I just wanted to check in for now, but hope to be back soon after exploring some possibilities. |
Checking back on this issue I can confirm the issue we're encountering matches conflict 2. Whats most frustrating is that the code itself is bundled and there, but it will not be invoked because the first time the component is invoked that is the version that is cached in ember and will be invoked in all other engines or the host app that references it. |
This issue is also referenced in the official docs with the recommendation to avoid including different versions of the same addon. I would like to find a solution to this issue that doesn't involve our teams having to be in lock-step and they can opt into updates when its convenient for them rather than requiring anyone that needs an upgrade to force everyone else to integration test a centralized change. |
@nmcclay Check out https://github.com/dgeb/ember-cli-addon-guard, which is the solution I developed based on |
@dgeb you are amazing! I tried this out and encountered a few unexpected issues getting it working with my engines, but after some hacking I got it to work for both the top level duplicated addon and any nested sub-components without any additional engine template rewriting. Very cool stuff and exactly what I was looking for! One thing I noticed is ember-engines 0.7.1 is dependent on *edit - problem is unrelated to calculate-cache-key-for-tree dependency, will follow up in ember-cli-addon-guard repo. |
@nmcclay great, glad it's working for you (for the most part)! I'll follow up with any issues you open in ember-cli-addon-guard. |
@nmcclay ember |
@villander I tried out the deduplication feature flag, but it doesn't seem related to conflict 2 from demo-engine-addon-dependency-conflicts repo. Its not a duplication problem as much as a unique namespace problem that doesn't allow you to load different versions of shared addons within engines. |
right! makes sense. But I think that conflict 2 must be handle on what you think? this is scope of ember-engines addon? |
I built To address this,
I think these are the only two reasonable ways to handle these conflicts in the current system in which dependencies are all flattened. Of course, we'll have more options available if we stop flattening dependencies. |
A gotcha we had recently here and that may be of use to some: we are splitting our old shared addon into two bits:
So at the end of the day, addon_1 doesn't need to be the same version in all engines, as it is only built in the parent app or dummy app, so when updating your addon you just need to update the engine you are working with, and the parent app, and you are done - for all models, services, tests and mirage helpers (supposing of course you are confident that updating your shared addon won't break your other engines' tests..). |
We have a host app and multiple routable engines they all share some common lib (addon). For any small change to common lib we have to do a release and update host app and all the engines' package.json. So we would have to also create releases of all the engines as well. We are using semantic versioning but The reason of doing it this way is, we have moved tests related to engines into engines and when we run engine's test in dummy app we need the latest version of those common libs in the engines. Is there a better solution to solve this process.
Also it will be nice if someone shares their processes regarding engines. Its been bit difficult to manage engines in terms of dependancies.
The text was updated successfully, but these errors were encountered: