简体   繁体   English

如何设置ember引擎?

[英]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.0ember-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: 有几个问题,我将与您分享我们做了什么:

1. Add ember-engines as dependency (not just dev-dependency) 1.添加ember-engines作为依赖(不仅仅是dev-dependency)

You have to add ember-engines as a dependency in the package.json both for the app and the engine. 您必须在ember-enginespackage.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

2. Add the actual engine to the package.json 2.将实际引擎添加到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 . 即使它在node_modules中不是公共的和符号链接的,就像我们的情况一样,你必须将引擎添加到package.json

In our case this was "thingy-frontend": "*" . 在我们的例子中,这是"thingy-frontend": "*"

Don't forget to npm install . 别忘了npm install

3. Check symlink name 3.检查符号链接名称

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的名称)。

4. Use the right resolver 4.使用右侧旋转变压器

You have to ensure, that both in the addon/engine.js and the app/resolver.js use the ember-resolver . 你必须确保addon/engine.jsapp/resolver.js使用ember-resolver

5. Failed to load asset manifest. 5.无法加载资产清单。

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.

相关问题 Ember引擎和Ember简单Auth - Ember engines and Ember simple Auth Ember.js:如何将 package JSON 文件依赖项共享给子引擎和插件 - Ember.js: How to share package JSON file dependency to child engines and addons 如何设置Ember-CLI属于下拉菜单? - How do I setup Ember-CLI belongsTo dropdown? 应用程序路径中的多个模型,如何设置控制器Ember.JS - Multiple models in Application route, how to setup the controller Ember.JS 如何在ember.js中设置同一路径中的多个控制器? - How to setup multiple controllers in the same route in ember.js? 如何使用Dalek自动进行Ember测试(特定Ember组件的设置/拆卸) - How do I do Automating Ember testing with Dalek (setup/teardown of specific Ember components) 浏览器中的引擎 - 它们如何交互? - Engines in Browser - How do they interact? 如何在 Ember CLI 结构中的 EmberJS 主页上设置“从服务器加载数据”示例? - How to setup the “Loading Data from a Server” example on the EmberJS homepage within an Ember CLI structure? ember.js-如何设置具有可选ID的路由以进行查找和后备默认模型? - ember.js - How to setup a route with an optional ID for lookup, and fallback default model? ember.js如何为视图显示不同的筛选列表? 复杂的设置 - ember.js how to display different filtered lists for a view? complex setup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM