[英]How to setup ember engines?
I've created a standalone routable engine with ember-engines
0.4.0
, ember-cli
2.10.0
. 我用ember-engines
0.4.0
, ember-cli
2.10.0
创建了一个独立的可路由引擎。
I get this error if I call the engines index route ( /thingy/
): 如果我调用引擎索引路径( /thingy/
),我会收到此错误:
Assertion Failed: Asset manifest does not list any available bundles.
Consuming App router.js
: 消费App router.js
:
this.mount('thingy-frontend', { as: 'thingy', path: 'thingy' });
Engine App routes.js
: 引擎应用routes.js
:
this.route('index', { path: '/' });
The engine is 'installed' via a symlink in the node_modules/
dir of the consuming ember-cli
app. 引擎通过消费ember-cli
应用程序的node_modules/
dir中的符号链接“安装”。 ( See here why ). ( 见这里原因 )。
Just for fun I've tried to change the routes to test if that works ... 只是为了好玩,我试图改变路线,以测试是否有效......
Consuming App router.js
: 消费App router.js
:
this.mount('thingy-frontend', { as: 'thingy' });
Engine App routes.js
: 引擎应用routes.js
:
this.route('index', { path: 'new' });
I've called /thingy/new
and got an UnrecognizedURLError
. 我打电话给/thingy/new
并得到一个UnrecognizedURLError
。 Alternative, if I call the root path, I get an Assertion Failed: Asset manifest does not list any available bundles.
或者,如果我调用根路径,则会出现Assertion Failed: Asset manifest does not list any available bundles.
Also if I place a console.log('...');
如果我放置console.log('...');
in the engines index.js
, I can't see any output. 在引擎index.js
,我看不到任何输出。 Seems like it isn't loaded at all. 好像它根本没有加载。
The setup was inspired by the official README and the official example repos. 该设置的灵感来自官方README和官方示例回购。
Any idea how to fix this Ember Engines setup? 知道如何修复此Ember引擎设置吗?
You can find the repos on GitHub: 你可以在GitHub上找到回购:
We could solve the issue. 我们可以解决这个问题。 There have been several problems and I'll share with you what we did: 有几个问题,我将与您分享我们做了什么:
You have to add ember-engines
as a dependency in the package.json
both for the app and the engine. 您必须在ember-engines
的package.json
添加ember-engines
作为依赖项。 So we change the package.json
to: 所以我们将package.json
更改为:
"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
. 别忘了npm install
。
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
. 即使它在node_modules中不是公共的和符号链接的,就像我们的情况一样,你必须将引擎添加到package.json
。
In our case this was "thingy-frontend": "*"
. 在我们的例子中,这是"thingy-frontend": "*"
。
Don't forget to npm install
. 别忘了npm install
。
In our case the symlink had the name of the engine repo instead of the actual engine name. 在我们的例子中,符号链接具有引擎repo的名称而不是实际的引擎名称。 That won't work. 那不行。 We changed the symlink name to thingy-frontend
(that's the name from the engines index.js
). 我们将符号链接名称更改为thingy-frontend
(这是引擎index.js
的名称)。
You have to ensure, that both in the addon/engine.js
and the app/resolver.js
use the ember-resolver
. 你必须确保addon/engine.js
和app/resolver.js
使用ember-resolver
。
This is probably a bug in ember-engines
. 这可能是ember-engines
一个错误。 See the issue for more details: https://github.com/ember-engines/ember-engines/issues/282#issuecomment-268834293 有关详细信息,请参阅该问题: 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) 您可以通过手动将<meta />
-Tag添加到<head>
来解决该问题(请参阅上面的GitHub问题链接)
Many thanks to Michael Donaldson ! 非常感谢Michael Donaldson !
I can't find reference to your Engine app from Consuming app package.json. 我无法从Consuming app package.json中找到对您的引擎应用程序的引用。 I think you should add to Consuming package.json Engine app. 我认为你应该添加到Consuming package.json Engine应用程序。 For in-repo-addons - engines I can find in ember-engines-demo that in package.json they have: 对于in-repo-addons - 我可以在ember-engines-demo中找到引擎,在package.json中它们具有:
"ember-addon": {
"paths": [
"lib/ember-chat-engine"
]
}
For not in-repo-addon, but for normal modules they have: 对于in-repo-addon,但对于普通模块,他们有:
"dependencies": {
"ember-data": "^2.6.0",
"ember-engines": "dgeb/ember-engines#v0.2",
"ember-blog-engine": "dgeb/ember-blog-engine"
},
Notice ember-blog-engine. 注意ember-blog-engine。 Here's full reference to their package.json . 这里是他们的package.json的完整参考。
However in your Consuming ember-engines-app app package.json does not list ember-engines-engine name. 但是在你的Consuming ember-engines-app app package.json中没有列出ember-engines-engine名称。
Ember processes addons from package.json lists so you have to reference your engine addon there. Ember处理来自package.json列表的插件,因此您必须在那里引用您的引擎插件。 Otherwise you will never get any line of code from such package executed in Ember CLI environment. 否则,您将永远不会从Ember CLI环境中执行此类包中获得任何代码。
Please add your ember-engines-engine to consuming app package.json. 请将您的ember-engines-engine添加到使用app package.json。
I'd add that incompatibility could also be an issue... 我补充一点, 不兼容也可能是个问题......
As Ember Engines is experimental and being developed against the master branches of Ember and Ember-CLI, be sure that you are using compatible versions . 由于Ember Engines是实验性的,并且正在针对Ember和Ember-CLI的主分支进行开发,因此请确保您使用的是兼容版本 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.