-
Notifications
You must be signed in to change notification settings - Fork 90
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
TypeError on named re-exports #98
Comments
@spncrlkt I would prefer not to work with stage-1 export. What do you think about the solution proposed in https://gitter.im/speedskater/babel-plugin-rewire do only work with a sinlge named export containing all the API and a codemod transferring the existing code to it? |
A named export would imply a different API than rewire itself, unless you still |
@TheSavior thats true. But in my optionion the main focus of this project should be to provide the best mocking functionality for es6 code, regardless of the used module implementation. The named export module/api object will iteslf be API-compatibel with rewire. Hence to provide backward compatibility it is simply a matter of reexporting this object as the default export and batch it on the default export. This can be done by another plugin, or can also be done by a plugin, which uses the old commonjs default export behavior. |
@speedskater Provided babel-plugin-rewire can accommodate my code under test (containing named wildcard exports, as above), I have no opinion on what the rewire API looks like. Whatever you think is best. I just want to use stage-1 exports. Thank you for all your hard work! |
@TheSavior, @spncrlkt The problem regarding reexports and the rewire plugin approach itself is more severe as I have initially thought. |
👍 hoping a good solution can be found soon! |
@spncrlkt I have merged your fix into the master branch. Thanks for your PR. I think we will still have to find a way how to proceed without polluting existing named exports but it will be a task for the upcoming releases. |
I'm using babel-plugin-rewire, and really like it! I ran into the following blocking issue.
If I do a named re-export like:
I get the following error:
"TypeError: (...)/dev/rewire-example/exports.js: Cannot read property 'name' of undefined"
Possible solution:
when i change the following line in the installed node_module, the error goes away. Seems like on re-exports,
specifier.local
doesn't exist, butspecifier.exported
does exist. I'm not sure if this would break anything, so want to get a quick sanity check.https://github.com/speedskater/babel-plugin-rewire/blob/master/src/babel-plugin-rewire.js#L121
Repro repo: https://github.com/spncrlkt/babel-plugin-rewire-repro
Update:
Seems like the case I'm trying to handle would be similar to a wildcardExport. The difference is it's a namedWildcardExport. I'm going to write a failing case for it, then begin looking at a fix.
Update: this is a stage-1 export option, which is proposed here: https://github.com/leebyron/ecmascript-more-export-from. Does babel-plugin-rewire want to work w/ babel's stage-1 preset?
Thanks!
The text was updated successfully, but these errors were encountered: