question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when using ember-data@3.16 with staticAddonTrees enabled

See original GitHub issue

Hi,

when enabling staticAddonTrees in an app that uses ember-data@3.16.0, I’m seeing an error being thrown:

Could not find module `@ember-data/model/-private` imported from `(require)`
data-version ok
3.15.0 🆗
3.15.1 🆗
3.16.0 👎
3.17.0-beta.0 👎

Reproduction repo: https://github.com/makepanic/embroider-data-staticAddonTrees

If this issue is better tracked in the ember-data repo, I can reopen it there.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
atsjjcommented, Apr 10, 2020

I managed to get this working with ember-data@3.17.0.

You can try the workaround with the following ember-cli-build.js:

'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const { V1Addon } = require('@embroider/compat');
const { forceIncludeModule } = require('@embroider/compat/src/compat-utils');

class EmberDataCompatAdapter extends V1Addon {
  get packageMeta() {
    return forceIncludeModule(super.packageMeta, './-private');
  }
}

module.exports = function(defaults) {
  let app = new EmberApp(defaults, {
    // Add options here
  });

  // Use `app.import` to add additional libraries to the generated
  // output files.
  //
  // If you need to use different assets in different
  // environments, specify an object as the first parameter. That
  // object's keys should be the environment name and the values
  // should be the asset to use in that environment.
  //
  // If the library that you are including contains AMD or ES6
  // modules that you would like to import into your application
  // please specify an object with the list of modules as keys
  // along with the exports of each module as its value.

  const { Webpack } = require('@embroider/webpack');
  return require('@embroider/compat').compatBuild(app, Webpack, {
    compatAdapters: new Map([
      ['@ember-data/model', EmberDataCompatAdapter],
      ['@ember-data/record-data', EmberDataCompatAdapter],
    ]),
    staticAddonTestSupportTrees: true,
    staticAddonTrees: true,
    staticComponents: true,
    staticHelpers: true,
  });
};

This change seemed to have an effect on the DEBUG directories. Forcefully including the -private paths for the two modules did the following:

diff -qr DEBUG-BROKEN DEBUG-WORKING

Only in DEBUG-WORKING/ember-cli-babel/@ember/test-helpers: 017
Only in DEBUG-WORKING/ember-cli-babel/@ember/test-helpers: 018
Only in DEBUG-WORKING/ember-cli-babel/@ember/test-helpers: 029
Only in DEBUG-WORKING/ember-cli-babel/@ember/test-helpers: 030
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/adapter: 006
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/adapter: 007
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/canary-features: 005
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/canary-features: 006
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/canary-features: 011
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/canary-features: 012
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/debug: 010
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/debug: 016
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/model: 011
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/model: 018
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/model: 019
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/private-build-infra: 004
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/private-build-infra: 008
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/record-data: 012
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/record-data: 021
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/record-data: 022
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/serializer: 013
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/serializer: 024
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/serializer: 025
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/store: 009
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/store: 014
Only in DEBUG-WORKING/ember-cli-babel/@ember-data/store: 015
Only in DEBUG-WORKING/ember-cli-babel/ember-data: 003
Only in DEBUG-WORKING/ember-cli-babel/ember-data: 004
Only in DEBUG-WORKING/ember-cli-babel/ember-fetch: 014
Only in DEBUG-WORKING/ember-cli-babel/ember-fetch: 015
Only in DEBUG-WORKING/ember-cli-babel/ember-fetch: 026
Only in DEBUG-WORKING/ember-cli-babel/ember-fetch: 027
Only in DEBUG-WORKING/ember-cli-babel/ember-load-initializers: 016
Only in DEBUG-WORKING/ember-cli-babel/ember-load-initializers: 028
Only in DEBUG-WORKING/ember-data: ember-data

My best guess is that the tooling doesn’t like that the @ember-data/model addon as well as the @ember-data/record-data addon rollup the -private module and then exclude that from the addon tree. I’m still learning how embroider works and I’m unable to suggest a fix better than my hack at this time. However, I hope this helps!

0reactions
rreckonerrcommented, Sep 24, 2022

Seems like the issue is still there. I’m on ember-data version 4.4. None of the solutions above help.

"@embroider/compat": "^1.6.0",
"@embroider/core": "^1.6.0",
"@embroider/router": "^1.8.3",
"@embroider/webpack": "^1.6.0"
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found