Skip to content
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

Plugin compatibility, exit vs enter? #84

Closed
yggie opened this issue Oct 13, 2016 · 5 comments
Closed

Plugin compatibility, exit vs enter? #84

yggie opened this issue Oct 13, 2016 · 5 comments
Labels

Comments

@yggie
Copy link

yggie commented Oct 13, 2016

I had trouble composing another module transformation babel plugin I wrote with this module, and I finally boiled it down to the fact that I was using enter and you were using exit (see here).

Its really more of a question than an issue, was there any particular reason to use exit rather than enter for your code? Since this is a relatively simple transformation, would it make sense to perform it as early as possible so that it is easier to compose? Forgive me if this is a silly question, I have very little experience with babel myself.

@tleunen
Copy link
Owner

tleunen commented Oct 16, 2016

Hey @yggie. No particular reasons.
I used exit because I noticed the other plugins used that as well.

I believe changing it to enter shouldn't be an issue, but could you share a bit what you're trying to achieve?

@yggie
Copy link
Author

yggie commented Oct 17, 2016

hey @tleunen, I have written a simple plugin that inlines the JSON file imports as part of the babel compilation process (the repo is here). In one of my projects, I decided to use this plugin together with yours to get JSON files from a directory under an alias, something like:

import json from 'custom-path/to/json'

right now, this approach fails because my plugin uses enter whereas yours uses exit. In my case, I thought it would make sense to use enter to allow other plugins early access to the imported JSON structure, in case something needed to be done with it (uglifiers for example). I am open to ideas on how to solve this, my plugin is still fairly new so there shouldn’t be huge repercussions if I make changes on my end.

@tleunen
Copy link
Owner

tleunen commented Oct 25, 2016

Hmm... I see your point.
I don't know issues we could have by changing for enter instead :s Did you try it? Do you have exactly the same result?
It seems Facebook also uses exit for their system

@yggie
Copy link
Author

yggie commented Oct 25, 2016

Yes I have tried patching your library to use enter, it worked fine. I have also tried using exit for my library, and that works too.

If it is generally accepted to use exit, then I will just change my plugin to use exit instead. I might have just misunderstood how to use enter and exit properly, I trust Facebook’s decision more than my own 😄

@tleunen
Copy link
Owner

tleunen commented Oct 25, 2016

I must say I don't really see the reasons to use one versus the other. I can see the benefits of using enter, as explained by your needs. I will try to find documentation on both enter and exit and see what's best in our case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants