Ember In Repo Engines

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?

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.

1 Like

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

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!

2 Likes

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

1 Like

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…

2 Likes

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

what if i have in-repo addon inside a standard engine? I have given standard engine in the host app’s package.json’s dependencies and/or devDependencies` and in-repo engine in ember-addon.paths array of standard engine but meta tag for in-repo engine is nor generated @rwjblue