Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find module @ember-data/debug imported from ember-data/index #7053

Closed
williamweckl opened this issue Feb 19, 2020 · 9 comments
Closed
Labels
🏷️ bug This PR primarily fixes a reported issue

Comments

@williamweckl
Copy link

williamweckl commented Feb 19, 2020

Description

When I update my ember-data to 3.16.0 and deploy to a production env the error Could not find module @ember-data/debug imported from ember-data/index happen once I try to access the page through a browser.

Maybe it is a compatibility issue with fastboot since the error is being trowed by node and not by the browser.

When I rollback to 3.15.0 it works as expected.

Versions

├─ @ember-data/[email protected]
├─ @ember-data/[email protected]
├─ @ember-data/[email protected]
├─ @ember-data/[email protected]
├─ @ember-data/[email protected]
├─ @ember-data/[email protected]
├─ @ember-data/[email protected]
├─ @ember-data/[email protected]
├─ @ember-data/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]

I've tried to do a reproduction repository, but the error happens only on production env with a node app serving the app with fastboot.

@runspired
Copy link
Contributor

How are you serving it up for fastboot? Debug can be excluded from production builds in some cases, though by default it ships if the parent addon is ember-data

@williamweckl
Copy link
Author

williamweckl commented Feb 23, 2020

I'm using fastboot-app-server with express js. It's probably being excluded, but if it is optional, why is ember data trying to import it?

@runspired
Copy link
Contributor

if it is optional, why is ember data trying to import it?

If your app uses the ember-data package (as nearly all users currently do) it will try to import it. It is only excluded by default when

  1. you are in a production build AND
  2. you are not using the ember-data package

It is possible there is a broken check but given the lack of reports outside of this one I currently suspect there is either (1) something weird about the build-env for fastboot-app-server or (2) something weird in how your app specifies the dependency or (3) something bad being done by the app/an add-on. FactoryGuy is a common culprit for such things.

@samcic
Copy link

samcic commented Mar 6, 2020

I'm seeing precisely the same problem on two different apps after upgrading. One uses Fastboot and the other doesn't.

In both cases, the development build has no issues. Also, in both cases, reverting to 3.15.1 resolves the problem.

I know this description probably doesn't help, so I'll try to find the time to get a bare-bones repro and post it here when I have it.

@enterpub
Copy link

We are having same issue after update to 3.16. To workaround the issue if you are using Ember-Data in your app in ~/your_app/ember-cli-build.js do this:

const EmberApp = require("ember-cli/lib/broccoli/ember-app");

module.exports = function (defaults) {
    const app = new EmberApp(defaults, {
    
        // Delete or comment out below code
        //emberData: {
        //     includeDataAdapterInProduction: false
        //},

        storeConfigInMeta: false
    });

    return app.toTree();
};

@runspired
Copy link
Contributor

@enterpub are you saying your app has that config or has commented out that config?

@enterpub
Copy link

@runspired , sorry for misunderstanding. I meant first my app had includeDataAdapterInProduction: false included in ~/your_app/ember-cli-build.js, which lead to en error Could not find module @ember-data/debug imported from ember-data/index .But later I commented out the code as shown above and app started working in "prod" environment as expected.

@runspired
Copy link
Contributor

@enterpub thanks! that likely tells me the issue is that the above flag doesn't work properly when the ember-data package is present since the import is still used. Which is something I can fix :)

@runspired
Copy link
Contributor

Likely all that needs to be changed is for this line:

import DebugAdapter from '@ember-data/debug';

And this line:

DS.DebugAdapter = DebugAdapter;

To be lazily computed and wrapped in a package check.

e.g.

if (HAS_DEBUG_PACKAGE) {
  DS.DebugAdapter = require('@ember/debug').default;
}

@runspired runspired added 🏷️ bug This PR primarily fixes a reported issue and removed Bug labels Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bug This PR primarily fixes a reported issue
Projects
None yet
Development

No branches or pull requests

4 participants