-
Notifications
You must be signed in to change notification settings - Fork 28
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
Cannot import testdouble: rendering invalid hoisted variable #226
Comments
|
Basically it fails on the code like |
Interesting. I will have a look into it later this evening! :) |
Was able to reproduce and created a sample test case with a few other variations. I have an idea on how to fix it, so should hopefully have a fix incoming very soon! |
@PepsRyuu thanks for looking at it. Other than transforming it into a normal assignment without destructuring I had an idea to wrap any assignment in parens like var blah;
// ...
({ blah } = require("...")) this would be valid syntax but there are semicolon problems |
I was just looking into that when you wrote that! 😁 I have the test case passing at the moment using that (with auto-insertion of the semi-colon if missing). Will need to thoroughly test it though to make sure there won't be any other issues as a result of the insertion of the new characters. If you're curious, this is what I have so far: #227 |
@PepsRyuu yup, that's what I tried as well except I don't know magic-string well enough. I can test this tomorrow on our use case |
Apologies for the delay, busy week. :) I've pushed an extra test case, seems to work this fix. Have you had a chance to test it with your use case? If it works for you I'll go ahead and release. |
@PepsRyuu cheers! No worries. Didn't have a chance yet unfortunately, will try to do it on Monday |
I'm sorry that it takes so long, I little bit busy, I will definitely do it by the end of the week |
repo to reproduce:
tutao/nollup-bug@9ce90c6
(run
node make
)I debugged a little and it seems like it's happening around
node.type === 'VariableDeclaration'
becausenode.declarations.id
doesn't have a name, it's an object pattern of some kind.The text was updated successfully, but these errors were encountered: