Open trotzig opened 8 years ago
We could generalize the ignore prefixes option.
I wonder if we could generalize it in a way that would allow us to also handle aliases like "cx": "classnames"
. Not sure about the naming, but maybe something like:
packageNameAlternatives({ packageName }) {
const alternatives = [];
const prefix = 'my-prefix-';
if (packageName.startsWith(prefix)) {
alternatives.push(packageName.slice(prefix.length));
}
const suffix = '-js';
if (packageName.endsWith(suffix)) {
alternatives.push(packageName.slice(0, 0 - prefix.length));
}
if (packageName === 'classnames') {
alternatives.push('cx');
}
return alternatives;
},
At Brigade, we have this in our .importjs.json config:
If we simply would ignore the "js" part of a package, these could be automatically imported and wouldn't have to be part of the aliases configuration.