Skip to content

Add ava/babel as a shortcut for including AVA's Babel presets #1225

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

Closed
vadimdemedes opened this issue Feb 4, 2017 · 7 comments
Closed

Add ava/babel as a shortcut for including AVA's Babel presets #1225

vadimdemedes opened this issue Feb 4, 2017 · 7 comments
Labels
enhancement new functionality

Comments

@vadimdemedes
Copy link
Contributor

It seems to be a good convention across the community (glamor, next.js, more) to provide a shortcut for auto-including Babel settings. If user wants to customize presets, right now he has to include these presets manually. What I'm proposing:

{
  "presets": [
    "ava/babel",
    "custom-preset"
  ]
}

It would also significantly simplify the creation of tools like ava-preact-init, ava-react-init, ava-inferno-init, etc. If we provide a simple entrypoint for these presets, we won't need to update each of these modules when we change something in our presets.

@vadimdemedes vadimdemedes added babel enhancement new functionality labels Feb 4, 2017
@novemberborn
Copy link
Member

We have @ava/stage-4 and @ava/transform-test-files now. What are you proposing @ava/babel does?

@vadimdemedes
Copy link
Contributor Author

No, not @ava/babel package, but ava/babel.js file. This file would simply serve as a preset, which would include @ava/stage-4 and @ava/transform-test-files. Think of it as a handy shortcut, nothing more.

@novemberborn
Copy link
Member

Ah. I think we should wait and see how the new presets get used, especially as we improve our Babel support.

@vadimdemedes
Copy link
Contributor Author

I think we should wait and see how the new presets get usedI think we should wait and see how the new presets get used

Could you explain that more? I didn't get the point.

@novemberborn
Copy link
Member

See if and how people use @ava/stage-4 / @ava/transform-test-files, without adding a wrapper preset to AVA itself.

@novemberborn
Copy link
Member

Turns out a preset like this is suggested in RFC 001:

testOptions: {}: specify the Babel options used to compile test and helper files. If provided this completely disables the default Babel configuration AVA uses to compile test and helper files. Like with sourceOptions, babelrc defaults to true. Set presets: ["ava"] to apply AVA's transforms.

Though I suspect we may have to parse the options looking for that preset, and then replacing it with @ava/stage-4 and @ava/transform-test-files. The latter taking the power-assert option into account.

@novemberborn novemberborn added this to the 1.0 milestone Sep 3, 2017
novemberborn added a commit that referenced this issue Jan 26, 2018
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.
@novemberborn
Copy link
Member

#1608 implements ava/stage-4 as an alias for our @ava/stage-4 preset. I've decided not to expose @ava/transform-test-files as I want to (conceptually at least) separate the enhancements it contains from AVA's Babel usage.

novemberborn added a commit that referenced this issue Jan 27, 2018
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.
novemberborn added a commit that referenced this issue Jan 27, 2018
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new functionality
Projects
None yet
Development

No branches or pull requests

2 participants