Ember In Repo Engines


#1

Is there any way to group in-repo engines under a folder. Let’s say, i have 4 in-repo-engines namely A, B, C1 and C2. I want to group C1 and C2 in-repo-engines under a folder called C (Folders - lib>> C>> C1 , lib>> C>> C2). Is this possible? If so, what are the other configurations we must do?


#2

Sure, there is no specific reason they live under lib today. You can move them around anywhere you’d like. One of my work projects has engines in a top level engines/ directory, which works well for us.

The main thing to change is the ember-addon object in your package.json to include the correct paths for discovery.


#3

Thank you so much @rwjblue. How to define the path in ember-addon object ? Can u pls give me an example .


#4

When you do the following:

ember new foo
cd foo
ember install ember-engines
ember generate in-repo-engine bar

You will see that it does a few things:

  1. creates a lib/bar/ folder with a few files for your engine in it
  2. updates your package.json to add additional paths to the ember-addon object in package.json.

Your package.json may have something like the following:

  "ember-addon": {
    "paths": [
      "lib/bar"
    ]
  },

In order to move that in-repo-engine to another folder (lets just say engines/bar for the sake of argument), you will need to update the path in ember-addon.paths in package.json and move the actual engine files from lib/bar to engine/bar. That should be all you need to do!


#5

Thank u so much for your explanation. Learnt a new thing. :grinning:


#6

For anyone curious, from ember-cli’s perspective the only difference between an in-repo addon (or engine) and an external one is how ember-cli discovers it. In the case of an external thing, it discovers its presence from the package.json's dependencies and/or devDependencies, but clearly in-repo addons (or engines) do not have an entry there (because they are “in repo” :smiley:) so instead we discover them via this ember-addon.paths array.

Essentially the ember-addon.paths array is just a way to discover additional addons that would not normally be discovered via normal package.json dependencies/devDependencies traversal…


#7

So, it would be possible to add engines via an npm link rather than in-repo?