-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
A possible way to provide customizable babel configs using .babelrc
/env
#448
Comments
This is a great start! To keep my AVA and base configs identical, do I write {
"presets": ["es2015", "stage-0"], // base config
"env": {
"development" : {}, // commenting this out does nothing
"ava" : {} // commenting this out does something!
}
} Do you have plans for the general case of a custom register hook, which may transpile imports using transpilers other than Babel? Is that what For reference, here's the hook we're passing to Mocha (which is applied to test code via |
Yeah - that is what I was thinking, but you raise a good point about that being an odd side-effect. If you have a different idea, this is the place to share.
I think maybe If anyone's got a list of alternative transpilers they wish they could use with AVA. I'd appreciate you sharing. Even better if you have in profiling information on those transpilers (require time via That said, this feels much more doable than providing performance enhancements for everyone. |
I like the idea in general, but I'll need to think about how to handle the specifics.
👍 Would be too bad if people lost out on this one and can't think of any bad side-effect of doing it. // @ariporad @JaKXz @MoOx @kentcdodds @sotojuan @SamVerschueren @kevva |
My knee jerk reaction is to say no in favor of less magic ✨. I think that if you're going to override the default config, you should know what the default config is doing for you. |
@kentcdodds I would generally agree, but think of |
That makes sense. I'm in favor 👍 Thanks for keeping me in the loop :D |
Make sense too. It's not like you are adding tons of transformations. |
Hmm... Great idea @jamestalmage! However, This still seems a little weird to me. If we're already using the |
I note that one of XO's pluses is to pull config out of The "env" "ava" fields in the above |
Any news on this ? It will make testing react components easier :) |
@danielhusar No, not yet, can't give any ETA on this unfortunately :( |
@vdemedes Am I right that discussion is over (initial proposal + add power-assert automatically)? And we need just implement it? |
@develar There are still some unanswered questions:
|
@talexand You can put your Babel config in package.json under the |
Here's my two cents... It seems to me that expecting the user to change their For example, your {
"babel": {
"presets": [
"es2015",
"stage-0",
"react"
]
}
} ... and your {
"babel": {
"presets": [
"es2015",
"stage-2",
"react"
]
},
"ava": {
"babel": {
"presets": [
"es2015",
"stage-0",
"react"
]
}
},
} This allows you to have separate babel configs for test and source files if you want. We could also have some special keywords for the
In package.json, it might look like this: {
"babel": {
"presets": [
"es2015",
"stage-0",
"react"
]
},
"ava": {
"babel": "inherit",
},
} |
@spudly, I love the recommendation. I didn't really feel comfortable mucking around with babel's config. This seems much cleaner 👍 |
@spudly 👍 That's some very good cents. I like it. @jamestalmage @vdemedes You good with this? |
I like it! Thanks @spudly! |
This is why micro-libraries are reeeeally nice :-) Maybe someone (me?) could extract that logic into a well tested microlib that both tools use? |
Added a pull request for all except the "extends" key. Let me know what you think. |
👍 - It might be best just to make a PR to Babel that extracts it into a microlib within the Babel monolith repo (that would likely be what the Babel team wants). |
I think it should also be possible to disable Babel completely with: |
👍 |
Reopening this as we still need to implement |
Love it so far, thanks guys! |
👍 Is there any workaround technique that would have the same effect, until this ships? Would |
Sounds reasonable. Only one way to find out for sure ;) |
It'll still use babel, but it will not have any presets, so it won't transform anything. |
Is it possible to disable babel via CLI? minimist translates ⏴ minimist(['--no-babel'])
⏵ { _: [], babel: false } |
Continued from:
#398 (comment)
My proposal is that we allow the following in
.babelrc
:There are a couple questions that need to be answered in order to proceed. Specifically, can we change which
env
Babel uses on a per file basis? It might be as easy as settingprocess.env.BABEL_ENV
before each call tobabel.transform(..)
The text was updated successfully, but these errors were encountered: