-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import error #2
Comments
I'm also seeing exactly this error, but it's extremely hard to pin down and I can't even reliably repeat it. I did notice adding any statement resolves the problem - could it be some sort of race condition? Throws error:
Doesn't throw:
I'm using next.js, and my .babelrc is very simple:
Thanks for any help. |
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. |
If you guys want to try upgrading to v2.0.0, it may fix the problem. I didn't do anything to purposely fix it but I pretty much completely rewrote the plugin so I may have inadvertently fixed the bug. |
I am still facing the same issue with the latest release. It does not seem to be fixed. I will try to investigate more too an see if I can bring more information. |
i was having a similar problem and i think i have fixed it. You basically need a env set for production in your babel rc. Take a look at mine:
not sure if you are experiencing the same issue but let me know if this works for you :) |
Unfortunately it's still reoccurring with the new version, and the suggestion by TAQ2 hasn't worked either. Happy to experiment with other possibilities, if there are any suggestions? |
@bs1180 I'm still not sure why this is happening, but I've got some time to investigate now. I'm considering adding a My first step is to recreate the issue on my end so I've got a few questions:
Thanks for your patience with this issue btw. P.S. If you have time to condense your project into a simple reproduction repo of the issue that you can share, that would be extremely helpful. If not, I'll do my best to recreate your scenario from your description. |
@seeden If you can provide a reproduction repo of your error, I'll be glad to take a look and try to fix it. Sorry for the long wait. |
@seeden @bs1180 I've created an example project where I attempted to recreate the errors you guys were getting, but I'm not getting an error in either case. I named my query import the same as the file name(seeden's case), and tried importing and immediately exporting(bs1180's case) The first case(master branch) is closer to what I would normally do, but I made a "separate-component" branch to more closely imitate what bs1180 appeared to be doing. Both branches work fine for me. I'm closing this for now, but if either of you are able to reproduce the error in a repo(or fork of mine) I'll reopen this issue. Hope my example helps! |
Hi @detrohutt I tried your latest version 2.0.0 and I can see same error. // models
import Leaderboard from './models/Leaderboard.graphql';
// payloads
import LeaderboardTypePayload from './queries/LeaderboardTypePayload.graphql';
// queries
import leaderboards from './queries/leaderboards.graphql';
import leaderboardType from './queries/leaderboardType.graphql';
export default [
// models
Leaderboard,
// payloads
LeaderboardTypePayload,
// queries
leaderboards,
leaderboardType,
]; Next works // models
import LeaderboardModel from './models/Leaderboard.graphql';
// payloads
import LeaderboardTypePayload from './queries/LeaderboardTypePayload.graphql';
// queries
import leaderboards from './queries/leaderboards.graphql';
import leaderboardType from './queries/leaderboardType.graphql';
export default [
// models
LeaderboardModel,
// payloads
LeaderboardTypePayload,
// queries
leaderboards,
leaderboardType,
]; /Users/seeden/Documents/git/quizana-ui/node_modules/babel-core/lib/transformation/file/index.js:590
throw err;
^
TypeError: /Users/seeden/Documents/git/quizana-ui/src/graphql/leaderboard/typeDefs.js: Cannot read property 'type' of undefined
at Whitespace.getNewlinesAfter (/Users/seeden/Documents/git/quizana-ui/node_modules/babel-generator/lib/whitespace.js:50:19)
at Generator._printNewline (/Users/seeden/Documents/git/quizana-ui/node_modules/babel-generator/lib/printer.js:459:34)
at Generator.printJoin (/Users/seeden/Documents/git/quizana-ui/node_modules/babel-generator/lib/printer.js:376:32)
at Generator.printList (/Users/seeden/Documents/git/quizana-ui/node_modules/babel-generator/lib/printer.js:430:17)
at Generator.ObjectExpression (/Users/seeden/Documents/git/quizana-ui/node_modules/babel-generator/lib/generators/types.js:57:10)
at /Users/seeden/Documents/git/quizana-ui/node_modules/babel-generator/lib/printer.js:298:23
at Buffer.withSource (/Users/seeden/Documents/git/quizana-ui/node_modules/babel-generator/lib/buffer.js:168:5)
at Generator.withSource (/Users/seeden/Documents/git/quizana-ui/node_modules/babel-generator/lib/printer.js:189:15)
at Generator.print (/Users/seeden/Documents/git/quizana-ui/node_modules/babel-generator/lib/printer.js:297:10)
at Generator.ObjectProperty (/Users/seeden/Documents/git/quizana-ui/node_modules/babel-generator/lib/generators/types.js:92:8) |
@seeden I have still failed to reproduce this error. I have tried on Linux and Windows. I'm starting to suspect it is a problem with babel and not with my plugin. What operating system are you using and what version of babel-cli? |
I have same problem on my Mac and Ubuntu as well. "babel-cli": "^6.24.1",
"babel-core": "^6.25.0", and .babelrc {
"presets": [
["env", {
"targets": {
"node": true,
},
"useBuiltIns": true,
"loose": true,
}],
"stage-0",
"react",
],
"plugins": [
"babel-plugin-inline-import-graphql-ast",
"transform-decorators-legacy",
"transform-class-properties",
"dynamic-import-node",
"transform-proto-to-assign",
"transform-flow-strip-types",
],
} |
Ok, good news. I was finally able to reproduce the bug. This was the only way I was able to reproduce it:
For Example:
In my case there were several different workarounds, any of which got rid of the error:
I was able to reproduce this in both |
@detrohutt not for me. Here is an example of file with the issue when removing the comment line https://gist.github.com/real34/851e9c210a90772368424658f9494353#file-gallery-js-L58 I have 3 files in error, and every time adding a comment line before the call to the enhancer (like in the example above) solve the issues.
and
|
Saw the same error, added a comment before client.query and started working again... |
@rngadam try using the new version I just released and see if that works any better. It's version |
I'm still experiencing this bug, has any solution been found? |
@jjant I just published version |
@detrohutt I kinda gave you an idea ... #2 (comment). |
@FredyC Fair enough. For the last month or so I've been focusing exclusively on learning C++ and working on a project in that. I'm not sure I want to "context switch" back to this project at the moment, but as soon as I pick this back up I'll add some debugging. In the meantime if you or anyone else is interested in making a PR to do that, I'll gladly accept it. |
Has anyone tried to fix this? Or can recommend an alternative? |
Hey guys, please try the fix @vstepanyuk made by using |
i'm still seeing the same error :/ |
me too, error still exists. |
Can you share your examples? |
Happens to me too. |
If I put a new line above the .graphql file, it works. I think I found a weird bug with it. When I use auto format with prettier using an atom plugin it seems to fail. I also wonder if its a problem with not using semi colons? |
I just added newlines between the import statements and it works. This does not work:
This works:
if there are no newlines, it doesn't. :) Of course, eslint is now happy about this. Any chance we can get a fix? |
@advance512 you can try the new beta version I just published. Please let me know whether or not that fixes it for you.
|
did |
Hi, for me it still doesn't work with This doesn't work:
It works:
|
Hi, we managed to create a repository with a reproduction of this bug. To reproduce:
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! |
Good job, @real34 ! |
Thanks @real34 ! I’m not sure if I’ll get to it today since it’s thanksgiving here in the U.S. but I’ll get to work on it ASAP! |
@real34 I just published |
Update (2017/11/27)Sorry, it still happens, I have to add a blank line above the import to fix it. |
@EdwardAA I tried yet another approach with |
2.0.3-beta.3 does not fix the issue. |
import * as TestQuery from '../queries/test.graphql'; |
I made a PR to I need some thumbups to make sure that a new version of Babel 6 will be released with this fix. |
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, it doesn't look like there's much movement on the babel PR to fix this issue. I really appreciate everyone here being so patient about this bug. I know first-hand how annoying it is. As a "thank you" to you guys, I just released a new beta that has a pretty cool feature. It adds support for multiple operations just like the graphql-tag webpack loader got last month. Try it out and let me know what you think! It's @beta or "2.2.0-beta.0" |
The babel team got this sorted out. See this comment for more info. The gist is you need to remove your |
MIT License Copyright (c) [year] [fullname] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
When I use next import I can see error and my build will fail
But when I change quiz => quizQuery evrything is fine.
I have really no idea what is wrong with names. I have same error across whole project.
The text was updated successfully, but these errors were encountered: