1

we have a four apps that share a lot of components. So far we use addons to manage this shared code, but we're facing a lot of troubles with addons approach.

Something like this:

App1
- basic-form-elements-addon
- feedback-form-addon
- tables-management-addon
App2
- feedback-form-addon
- tables-management-addon
App3
- basic-form-elements-addon
App4
- basic-form-elements-addon
- tables-management-addon

The problem with this approach is that updating an addon is a quite long process involving a lot of steps:

  1. Link addon into app (using yarn link)
  2. Modify addon code
  3. Publish addon into npm
  4. Update dependency in App1
  5. (and possibly if I have a time and energy, update dependency and usage in App2,3,4 as well or leave it for someone else who touches that code :cry:)

Apart from this, there are other problems - maintaining 8 different ember apps costs a lot of time - updating ember versions - updating other dependencies - maintaining same linting configs and other tooling

these are the biggest issues we face now with this approach.

I don't know what's the best solution to this problem, but my idea was that we would - merge all addons into one addon (now that it's possible to require just part of the ember tree, it shouldn't have a bad impact of a code size, right?) - move all code into one repository (kind of monorepo) - use addon not as npm dependency, but somehow import it from the sibling directory (I don't know if this is possible)

so at the end, we would end up with something like this

git (monorepo)
- App1
- App2
- App3
- App4
- shared-code
--- components
--- helpers
--- models
--- ...

Is that possible? What would I need to do to achieve this setup? Or do you have a better solution?

Thank you for any kind of help, Ondrej

ondrej
  • 967
  • 7
  • 26
  • i don't see what that wouldn't work. edit: only downside is you would be forced to update all the apps if you make a breaking change to one of the shared components. this might be a good thing however. – Christopher Milne Nov 23 '17 at 15:43
  • But how can I import components, helpers etc. from different folder? – ondrej Nov 23 '17 at 19:36

1 Answers1

0

I think you are looking for ember in-repo addons.

You can have all your addons and apps in same folder(mono-repo style), and use addons in your app by mentioning them in app's package.json file.

For example, if you have folder structure like this,

/addon-one
/addon-two
/app-one
/app-two

In each of your app's package.json, you'll have to mention

"ember-addon": {
 "paths": [
   "../addon-one",
   "../addon-two"
 ]
},

And you should be sharing your addons with both apps.

eg repo: https://github.com/sureshdunga/ember-in-repo-addon-example

  • That looks promising. Although it solves just part of the problem. There is still maintenance with managing versions/configs in each repo separately. – ondrej Nov 29 '17 at 12:18
  • Unless you want to have release cycles for your addons, there is no reason for using versions for them. As, addons will be used from the given path instead of node_modules path, there is no need to version them at all. Also, if you specify addon as a developingAddon, it will work just like how `npm link` would work. – Suresh Kumar Nov 29 '17 at 14:41
  • I didn't mean managing versions of addons, but upgrading dependencies in each addon separately. As we have 3+ addons and 3 apps that means we have to upgrade Ember in each app and add-on separately. – ondrej Nov 30 '17 at 07:46
  • That's something you can't avoid. We have been using this model for couple of months and it's been very productive.Anyway, do add an answer if you find a better approach. – Suresh Kumar Nov 30 '17 at 09:38