Ember app modules namespacing


#1

Good morning.

The company I’m working for is building an emberjs app, which constitutes of different modules. We’re using Ember CLI to handle the project structure and build (at least for now).

For the modules, I mean very different pieces of functionality, not just some separation of data. Also, I want to add that these models have table names in common, but different data, so that’s one reason we needed to separate things. We will want to load these modules as required, so the app size gets reduced.

For the namespacing, we used an approach where we create a folder following the module name for controllers, models, adapters, views etc…

So the structure ended up like this:

  • app
    • controllers
    • module_1
    • module_2

You get the point.

This is working fine for us, although we had to customise and tweak a lot of ember things for this to work properly, we wanted to know if there’s an easier way to modularize an Ember app, using ember cli or not.

This is not something the guides and this very site talk about, but for some large projects, this becomes essential.

One solution we discussed as well was to have multiple ember apps. We decided to not do that on this moment because of some common data, so having one app would simplify, but the namespacing into folders brought its own issues we had to solve, like serializers, adapters, controller names, dependencies, etc.

Do you guys have any experience doing something like this? If yes, could you share what was the approach of doing so? Was the approach we took somewhat against the ember way?

Thanks in advance,


#2

I have 3 different ember apps that have a few shared bits in common, authentication, some models, and some common components. I share code using private ember addons and deploy using https://github.com/ember-cli/ember-cli-deploy and then serve the three apps from one rails app to avoid cors issues in addition to some other reasons. It’s worked well so far for me.


#3

I just heard about something new at an ember meetup

https://github.com/emberjs/rfcs/pull/10

I’ve not totally wrapped my head around it but it sounds like it solves the app in app issue.


#4

about the lazy loading there is a half solution. there is a great post about this from mixonic link. for ember-cli is a half solution, but i think it can be fixed with ember addon.


#5

@varblob I like the approach you’ve taken, about separate apps sharing code through addon. That’s something I have to test for myself and compare the solutions.

And that ember-cli-deploy is really nice! Thanks for that :slight_smile:

The Engines feature being discussed is definitely going to enable namespaces. I will keep an eye on that.

It’s good to see a lot of new stuff coming. Thanks for the responses so far