Search code examples
javascriptember.jsmodelember-dataember-cli

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


Ember data won't show on the inspector.The error is showing below. I am using module unification in new ember. module unification ember

Can someone tell me how to fix it because I need to see data in ember inspector?

The data show an empty data which I see the model but there is nothing(image below):

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

file tree:

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

This is the file structure of the module unification. There is nothing special in the package.json.

After adding those configuration (from @NullVoxPopuli) to the 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" }
});

PIC


Solution

  • This is def one of the rougher parts of module unification at the moment.

    So far, I've been able to get the data tab on the inspector to be loaded with this resolver config:

    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,
    });
    

    with this config, the models are only picked up if they are named in src/data/models/{model-name}.js -- if a model is at src/data/models/{model-name}/model.js, this does not tell the inspector where to look.