javascriptnode.jsember.jsember-engines

How to setup ember engines?


I've created a standalone routable engine with ember-engines 0.4.0, ember-cli 2.10.0.

I get this error if I call the engines index route (/thingy/):

Assertion Failed: Asset manifest does not list any available bundles.

Consuming App router.js:

this.mount('thingy-frontend', { as: 'thingy', path: 'thingy' });

Engine App routes.js:

this.route('index', { path: '/' });

The engine is 'installed' via a symlink in the node_modules/ dir of the consuming ember-cli app. (See here why).

Just for fun I've tried to change the routes to test if that works ...

Consuming App router.js:

this.mount('thingy-frontend', { as: 'thingy' });

Engine App routes.js:

this.route('index', { path: 'new' });

I've called /thingy/new and got an UnrecognizedURLError. Alternative, if I call the root path, I get an Assertion Failed: Asset manifest does not list any available bundles.

Also if I place a console.log('...'); in the engines index.js, I can't see any output. Seems like it isn't loaded at all.

The setup was inspired by the official README and the official example repos.

Any idea how to fix this Ember Engines setup?

You can find the repos on GitHub:


Solution

  • We could solve the issue. There have been several problems and I'll share with you what we did:

    1. Add ember-engines as dependency (not just dev-dependency)

    You have to addember-engines as a dependency in the package.json both for the app and the engine. So we change the package.json to:

    "dependencies": {
      "ember-cli-htmlbars": "^1.0.10",
      "ember-cli-babel": "^5.1.7",
      "ember-data": "^2.10.0",
      "ember-engines": "0.4.0"
    }
    

    Don't forget to npm install.

    2. Add the actual engine to the package.json

    Even if it's not public and symlinked in node_modules like in our case, you have to add the engine to the package.json.

    In our case this was "thingy-frontend": "*".

    Don't forget to npm install.

    3. Check symlink name

    In our case the symlink had the name of the engine repo instead of the actual engine name. That won't work. We changed the symlink name to thingy-frontend (that's the name from the engines index.js).

    4. Use the right resolver

    You have to ensure, that both in the addon/engine.js and the app/resolver.js use the ember-resolver.

    5. Failed to load asset manifest.

    This is probably a bug in ember-engines. See the issue for more details: https://github.com/ember-engines/ember-engines/issues/282#issuecomment-268834293

    You can workaround that issue by manually adding a <meta />-Tag to the <head> (see the GitHub issue link above)

    Many thanks to Michael Donaldson!