-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Automatically apply stage-4 preset even when Babel options are customized #1488
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
Comments
Actually I see why this may be a problem. Someone may want to completely overwrite the default My original issues are still relevant though, I think it would be better if there was a way to extend the default AVA babel config without having to copy the defaults. |
This is implemented in these lines: https://github.com/avajs/ava/blob/b6eef5ac30e7839371a420f17060f62f971717aa/lib/babel-config.js#L100:L127 We have a If Typically the problem users run into is that module syntax is no longer transpiled. As you say it'd be great if we would still include Given that we already resolve the config ourselves, we could default to adding the Another approach may be to explicitly re-export With either approach, naming is the problem. We always want to apply the |
What about an extend option? Something like: "ava": {
"babel": {
"extend": {
"plugins": ["transform-react-jsx"]
}
}
} The above config makes it clear I always want the default AVA babel config, but just extend it with "transform-react-jsx". I'm not keen on that exact example as it's not clear how it should be handled if both What do you think?
The issue wasn't so much installing the dev dependency, it was hardcoding |
The proposal in https://github.com/avajs/ava/blob/master/docs/specs/001%20-%20Improving%20language%20support.md#babel-projects is to always disable the default AVA behavior whenever anything is customized. It suggests an Applied to the current situation you'd get:
The problem though is that you can't use This is just odd, though:
But I think it's on the right track. Just need to come up with a better property name than |
"ava": {
"babel": {
"plugins": ["transform-react-jsx"],
"presets": ["ava"]
}
} Expresses the intent perfectly IMO. Is it an issue that it can't be used in If so, what about: "ava": {
"babel": {
"extendsDefault": true,
"plugins": ["transform-react-jsx"]
}
} |
I think it's misleading. Users may be tempted to move it into an external file. Let's assume If we go this route, perhaps the |
👍
Extending by default and having a
That makes sense to me. |
👍 (Note that semantically, AVA's default extends the user config, not the other way around.)
Yes.
👍 This may be a good time to add support for Would you like to take this on @lukechilds? |
I'm happy to take it on, however I've spent quite a bit of time on OSS recently and ideally need to focus on paid work for a bit so can't guarantee it'll be done soon. |
No worries, I know the feeling 😄 If anybody else wants to pick this up in the meantime, please drop a line! |
@lukechilds Do you think this would make the extending easier? #1225
|
@vadimdemedes You mean so we could have this: #1488 (comment)? If the |
Yes, only with that example: "ava": {
"babel": {
"plugins": ["transform-react-jsx"],
"presets": ["ava"]
}
} we'd need to have |
"ava": {
"babel": {
"plugins": ["transform-react-jsx"],
"presets": ["ava/babel"]
}
} is equally beautiful to me ❤️ |
As for @novemberborn's concern about using AVA's presets in |
That would work (and we could handle the |
Always extend the project's Babel configuration, if any. Always apply the `@ava/stage-4` preset. Fixes #1488. Users can disable this preset by adding it to the AVA's Babel configuration with the `false` option: ``` "ava": { "babel": { "presets": [ ["ava/stage-4", false] ] } } And yes, `ava/stage-4` so now an alias for the preset, which means it can be used even if the preset is not installed as a top-level dependency. Fixes #1225. `@ava/transform-test-files` is applied as part of the test compilation, but cannot be overridden by users like `@ava/stage-4` can.
#1608 now always applies |
Always extend the project's Babel configuration, if any. Always apply the `@ava/stage-4` preset. Fixes #1488. Users can disable this preset by adding it to the AVA's Babel configuration with the `false` option: ``` "ava": { "babel": { "presets": [ ["ava/stage-4", false] ] } } And yes, `ava/stage-4` so now an alias for the preset, which means it can be used even if the preset is not installed as a top-level dependency. Fixes #1225. `@ava/transform-test-files` is applied as part of the test compilation, but cannot be overridden by users like `@ava/stage-4` can.
Fixes #1598. Switches AVA's Babel implementation to use Babel 7. This applies to test and helper file compilation. Adds a `compileEnhancements` option which can be set to `false` to disable Power Assert and our `t.throws()` helper. Changes the Babel configuration. If you had this before: ```json "ava": { "babel": { "plugins": [] } } ``` You'll now need: ```json "ava": { "babel": { "testOptions": { "plugins": [] } } } ``` `ava.babel.testOptions.babelrc` now defaults to `true`. You can disable our stage-4 preset by adding `["ava/stage-4", false]` to `ava.babel.testOptions.presets`. Set `ava.babel` to `false` to disable AVA's test file compilation, **whilst still compiling enhancements**. If `compileEnhancements` is *also* set to `false` then Babel is skipped completely. Fixes #1225, #1488 and #1556.
The
ava.babel
property of package.json overwrites the default babel config. This means if you want to add support to for JSX for example in your tests, you can't just do:Because it overwrites the default babel presets with
undefined
so you get loads of syntax errors. You can get it working by manually also specifying the default@ava/stage-4
preset:However, this is less than optimal because if AVA upgrades to a new default in the future I'll get a "module not found" error. I could manually add
@ava/stage-4
as a dev dependency to my project to solve this but then that means I'll be out of sync with AVA's default presets if AVA updates.I think the best solution would be for AVA to merge custom options into it's defaults so you can literally extend the settings.
The text was updated successfully, but these errors were encountered: