-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Addons can provide their resolver module configuration via resolverConfig()
#348
Conversation
aa8ea98
to
532ef05
Compare
I think addons should not have the power to change any part of the config, only add to it.
if the configuration ends up being the same would it matter? idk how hard that logic would be to implement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This seems to only gather resolver config from top level addons at the moment, we should decide if that is what we want or not (I think we should probably recurse and process nested addons as well).
- The new code should be feature flagged (in the same way that the MU tree work is done today) to ensure no impact when not using MU
- Its not clear to me why this is implemented in terms of app runtime instead of build time only.
@@ -0,0 +1,67 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why this is included in addon/
and not done completely in index.js
, what am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwjblue What is your proposal in this case? Let's see if I can understand your suggestion.
In this proposal, the resolver looks like:
import Resolver from 'ember-resolver/resolvers/fallback';
import buildResolverConfig from 'ember-resolver/ember-config';
import config from '../config/environment';
import addonsConfig from 'ember-resolver/addons-config';
import mergeAddonsConfig from 'ember-resolver/merge-addons-config';
let moduleConfig = buildResolverConfig(config.modulePrefix);
mergeAddonsConfig(moduleConfig, addonsConfig);
export default Resolver.extend({
config: moduleConfig
});
The only benefit is that users can modify the addonsConfig
to skip the addon collision exception.
Are you suggesting to perform the addon config merge within the buildResolverConfig
function and continue using the current MU resolver.js
like:
import Resolver from 'ember-resolver/resolvers/fallback';
import buildResolverConfig from 'ember-resolver/ember-config';
import config from '../config/environment';
let moduleConfig = buildResolverConfig(config.modulePrefix);
export default Resolver.extend({
config: moduleConfig
});
or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suggesting to do the final merging in node land and using broccoli-file-creator to write the final config to ember-resolver/ember-config
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think autogenerating the whole ember-resolver/ember-config
is not ideal, because this is a function that needs the config.modulePrefix
.
I have changed my implementation to execute mergeAddonsConfig
within the ember-resolver/ember-config
which has been refactored:
import addonsConfig from 'ember-resolver/addons-config';
import moduleConfig from 'ember-resolver/module-config';
import mergeAddonsConfig from 'ember-resolver/utils/merge-addons-config';
export default function generateConfig(name) {
let config = {
app: {
name,
rootName: name
},
};
mergeAddonsConfig(moduleConfig, addonsConfig);
return Object.assign(config, moduleConfig);
}
This setup allows using the same default src/resolver.js
as today.
import Resolver from 'ember-resolver/resolvers/fallback';
import buildResolverConfig from 'ember-resolver/ember-config';
import config from '../config/environment';
let moduleConfig = buildResolverConfig(config.modulePrefix);
export default Resolver.extend({
config: moduleConfig
});
Done at 4d29950
I didn't know about that. I am gonna test it. If this is the case, I have to figure out how to recurse the nested addons at the
Yes, it is.
I don't know how it could be the possible implementation, I wrote you about it at #348 (comment). |
This change removes the need to call `mergeAddonsConfig` on the `src/resolver.js` app module
Done by 3762945
Replied at #348 (comment) |
Something I'm worried about is documenting the difference between registering collections and registering types. Before the hard assertion on types/collections many add ons (and some applications) injected or added things to the app container. While the resolver is a rather advanced topic I'm not sure we are giving enough documentation to users on how to resolve errors in their applications or contribute fixes to add ons. |
To be a bit more straightforward about it. We're currently running into issues trying to use the new resolver in our application and are getting errors for both Right now I'd have to stab in the dark until things started working. While possible and not too much of an issue for bleeding edge, this is not an experience we'd want for normal app or add-on developers. |
@rtablada Totally agree with your concerns. While we work on the API design, RFC and documentation, rfc013#Module Naming and Organization and the MU module configuration are good resources to learn how to customize the app module configuration. Before an addon API is available and addons that need their own modules implement support for the MU layout, you will have to change Note: types and collection for addons are registered like the registration of your own app types and collections.
The proposal is that app developers don't have to setup the addon module configuration; addons must configure their own collection and types and app developers just follow the addon instructions as today.
I don't know the particularities of these addons, but please let us know if you find something that has not been considered in this PR. |
Closing now that we have removed module unification support code. Thanks for all of your hard work here @ppcano, sorry we weren't able to get it landed in a timely fashion. |
The PR gives the ability to addons to provide their own resolver configuration via a new addon hook
resolverConfig
as per RFC-262.This requirement was initially created at the QUEST Module Unification - Final Cut and supercedes ember-cli/ember-cli#8419
An addon can provide its resolve module configuration for MU apps like:
For reference, the MU default config shows an example with the different options.