Ember Module Unification Stack trace: Error: Assertion Failed: 'data-adapter' is not a recognized type

Ember Module Unification Stack trace: Error: Assertion Failed: 'data-adapter' is not a recognized type

Ember 数据不会显示在 inspector.The 错误如下所示。 我在新 ember 中使用模块统一。 module unification ember

谁能告诉我如何解决它,因为我需要在 ember 检查器中查看数据?

数据显示为空数据,我看到模型但什么也没有(下图):

Ember Inspector has errored.
This is likely a bug in the inspector itself.
You can report bugs at https://github.com/emberjs/ember-inspector.
Error message: Assertion Failed: 'data-adapter' is not a recognized type
Stack trace: Error: Assertion Failed: 'data-adapter' is not a recognized type
    at assert (http://localhost:4200/assets/vendor.js:73088:19)
    at Resolver._definitiveCollection (http://localhost:4200/assets/vendor.js:73063:31)
    at Resolver.identify (http://localhost:4200/assets/vendor.js:73027:37)
    at Resolver.resolve (http://localhost:4200/assets/vendor.js:73055:27)
    at Class.resolve (http://localhost:4200/assets/vendor.js:98399:36)
    at Class.resolve (http://localhost:4200/assets/vendor.js:98232:25)
    at Class.superWrapper [as resolve] (http://localhost:4200/assets/vendor.js:41053:22)
    at _resolve (http://localhost:4200/assets/vendor.js:12906:36)
    at Registry.resolve (http://localhost:4200/assets/vendor.js:12445:21)
    at Registry.resolve (http://localhost:4200/assets/vendor.js:12450:60)
warn @ VM2062:92
handleError @ VM2062:149
(anonymous) @ VM2062:3515
_run @ backburner.js:1066
run @ backburner.js:748
run @ index.js:111
wrap @ VM2062:3511
messageReceived @ VM2062:3482
get.onMessageReceived.message @ VM2062:3476
get.forEach.callback @ VM2062:127
_messageReceived @ VM2062:126
run @ VM2062:344
_run @ backburner.js:1066
run @ backburner.js:748
run @ index.js:111
chromePort.addEventListener.event @ VM2062:343

文件树:

src
├── data
│   └── models
│       ├── application
│       │   └── model.js
│       └── user
│           ├── adapter.js
│           └── model.js
├── formats.js
├── init
│   └── initializers
│       └── i18n.js
├── main.js
├── resolver.js
├── router.js
├── services
│   └── intl.ts
└── ui
    ├── components
    ├── index.html
    ├── routes
    │   ├── about-page
    │   │   ├── route.js
    │   │   └── template.hbs
    │   ├── application
    │   │   ├── controller.js
    │   │   ├── route.js
    │   │   └── template.hbs
    │   └── user
    │       ├── controller.js
    │       ├── route.js
    │       └── template.hbs
    ├── styles
    │   └── app.css
    └── utils

这是模块统一的文件结构。 package.json 没有什么特别之处。

将这些配置(来自 @NullVoxPopuli)添加到 resolver.js

之后
  "data-adapter": { definitiveCollection: "main" },
  "container-debug-adapter": { definitiveCollection: "main" },
  "resolver-for-debugging": { definitiveCollection: "main" }

  assign(moduleConfig.collections, {
    data: { types: ["data-adapter", "model"], defaultType: "model" }
});

这是目前模块统一中比较粗糙的部分之一。

到目前为止,我已经能够使用此解析器配置加载检查器上的数据选项卡:

import Resolver from 'ember-resolver/resolvers/fallback';

import buildResolverConfig from 'ember-resolver/ember-config';
import config from '../config/environment';

let moduleConfig = buildResolverConfig(config.modulePrefix);

moduleConfig.types = Object.assign(moduleConfig.types, {
  // ember-inspector support
  'data-adapter': { definitiveCollection: 'main' },
  'container-debug-adapter': { definitiveCollection: 'main' },
  'resolver-for-debugging': { definitiveCollection: 'main' },
});

moduleConfig.collections.main.types.push('data');

moduleConfig.collections = Object.assign(moduleConfig.collections, {
  data: {
    types: ['data-adapter', 'model'],
    defaultType: 'model',
  },
});

export default Resolver.extend({
  config: moduleConfig,
});

使用此配置,只有在 src/data/models/{model-name}.js 中命名的模型才会被拾取 -- 如果模型位于 src/data/models/{model-name}/model.js,这不会告诉检查员要查看的位置。