-
Notifications
You must be signed in to change notification settings - Fork 148
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
Named exports get imported using a default import (which doesn't work) #215
Comments
Yeah, I agree. I wrote the transform originally when I was just starting out using ES6 modules and I didn't really understand some of the crucial differences. Haven't really touched it much since. So yeah, I agree it deserves to be moved into unsafe category. |
Done. Digging into this I realized there are several other issues with |
@nene thank you for Lebab. I hit this wall too soon. What if
gets transferred to:
|
While that would be doable, it results in code that has an obviously auto-generated look. But the goal of Lebab is to produce human-readable ES6 code. I think the better fix for this is actually on the import a from './a'; You would simply need to: import * as a from './a'; The tricky bit is for Lebab to decide which form of import it should use. Lebab would need to know whether the imported file uses default export or named exports. Currently though there are technical limitations to be overcome for implementing this as the |
commonjs
transform actually safe?
Take a look at this scenario
✅ Works
Gets transpiled to:
❌ Nope.
In order to solve this you need a manual change, so:
✅ There we go. But again, this is a manual change.
Once I solved all those kind of issues, all the rest of safe transforms worked like a charm 👍.
I know, in order to figure out this kind of scenarios,
lebab
should do a lot of extra heavy lifting and run checks of usage across files. This issue is not a feature request. Just pointing out that commonjs is not that safe, specially when using it through--replace
. Thoughts?The text was updated successfully, but these errors were encountered: