Addon the correct way to share large percentage of code?

I’ve been reading through this topic ( Sharing models via ember-cli addons? ) and I’d like some validation that what I’m thinking of doing makes sense.

I have a Rails app in it’s own repo and a customer facing Ember app in it’s own repo (e.g. ui-frontside).

I’d like to build a management Ember app (ui-management) that will share a large portion of the models, mixins, services and components. Basically, it will reuse almost everything from the way that error messages are displayed to how the ember-simple-auth is configured. The biggest difference will be in routes and the management interface will have components for editing models that would be read-only to the customer app.

Is the correct thing to do–to avoid copy-and-pasting code–to create a fourth repo as an ember-cli addon and copy everything from the customer app that could conceivably be shared? Then, refactor the custom app to use that base app?

We do something very similar, however all of our app is in the same repo. So it might not apply 1-to-1, but here is a repo I built to demonstrate how we handle this:

1 Like

There is no correct way :wink:

What I would do:

Create a new empty Repo for your Management App and add your main Ember App as a remote in git. Merge this remote in the Management App and commit. Your Main App and Management App are now the same. Change the Management App with the extra components or copy the working version over the Management App. Commit this to. Now Git “knows” how you changed your code. If you change something in the main App and commit it you can merge the change in your Management App from the remote. Git will handle this correct for you or with minimal effort from your site.

What I am basically saying is that you should use git remote

It’s Ember, it’s supposed to have a Correct Way™ :slightly_smiling:

1 Like

The eventual solution to this is engines. Unfortunately engines are still under development.

I don’t believe engines will solve the cross project problem. I believe engines will help modularize parts of the app. But if you really have two separate apps that you want to share code, I don’t see engines as a solution.

I ended up creating a separate addon with many of my models, mixins and a bunch of components (mostly HTML structure page). So far it has worked flawlessly. I can provide more info if anyone is interested.

Thanks for the feedback.

In my mind Engines should be isolated even more so than what can be termed as a ‘module’. Wondering why not user the traditional ways of sharing code using npm, bower, webpacks can’t be applied here.