babel-plugin-webpack-alias
babel-plugin-webpack-alias copied to clipboard
The support for trailing $
Hi!
In the webpack docs for resolve.alias there is an option to resolve a specific file by doing this:
resolve: {
alias: { xyz$: 'path/to/xyz.js' }
}
, and then using it in the code like
import xyz from 'xyz'
However, that does not work with the plugin. What does work is to have a webpack config like this:
resolve: {
alias: { xyz: 'path/to/xyz.js' }
}
, and using it like this:
import xyz from 'xyz'
This is caused by the following line in the src/index.js:176, I think:
let requiredFilePath = filePath.replace(aliasFrom, relativeFilePath);
I can submit a pr, but I'm just not sure what kind of behavior is expected.
Maybe the correct way is checking if aliasFrom
ends with $
, and, in case it does and the path starts with aliasFrom.slice(1)
, do filePath.replace(aliasFrom.slice(1), relativeFilePath)
, so the module remains backward compatible?
Or just add the description of the workaround to the README.md
?