ember-cli / ember-cli-deprecation-workflow

MIT License
165 stars 43 forks source link

Could not find module ember-cli-deprecation-workflow #196

Closed navels closed 2 months ago

navels commented 2 months ago

Am working on upgrading from Ember 3.28. Installed this add-on via

pnpm add -D ember-cli-deprecation-workflow

made the recommended code changes and then ran

ember test --server

which results in

not ok 1 Chrome 127.0 - [undefined ms] - Global error: Uncaught Error: Could not find module `ember-cli-deprecation-workflow` imported from `<my_package_name>/app` at http://localhost:7357/assets/vendor-a8e01cf449f0c2e23842103a14893ffb.js, line 259

I can see the library in node_modules . . . feels like I am missing something simple . . .

Update: ran

DEBUG="ember-auto-import:*" AUTO_IMPORT_VERBOSE=true ember test

and can see this at least:

  {
    "specifier": "ember-cli-deprecation-workflow",
    "path": "<my_package_name>/app.js",
    "isDynamic": false,
    "package": "<my_package_name>",
    "treeType": "app"
  },
NullVoxPopuli commented 2 months ago

what's your app.js look like?

imported from `<my_package_name>/app`

?

in my projects, it looks like this:

import './deprecation-workflow';

import Application from '@ember/application';

import loadInitializers from 'ember-load-initializers';
import Resolver from 'ember-resolver';

import config from '<package-name>/config/environment';

export default class App extends Application {
    modulePrefix = config.modulePrefix;
    podModulePrefix = config.podModulePrefix;
    Resolver = Resolver;
}

loadInitializers(App, config.modulePrefix);

and then, in app/deprecation-workflow.js:

import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow';

setupDeprecationWorkflow({
    throwOnUnhandled: true,
    workflow: [
        // Add your deprecation handlers here.
        // See docs:
        //    https://github.com/ember-cli/ember-cli-deprecation-workflow
    ],
});
navels commented 2 months ago

After running into this error I just added the import to app.js, like so, still failing:

import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from '<my_package_name>/config/environment';
import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow';

export default class App extends Application {
  modulePrefix = config.modulePrefix;
  podModulePrefix = config.podModulePrefix;
  Resolver = Resolver;
}

setupDeprecationWorkflow();
loadInitializers(App, config.modulePrefix);

Notably, ember-cli-deprecation-workflow and ember-resolver are both in devDependencies, both present on disk, both with identical output when building with ember-auto-import debugging on.

NullVoxPopuli commented 2 months ago

what's your ember-cli, ember-auto-import and @embroider/* (if any) versions? do you happen to have a reproduction of this I can poke at?

navels commented 2 months ago
ember-cli: 5.10.0
ember-auto-import: 2.7.4

When run in my package root:

> ember --version
ember --version
ember-cli: 5.10.0
node: 18.17.1
os: darwin arm64

I don't have any direct dependencies on embroider packages but there are plenty of transitive dependencies. Any particular package might matter? I am guessing

@embroider/macros: 1.15.1
@embroider/util: 1.13.0

I don't have a shareable repro but maybe I can put one together, but I might just try some debugging first.

navels commented 2 months ago

Okay it was something dumb. Unbeknownst to me, it was already a dev dependency pinned to version 2.2.0. Updating to the latest version fixed the issue.