mansona / ember-get-config

Get `config/environment` from anywhere, even addons!!!
MIT License
65 stars 20 forks source link

Add failing tests under Embroider #42

Closed bertdeblock closed 2 years ago

bertdeblock commented 2 years ago

Hopefully, this should illustrate that the config returned by ember-get-config is incorrect under Embroider (it seems this was also the case in v1 of ember-get-config). ember-get-config seems to only return what's defined in config/environment.js and not what actually ends up in <app-name>/config/environment or in the app's meta tag (e.g. including additional default config coming from addons).

The baz in-repo addon is probably not ideal, but works to showcase the issue.

mansona commented 2 years ago

So it turns out, what you're identifying is actually a bug in the compat code in embroider rather than any code in this repo. This code assumes only the config file in the host app, not the actual exported module that may contain the combined configs from all the addons https://github.com/embroider-build/embroider/blob/main/packages/compat/src/compat-adapters/ember-get-config.ts

I'm a little bit swamped this week but I'll try to open a conversation with @ef4 to see what can be done but from @alexlafroscia comment in that file I would suspect that this might not be a solvable problem in the embroider world 🤔

bertdeblock commented 2 years ago

At the moment, disabling the compat adapter for ember-get-config actually breaks everything:

Uncaught Error: Cannot find module '<app-name>/config/environment'

Requiring the module instead of using importSync works, though I'm unsure if that is "the fix".

EDIT: Made https://github.com/mansona/ember-get-config/pull/43 to disable the compat adapter during CI.

mansona commented 2 years ago

this was included in #45