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

Babel 7 support and additional enhancements #1608

Merged
merged 12 commits into from
Jan 27, 2018
Merged

Babel 7 support and additional enhancements #1608

merged 12 commits into from
Jan 27, 2018

Conversation

novemberborn
Copy link
Member

@novemberborn novemberborn commented Dec 7, 2017

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:

"ava": {
  "babel": {
    "plugins": []
  }
}

You'll now need:

"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.

@haltcase
Copy link

All seems to work so far! Was up and running using new @babel plugins in tests. .babelrc.js support is something I'm looking forward to.

@danny-andrews
Copy link
Contributor

I tried to give this a whirl. I'm getting Cannot find module 'hullabaloo-config-manager'

@novemberborn
Copy link
Member Author

@danny-andrews are you installing using npm 5.6? Currently these are Git dependencies, and hullabaloo-config-manager has a build step, so earlier npm versions might not handle them particularly well.

@haltcase
Copy link

@novemberborn would it be premature to publish these at @next tags? That'd make it more accessible for testing so is that the plan now at some point?

@novemberborn
Copy link
Member Author

@citycide I think so, yes. There's five dependencies that need updating, one of which we don't have control over. I haven't seen a clear timeline for when Babel 7 goes stable, and there've been significant changes over the past few weeks alone. For now let's stick to installing from this GitHub branch.

@danny-andrews
Copy link
Contributor

danny-andrews commented Dec 13, 2017

@novemberborn I used yarn. I'll just hold off until things progress. Found a workaround to get pipeline-operator to work without upgrading to babel 7. :) (I'd happy to test in out once it's in beta or whatever, though.)

@novemberborn
Copy link
Member Author

@citycide I'm hopeful that .babelrc.js files work now. Either through the babelrc option or by extending from JS files. Note that AVA does not yet take dependency changes into account if you use require() inside those JS configuration files.

There's a test failure in Node.js 4 in novemberborn/hullabaloo-config-manager#25 which might just be the test itself, not the code, but I don't have the time to figure that out right now.

@novemberborn
Copy link
Member Author

Also this PR now selects the test environment if BABEL_ENV and NODE_ENV are not set, similar to how we set NODE_ENV in the workers.

@haltcase
Copy link

@novemberborn it works 🙌

tested it on:
node v8.9.3, v6.12.2
npm v5.6.0, v3.10.10
babel v7.0.0-beta.34 w/ @babel/preset-stage-0 ( used pipeline and nullish coalescer in test 😋 )

For others who want to test, yarn didn't install the hullabaloo-config-manager dependency correctly. Once I used npm it worked fine.

@novemberborn
Copy link
Member Author

Please see the updated PR description.

I'll publish beta releases of our various dependencies and then merge this into master.

* Adds support for .babelrc.js files
* By default use 'test' environment rather than 'development'
This new option controls whether the @ava/transform-test-files preset is
used at all. Disabling will be one of the things necessary to side-step
Babel altogether.

Removes support for the `--no-power-assert` CLI flag, without a
replacement.

Refs #1556.
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.
Remove 'default' and 'inherits' options, since 'inherits' is now the
default.

In preparation for custom extension support and source compilation, move
options for test compilation into the `testOptions` field.
Set babel=false to disable AVA's default test compilation. *Also* set
compileEnhancements=false to disable the Babel pipeline altogether.

Fixes #1556.
@novemberborn novemberborn changed the title wip! Babel 7 support Babel 7 support and additional enhancements Jan 27, 2018
@novemberborn novemberborn merged commit b33cb1d into master Jan 27, 2018
@novemberborn novemberborn deleted the babel7 branch January 27, 2018 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants