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

0.4.0: Could not find module initializers/ember-engines-router-service #67

Closed
kpfefferle opened this issue Jun 8, 2022 · 19 comments · Fixed by #97
Closed

0.4.0: Could not find module initializers/ember-engines-router-service #67

kpfefferle opened this issue Jun 8, 2022 · 19 comments · Fixed by #97

Comments

@kpfefferle
Copy link

When attempting to use v0.4.0 of this addon, the tests we have in our application that use the engine containing this addon blow up with the following error:

Error: Could not find module `[EMBER_ENGINE]/initializers/ember-engines-router-service` imported from `(require)`

v0.3.0 continues to work as expected. I'm guessing this is something related to the migration to v2 addon format? We are using ember-auto-import v2 so v2 addons should theoretically work 🤔

@villander
Copy link
Owner

Hey, @kpfefferle is this error only happening in the test environment? Could you please provide a minimal reproduction then I can help more 😄 since we didn't those issues in our tests with the dummy app

@kpfefferle
Copy link
Author

@villander We get the same error at runtime in local development when trying to access any route that uses the engine, so this is not an issue isolated to the test environment.

I'll try and poke at this further later today.

@anehx
Copy link

anehx commented Aug 26, 2022

I'm having the exact same issue here: projectcaluma/ember-caluma#2001

@SergeAstapov
Copy link
Contributor

SergeAstapov commented Sep 20, 2022

the root cause of the problem I believe is that initializer file dist/_app_/initializers/ember-engines-router-service.js published to NPM has following contents:

export { default } from "ember-engines-router-service/initializers/ember-engines-router-service.js";

and it should be

export { default } from "ember-engines-router-service/initializers/ember-engines-router-service";

The simplest solution I see - bump @embroider/addon-dev package and release 4.0.1 with the new tarball.

now trying this in our app to confirm this is 1. the actual root cause and 2. proposed change makes the trick

@SergeAstapov
Copy link
Contributor

SergeAstapov commented Sep 20, 2022

@kpfefferle @anehx @villander FYI made a PR #73

EDIT: I may be wrong about the root cause, keep looking...

@anehx
Copy link

anehx commented Sep 21, 2022

@SergeAstapov I just checked out your branch and used that build for my use case. Sadly, it didn't work..

However, if I put console.log("something") above or below the export { default } from ... in dist/_app_/initializers/ember-engines-router-service.js everything works as expected. I have no idea why..

I also tried replacing the content of the initializer reexport to

import initializer from "ember-engines-router-service/initializers/ember-engines-router-service";
export default initializer

which doesn't change the meaning of the code but it worked.

I hope that helps..

@SergeAstapov
Copy link
Contributor

@kpfefferle @anehx would you mind to share how dependency tree looks like in your case and if you use Embroider for the app build or "classic" Ember CLI?

there was a discussion on Discord which has similar symptom https://discordapp.com/channels/480462759797063690/568935504288940056/1027599076709126194

@anehx
Copy link

anehx commented Oct 7, 2022

@SergeAstapov I'm not exactly sure what you mean by dependency tree - what output should I paste? Also, I'm using classic ember without embroider. Since a minimal reproduction might help more than outputs from my specific use case I created one here: https://github.com/anehx/ember-engines-router-service-reproduction, also I added a branch that uses embroider instead of classic ember (it didn't produce the error!): https://github.com/anehx/ember-engines-router-service-reproduction/tree/embroider

Hope this helps!

Edit: I read the discussion you linked, there seems to be a workaround by adding this package to the dev dependencies of the application, but I don't think this can be the solution to this. Wouldn't this even override the built in ember router service?

@SergeAstapov
Copy link
Contributor

@anehx thank you! Reproduction is always the best!

@kpfefferle
Copy link
Author

@SergeAstapov Our application is also using "classic" ember-cli, not Embroider 👍

@LucasPadovanPeek
Copy link

Hello!
We are getting a similar issue while trying to use the router
image

image

It seems that for engines the initializer is not being found, or it is not correctly setup or the files are not exported to the correct path.

@SergeAstapov
Copy link
Contributor

SergeAstapov commented Oct 27, 2022

got some updates here:
there is nothing wrong with ember-engines-router-service package itself.

The issue is: any v2 addon in the engine does not get pulled into build.
the reason I didn't see it in our app - we (somehow) had added ember-engines-router-service to devDependencies in the host app and it gets pulled into build.

Wouldn't this even override the built in ember router service?

@anehx it will be inert in the host app thanks to this check https://github.com/villander/ember-engines-router-service/blob/master/addon/src/-private/engine-ext.js#L8

NOTE:
temporary solution for this issue until it gets fixed in ember-auto-import - add ember-engines-router-service to devDependencies of the host app.

@anehx
Copy link

anehx commented Oct 28, 2022

@SergeAstapov Thanks for analyzing this issue! Is there an issue for ember-auto-import I could track?

For now, we will stay away from the rather hacky workaround and stay on v0.3.0 since v0.4.0 does not really bring any enhancement.

@SergeAstapov
Copy link
Contributor

@anehx I wonder if embroider-build/ember-auto-import#512 will fix the issue, but it's blocked with ember-engines/ember-engines#820

For now, we will stay away from the rather hacky workaround and stay on v0.3.0 since v0.4.0 does not really bring any enhancement.

from functional perspective, v0.3.0 and v0.4.0 are same. the main and only difference is v2 addon format in the latter version

@villander
Copy link
Owner

Thanks for figuring it out @SergeAstapov let's wait for these fixes and see how it goes. 🤞

@RobbieTheWagner
Copy link

I'm unsure if the error we are getting is related to this or not, but after updating to Ember 3.28, the router service is the app one. I am guessing the initializer is not running.

@villander
Copy link
Owner

@SergeAstapov any news here regarding your last comment?

@SergeAstapov
Copy link
Contributor

@villander unfortunately I don't have any updates on this issue. Haven't been able to find root cause in ember-auto-import and seen similar issues in our internal v2 addons as well for services re-exports only.

@villander
Copy link
Owner

@RobbieTheWagner could you please create a minimal reproduction with this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment