babel-plugin-import-graphql: import error
When I use next import I can see error and my build will fail
import quiz from './queries/quiz.graphql';
import quizzes from './queries/quizzes.graphql';
/Users/seeden/Documents/git/quizana-ui/node_modules/babel-core/lib/transformation/file/index.js:590
throw err;
^
TypeError: /src/graphql/quiz/typeDefs.js: Cannot read property 'type' of undefined
at Whitespace.getNewlinesAfter (/node_modules/babel-generator/lib/whitespace.js:50:19)
at Generator._printNewline (/node_modules/babel-generator/lib/printer.js:459:34)
at Generator.printJoin (/node_modules/babel-generator/lib/printer.js:376:32)
at Generator.printList (/node_modules/babel-generator/lib/printer.js:430:17)
at Generator.ObjectExpression (/node_modules/babel-generator/lib/generators/types.js:57:10)
at /node_modules/babel-generator/lib/printer.js:298:23
at Buffer.withSource (/node_modules/babel-generator/lib/buffer.js:168:5)
at Generator.withSource (/node_modules/babel-generator/lib/printer.js:189:15)
at Generator.print (/node_modules/babel-generator/lib/printer.js:297:10)
at Generator.ArrayExpression (/node_modules/babel-generator/lib/generators/types.js:106:12)
But when I change quiz => quizQuery evrything is fine.
import quizQuery from './queries/quiz.graphql';
import quizzes from './queries/quizzes.graphql';
I have really no idea what is wrong with names. I have same error across whole project.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 46 (23 by maintainers)
I made a PR to
babel-generator
to fix this issue https://github.com/babel/babel/pull/7205.I need some thumbups to make sure that a new version of Babel 6 will be released with this fix.
<del>2.0.3-beta.2 works for me, thanks 👍 </del>
Update (2017/11/27)
Sorry, it still happens, I have to add a blank line above the import to fix it.
Hi, we managed to create a repository with a reproduction of this bug.
To reproduce:
npm install && npm start
We noticed the bug is related to the number of chars… See video below:
https://www.dropbox.com/s/dwcce8skh5eafus/screencast_00000.mp4?dl=0
We hope it will help!
Thank you very much @MatthieuLemoine I regret I’ve not had the time to deal with this myself but I’ve been dealing with this bug pretty much every day in my current project and my codebase is littered with empty comments to accommodate it. I hope they will merge your pr and release for babel 6. I added a few reactions.
Unfortunately I have no idea how to fix this. This project was my first attempt at working with babel plugins so I’m not very familiar with the concepts.
I will say someone else reported another issue with the same error message to me. In his case, it happened when he added a blank line before one of his import statements. I was unable to reproduce that error on my end though.
Anyone more knowledgeable feel free to make a pull request or point me in the right direction.
Thanks @seeden and @bs1180 for your help in working around the bug. When I have more time I’ll try to do some research into what might be causing this.
@rngadam try using the new version I just released and see if that works any better. It’s version
2.0.1-rc.1
@seeden @bs1180 @real34 I think I fixed it! Try upgrading to
2.0.1-beta.4
and let me know if it works for you.I have same problem on my Mac and Ubuntu as well. Here is my versions:
and .babelrc