Open bkonkle opened 7 years ago
@bkonkle did you ever figure this out?
I wound up using moduleNameMapper
in the package.json:
"moduleNameMapper": {
"^shared/(.*)$": "<rootDir>/js/shared/$1"
},
I ended up ditching aliases altogether, and going with lerna
and a monorepo structure. :-)
For people finding this issue:
Use this plugin only in your development
env.
// Babel config
"env": {
"development": {
"plugins": [
[
"babel-plugin-webpack-alias",
{
"config": "./path.to.webpack.config"
}
]
]
}
}
Then use Jest's moduleNameMapper
to reconfigure aliases for Jest.
moduleNameMapper
expects to see module with index.js
under mentioned path, still webpack's resolve.alias
work in another way - it just substitutes file path to the imported file, so you don't need to have index.js
under this folder.
At the moment I can't setup babel-plugin-webpack-alias
for jest
and can't use moduleNameMapper
because of that.
Actually my problem was that I used babel@7
, so switching to babel-plugin-webpack-alias-7
solved the problem for me. Details are here: https://github.com/trayio/babel-plugin-webpack-alias/issues/50
Hi! Thanks for sharing this project! I'm trying to use it with Jest, and running into trouble:
I'm digging into the source trying to figure out how to work around it, but I don't have any good leads yet. If anyone has ideas, I'd love to hear them! :-)
My
.babelrc
: