Open eirikurn opened 3 years ago
What about supporting what webpack does?
https://webpack.js.org/configuration/resolve/#resolvealias
A trailing $ can also be added to the given object's keys to signify an exact match:
const path = require('path');
module.exports = {
//...
resolve: {
alias: {
xyz$: path.resolve(__dirname, 'path/to/file.js'),
},
},
};
With a config like this:
When someone imports
app/utils
, it should first do an exact match and resolve to "vendor/utils" before trying asterisk patterns sorted by the longest prefix. See microsoft/typescript. Note that the order of the patterns should not matter.Currently, tsconfig-paths only finds the first match in the order of longest prefix. Patterns that don't have an asterisk, have a prefix length of 0, so they get matched after all patterns with asterisks in them.