-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Prevent foot-guns when customizing index.js #9334
Comments
I don't understand the issue, let's focus on the actual problem that you faced (not the general case of attempting to prevent all footguns). What did you have specified in your |
the full index.js was: module.exports = {
name: require('./package').name;
options: {
// but i'm not sure if specifics matter
autoImport {
['splunk-sdk']: 'splunk-sdk/client/splunk',
},
skipBabel: [
{
package: 'splunk-sdk',
semverRange: '*',
}
]
}
} but in both the dummy app and all consuming apps the autoImport config acted as if it wasn't there. (error thrown when trying to import a specific module, splunk-sdk) what did work was the exact same Knowing that, to get things working, I deleted the |
Code used for included() {
let app = this._findRootApp();
let autoImport = app.options.autoImport || {};
app.options.autoImport = {
...autoImport,
alias: {
...(autoImport.alias || {}),
['splunk-sdk']: 'splunk-sdk/client/splunk',
},
skipBabel: [
...(autoImport.skipBabel || []),
{ package: 'splunk-sdk', semverRange: '*' }
]
};
this._super.included.apply(this, arguments);
},
_findRootApp() {
let current = this;
while (current.parent.parent) {
current = current.parent;
}
return current.app;
}, |
You basically can't use Lines 329 to 331 in 8ce28a9
I would expect you need to do: module.exports = {
name: require('./package').name,
init() {
this._super.init.apply(this, arguments);
this.options.autoImport = {
alias: {
'splunk-sdk': 'splunk-sdk/client/splunk',
},
skipBabel: [
{ package: 'splunk-sdk', semverRange: '*' }
],
};
}
} Can you confirm that works properly? |
@rwjblue Ah, so in the above, would the apps options then be deep-merged on top of the |
@rwjblue why can't I use |
@NullVoxPopuli issue still relevant/warranted? |
Nope, none of these problems exist with v2 addons |
For example, let's say you want to add
it seems that if another addon specifies those options, whichever is loaded last wins.
so, it'd be great if ember-cli could either warn/hard-error when there is a conflict in
options
or, forbid the setting of options for other addons within your addon (I recognize that a deep merge of all options wouldn't be predictable, because there isn't a good way to guarantee order).If this is already supported, then there are other foot guns I've yet to track down :(
The text was updated successfully, but these errors were encountered: