babel-plugin-module-resolver
babel-plugin-module-resolver copied to clipboard
[Severe BUG] cannot resolve symbolic directory links
In my root of project "src", I created two symbolic links:
ln -s Projectxx/src/A src/A
ln -s Projectxx/src/B src/B
src/A -> Projectxx/src/A src/B -> Projectxx/src/B
For example Projectxx/src/A has file1, file2, file3, where file1 imports file2 and exports an interface to outside of the project. I used webpack in Projectxx to provide module alias:
\\ Projectxx/src/A/file1.js
import {xxx} from "A/file2"
Now in the project I am working on, I will use interfaces provided by file1
\\ src/M/endpoints/map.js
import {yyy} from "A/file1"
I have defined module aliases in .babelrc, but that doesn't work. Node throws errors because it cannot detect "A/file2"
//.babelrc
{
...
plugins: [
...
["module-resolver", {
"root": ["./src"],
"alias": {
"A": "./src/A"
}
}]
]
}
I think this should be a bug.
same issue, anyone has solve it
Remove the symlink and let the plugin handle the path? So the config would be to have A set to ProjectX/src/A instead.
Solved this in react native + metro land by just aliasing to the real path of the symlink -
plugins: [
[
'module-resolver',
{
root: './src',
...
alias: {
common: '../common/build', // common is a symlink in node_modules/common to ../common/build
},
},
],
],
@Maushundb how is this different than the snippet of code in the original question?
Rather than adding the alias to the path of the symlink, I just added the alias to the original path as a workaround