-
Notifications
You must be signed in to change notification settings - Fork 135
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
Namespace import crashes the plugin #111
Comments
Thanks for bringing this up @InvictusMB. My inclination is to just throw a hard error with a sensible error message to tell people they can't use macros this way. But then I think why can't they? So instead, do you think that you could make a PR to make this work? I don't want to treat it as a default import though. I want it to work as it normally would (where the namespace specifier is basically an object with all exports on it). What do you think? |
I don't have a good answer to this.
I agree, however I don't see much syntactic difference between default import and namespace import for a macro user. My gut feeling tells me that it is better to treat default imports as equal to namespace imports and not complicate 99% of use cases. Otherwise it seems to be a rabbit hole. Let's say we have this code import * as foo from 'foo.macro';
foo.bar();
foo["baz"](); I assume, you want it to be handled as equivalent to import {bar, baz} from 'foo.macro';
bar();
baz(); The algorithm could be:
On the macro side this will also complicate things. I'm not 100% sure this extra complexity is worth the outcome. P.S. The test suite fails on my windows machine. Does it have any windows specific reasons to fail?
|
I'm also not convinced it's worth the work. Tests should definitely work on windows, but I don't have a windows machine to test it on. PRs welcome for that! |
I have a PR on the way for this.
|
You know what, I'd really rather wait until someone's really asking for this before making a bunch of changes 😬 |
I agree. I want the plugin not crashing though. |
@kentcdodds |
No, but nobody's actively working on it or asking for it. Sorry, I should have commented about that when closing. |
You know what, I'll go ahead and work on this myself. |
babel-plugin-macros
version: 2.5.1Relevant code or config
What happened:
Compiler fails with the following message
Problem description:
ImportNamespaceSpecifier
node is not handled properly here and the error message is not helpful. Offending code:babel-plugin-macros/src/index.js
Lines 78 to 80 in e0ebca7
Suggested solution:
ImportNamespaceSpecifier
should either be handled asdefault
case or as a separatenamespace
case. Or maybe both variants are valid and there should be a config option akin toallowSyntheticDefaultImports
in TypeScriptQuick fix:
The text was updated successfully, but these errors were encountered: