Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Getting ready for Babel 7 #1598

Closed
novemberborn opened this issue Nov 27, 2017 · 10 comments
Closed

Getting ready for Babel 7 #1598

novemberborn opened this issue Nov 27, 2017 · 10 comments
Assignees
Labels
Milestone

Comments

@novemberborn
Copy link
Member

Babel 7 will be released soon (#1575). Here's what we're going to do:

Any changes that are required in the dependencies will be released to npm when they're ready. The remaining changes in AVA itself will be held back until Babel 7 is officially released. We'll do a new AVA release once the dust settles. Those of you working with Babel's beta versions will be able to install from GitHub.

It's possible that AVA won't fully support all the new configuration options, but that won't stop us from releasing Babel 7 support. We'll just have to document what's still missing.

There's a lot of pieces to coordinate here, so for now I've assigned myself to this effort. If you've got some time in the next few weeks and are looking to help out, please chime in here and I'll see where we are. There's lots of other issues labeled "help wanted" too 😉

Thanks!

@novemberborn
Copy link
Member Author

Any changes that are required in the dependencies will be released to npm when they're ready.

Looking at avajs/babel-preset-stage-4#11 this is tricky though, since all the v7 plugins are still released as betas. We'll probably have to install our dependencies from GitHub until Babel 7 is released officially.

@razor-x
Copy link
Contributor

razor-x commented Dec 4, 2017

With the tight babel integration and no support for using a peer version of Babel, is Ava concerned about users who cannot upgrade yet to Babel 6 becoming locked out of support for the next version of Ava? This issue is exacerbated by not using semver as this change would normally force a major version bump leaving the previous version open for PRs to backport security fixes and bug fixes.

@novemberborn
Copy link
Member Author

@razor-x bug fixes could still be backported (they count as patch releases anyhow), but as a general rule the AVA team does not have the resources to maintain earlier versions.

I think this would impact users who customize the Babel configuration that AVA applies to their test files. As far as the official Babel plugins are concerned the Babel 7 versions will be published under new package names, so the test configuration could use new versions whereas sources can still be compiled using Babel 6. Another workaround would be to precompile test files using Babel 6.

I did consider supporting both versions, but as I'm doing the work on the dependencies that seems increasingly complicated.

@razor-x
Copy link
Contributor

razor-x commented Dec 5, 2017

That's all reasonable. Mostly want to bring up this issue for an official response so affected users understand what Ava development will support and can plan accordingly.

I'd say it's dangerous to assume code that passes tests run through Babel 7 but compiled with Babel 6 will run identically in production. Ideally that's not the case, but one cannot guarantee perfect parity between two major versions.

@novemberborn
Copy link
Member Author

I'd say it's dangerous to assume code that passes tests run through Babel 7 but compiled with Babel 6 will run identically in production.

AVA doesn't compile source code though, it only compiles test files, and by default only to deliver stage-4 syntax to older Node.js versions (plus some other enhancements under our control). I don't expect any breakage there once we finish the upgrade.

@razor-x
Copy link
Contributor

razor-x commented Dec 7, 2017

Are you saying Ava does not run relative importin spec files though the bundled Babel version but through the one specified by your package.json?

@novemberborn
Copy link
Member Author

Other than helper files, AVA does not compile source files (the stuff you're testing). You have to use babel-register for that (or precompile), so this change will not affect source files.

@novemberborn
Copy link
Member Author

@vjpr, @citycide, @cwonrails Please give #1608 a whirl if you have a moment. Note that .babelrc.js files are not yet supported.

@haltcase
Copy link

haltcase commented Dec 9, 2017

@novemberborn was about to try it out but it looks like babel-preset-transform-test-files#babel7 needs its deps updated because babel-plugin-espower#babel7 was merged to master and removed (power-assert-js/babel-plugin-espower@71e1a50)

Until then npm will fail with a very unhelpful message:

npm ERR! code 1
npm ERR! Command failed: /usr/bin/git checkout babel7
npm ERR! error: pathspec 'babel7' did not match any file(s) known to git.

while yarn is a bit more useful since it actually gave me some kind of idea where the problem was:

yarn install v1.3.2
info No lockfile found.
[1/5] Validating package.json...
[2/5] Resolving packages...
error Couldn't find match for "babel7" in "_c" for "https://github.com/power-assert-js/babel-plugin-espower.git".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

@novemberborn
Copy link
Member Author

@citycide thanks for the heads up. I've updated the dependencies, please give it another go!

@novemberborn novemberborn added this to the 1.0 milestone Jan 15, 2018
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.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants