Support resolve.root
Could this plugin be made to support resolve.root? Is there a way to consider it now?
The way I'm doing it now is grabbing my aliases off of my webpack config and prepending the root to them for the aliases I pass to this plugin.
Yeah I'll have a look at implementing resolve.root, it shouldn't be too hard.
+1
The issue I have there is that I'm not sure how the resolve.root option works 🤔 The webpack documentation is unclear.
EDIT: What I really don't get is how doesn't work when you have both a root and aliases 🤔
We're using babel-plugin-webpack-alias for running our tests in Mocha without full build.
Today it stopped work for us after dependencies update
Upon running tests we've got such error: Error: Cannot find module 'actions/api' throwing from very first test
Here's resolve part of our config:
var path = require('path')
module.exports = {
"resolve":{
"root": path.resolve(__dirname),
"modulesDirectories":[
"node_modules",
"actions",
"components",
...
],
"alias":{
"commonActions":"actions",
"apiActions":"actions/api",,
"customFormActions":"actions/formCustom",
"components":"components",
"formComponents":"components/form",
...
},
"extensions": ['', '.json', '.js', '.jsx']
},
...
}
P.S. We finished up in approach from first comment: create separate test config with absolute paths for aliases. That works for us but may confuse other users of this library
@vpotravnyy Hi! Sorry for the issue, I will look at it
At the moment it doesn't work with extensions and relative aliases... I'm working on a fix right now
@vpotravnyy I'm moving that to another bug as it is not related to the resolve.root support: https://github.com/trayio/babel-plugin-webpack-alias/issues/14 Thanks for raising the issue!
I've been playing around doing something similar to what this plugin seems to do, and I found that the resolveLoader.root was what I had to use instead of resolve.root see this issue for more info: https://github.com/webpack/webpack/issues/207
In case anyone's interested, I just published the utility I've been using to get webpack to play nice with aliases here: https://www.npmjs.com/package/webpack-local-libs