avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.74k stars 1.41k forks source link

Document usage of `babel.config.js` files #1816

Closed novemberborn closed 5 years ago

novemberborn commented 6 years ago

As of #1798 we support Babel 7 beta 48. This supports a new babel.config.js file.

We need to update our Babel recipe with examples of babel.config.js files. I think we may even be able to remove .babelrc examples, as I'm under the impression that this is the desired new config format for Babel 7.

~We need to update our Babel integration tests (in test/api.js) so we're also testing babel.config.js files. We should change our default behavior so that both babelrc and config files are considered when compiling test & helper files. See:~

https://github.com/avajs/ava/blob/a5de3691e76a2a999ac3392830d1e26d279d60ab/lib/babel-pipeline.js#L28

https://github.com/avajs/ava/blob/a5de3691e76a2a999ac3392830d1e26d279d60ab/lib/babel-pipeline.js#L125

gajus commented 6 years ago

It appears that Ava stopped working with Babel 49 update.

The test files are no longer compiled using .babelrc.

Is this related?

novemberborn commented 6 years ago

@gajus depending on your beta version AVA should have its own instance of @babel/core, so I wouldn't expect it to stop working. Perhaps you could try with master?

gajus commented 6 years ago

Master works. 1.0.0-beta.4 does not.

When is the current master getting released?

novemberborn commented 6 years ago

Master works. 1.0.0-beta.4 does not.

That's weird. Beta 4 has pinned its Babel dependencies so it shouldn't end up using Beta 49. Perhaps your installer is deduping in unexpected ways.

When is the current master getting released?

I'm trying to land two features that were blocked on this Babel compatibility issue.

gajus commented 6 years ago

That's weird. Beta 4 has pinned its Babel dependencies so it shouldn't end up using Beta 49. Perhaps your installer is deduping in unexpected ways.

I am using npm@5.6.0.

It is not an issue with the installed version of @babel/core either.

$ cat ./node_modules/ava/node_modules/@babel/core/package.json | jq .version
"7.0.0-beta.44"
novemberborn commented 6 years ago

@gajus not sure what's going on then. Hopefully the next beta fixes it correctly.

gajus commented 6 years ago

@gajus not sure what's going on then. Hopefully the next beta fixes it correctly.

This is currently breaking all of our builds.

Not one package, but all of the builds.

Whatever change happened between Babel ^7.0.0-beta.47 and ^7.0.0-beta.49 is breaking latest Ava release behaviour.

novemberborn commented 6 years ago

Ah, perhaps you have some plugins / presets that are making its way into AVA's Babel pipeline? I suggest downgrading to Babel 7 beta 44 (or 47) for the time being. Make sure to install exact dependencies, the ^ includes all beta releases.

danny-andrews commented 6 years ago

Just for clarification, does ava currently support babel.config.js? i.e., is this simply a documentation/test issue?

kevva commented 6 years ago

@danny-andrews, yes, if you add something like this to your ava config:

"babel": {
    "testOptions": {
        "configFile": "./babel.config.js"
    }
}
novemberborn commented 6 years ago

We need to auto-detect it though, like we do .babelrc files. That's not implemented yet. We also need tests for that implementation, including what happens when both files are present.

Then, I'd like to update our documentation to use babel.config.js rather than .babelrc.

kevva commented 6 years ago

@novemberborn, wouldn't just providing configFile: true in defaultOptions work? Then it'd fallback to Babels own behaviour. And yeah, needs some tests too.

novemberborn commented 6 years ago

@kevva yup, I just didn't want to do that without having tests and an understanding of how it all behaves.

novemberborn commented 6 years ago

master now supports babel.config.js files, but we still need to update the documentation.