With Babel 7 beta and babel-loader 8.0.0-beta.0 it throws an error:
ERROR in ./src/js/index.js
Module build failed: TypeError: Cannot read property '1' of undefined
at Plugin.manipulateOptions (C:\teste\webpack-boilerplate-react-graphql-ssr-css-in-js\node_modules\babel-plugin-module-resolver\lib\index.js:88:9)
at normalizeOptions (C:\teste\webpack-boilerplate-react-graphql-ssr-css-in-js\node_modules\@babel\core\lib\transformation\normalize-opts.js:83:17)
at runSync (C:\teste\webpack-boilerplate-react-graphql-ssr-css-in-js\node_modules\@babel\core\lib\transformation\index.js:34:84)
at transformSync (C:\teste\webpack-boilerplate-react-graphql-ssr-css-in-js\node_modules\@babel\core\lib\transform-sync.js:15:38)
at Object.transform (C:\teste\webpack-boilerplate-react-graphql-ssr-css-in-js\node_modules\@babel\core\lib\transform.js:20:65)
at transpile (C:\teste\webpack-boilerplate-react-graphql-ssr-css-in-js\node_modules\babel-loader\lib\index.js:55:20)
at Object.module.exports (C:\teste\webpack-boilerplate-react-graphql-ssr-css-in-js\node_modules\babel-loader\lib\index.js:179:20)
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server react-hot-loader/patch webpack/hot/only-dev-server ./src/js/index
Is it being updated?
Thanks!
[UPDATE]
I updated the babel-plugin-module-resolver to 3.0.0 and the error above stopped, but the "root" node isn't working, I need to do this:
['module-resolver', {
root: ['./src/js'],
alias: {
MasterPage: './src/js/structure',
Actions: './src/js/actions',
Reducers: './src/js/reducers',
RootRoute: './src/js/routes',
Store: './src/js/store'
}
}]
Would you have a repo where we can test this? I'd like to debug why the root wouldn't work anymore in your case
I'm also using babel 7 and with the version 3.1.0 of babel-plugin-module-resolver (Awesome package btw).
My context is an universal react app with webpack compiling a client version and a server version of my app. My aliases are only targeting folders belonging to my own app (no shortcut to externals node modules).
I'm getting a lot of errors like this one.
ERROR in ./node_modules/glob/glob.js
Module not found: Error: Can't resolve 'fs'
If I go back to the 3.0.0, everything work fine again.
@tleunen yes! sorry, I didn't receive the notification. My repository is https://github.com/rafaelmaruta/webpack-react-redux-sass-css-modules-flow
It has one .babelrc and webpack configuration inside the webpack folder
I was initially having the same issue with my update to Babel 7 beta 42, but it turned out I was pinned to an old version of babel-plugin-module-resolver (2.7.1). When I updated to 3.1.1 the problem went away for me.
I also have this behavior, using "@babel/core": "^7.0.0-0", etc., and "babel-plugin-module-resolver": "^3.1.1".
I was able to solve it using @rafaelmaruta 's fix. Here's my original config (broken) vs new config (working).
For resolving modules at the following paths:
/src/src/actions
/src/src/components/answerspages
/src/src/components/common/buttons
/src/src/components/common
plugins: [
['babel-plugin-module-resolver',
{
root: ['/src'],
alias: {
actions: './src/actions',
answerspages: './src/components/answerspages',
buttons: './src/components/common/buttons',
common: './src/components/common',
...
root: ['/src'],
alias: {
actions: 'src/actions',
answerspages: 'src/components/answerspages',
buttons: 'src/components/common/buttons',
common: 'src/components/common',
...
Changing the alias key's values to relative file paths seems to have fixed the problem (though I've got more testing to do).
@SterlingVix , did everything work?
@rafaelmaruta, I may have had to change it again. I've had some health issues keeping me away from work (馃) but I'm setting myself a reminder to check it out next time I'm back at the desk.
I think is would be nice if you edit your readme.md to warn other one about broken issues
@SterlingVix I also hadn't time, but until next week I'll test too
@rafaelmaruta I cloned your repo and here's what I did:
src/js/index.js.yarn start.import Store from 'Store'import Store from 'store' - it was workingimport Store from 'storeee' - it wasn't working (expected)root: ['./src/js'], to root: './src/js',import Store from 'Store'import Store from 'store' - it was workingimport Store from 'store/index' - it was workingimport Store from 'store/index.js' - it wasn't working (expected)import Store from 'store/index.jsx' - it was workingIn conclusion, everything seems to be working properly.
As a matter of fact I've been using babel-plugin-module-resolver 3.1.1 with Babel ~7.0.0-beta.40 and higher for over a month and it's just working. In any case, since Babel 7 is still in beta, things are expected to break - but I verified that they aren't broken.
If there was one beta version which didn't work with the plugin, please update Babel or use Babel 6 instead.
If you want the plugin to work with Babel 7, please make sure that you're using the newest version of the plugin.
Most helpful comment
I think is would be nice if you edit your
readme.mdto warn other one about broken issues