-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Disable Babel #130
Comments
It might work if you depend on the tagged git version of Babel 5 locally as AVA will use that one instead of the builtin one. I use that trick in XO to be able to lint itself: https://github.com/sindresorhus/xo/blob/dd233cc40a1984a793000f260062c520767a685b/package.json#L78 If that doesn't work, I guess we could add a flag, but I was hoping we didn't have to, as there's no other reason I can think of to disable Babel. |
Hello @sindresorhus, I have a case you may wish to consider. I am looking to use AVA to test a node Is this a case you would be willing to support? |
By default, AVA will only instrument your tests, not production code. There is no good reason not to take advantage of Babel instrumentation in your tests. |
Node.js 4.2.0 is missing a lot of ES2015 features. Also nice being able to use ES2016 features like async functions. Disabling Babel will not only disable Babel, but also the enhanced asserts. I plan on looking into creating Node.js version specific presets, so it only transpiles what's not supported natively. This became a lot easier to achieve with Babel 6. |
That was on my radar as well. Lets not duplicate effort. |
@jamestalmage Yeah, only an idea yet. Feel free to take it on. Let's continue this in #148. |
That seems to be true, but Babel polyfills are also available in production code, making AVA almost unusable for testing polyfills: // sut.js
module.exports = function () {
return !!Object.getOwnPropertySymbols;
}; // test.js
import test from 'ava';
import sut from './sut'
test(t => {
t.true(sut());
t.end();
});
Or is this a bug? |
Ah - that is a good point. Not sure if @1d5ef4c5f6fcb70f9e90e584dfd08865db1e93b4 (landed in master, but not published) will address that. |
@jamestalmage yep, thats what that fix was for, it still need some work thou (#150). |
Instead of "Disable Babel", How about an option to disable the lookup of the local version, and force |
#390 takes care of this. Closing. |
So what's the correct way to completely disable Babel compilation (for when I know my test scripts only use syntax that is 100% supported by my target Node version)?
|
@callumlocke try with |
We should probably alias |
Trying import _Promise from 'project/node_modules/ava/node_modules/babel-runtime/core-js/promise.js';
^^^^^^
SyntaxError: Unexpected reserved word This is on Let me know if you would like the full log. |
Try adding just this plugin: http://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/ |
@jamestalmage That fixed it. However the suggestion requires adding a new devDependency on a project that otherwise has no need for babel. It would be nice if we could use that plugin directly from ava's own dependency on Not a call to action, just sharing thoughts. |
I'm just curious, what motivates the "no babel" decision. Missing out on To answer your question, it is unlikely we are going to alter the lookup paths for the presets again (we used to, and it was problematic). |
For me, at the time I originally posted in this thread, the "no babel" idea was purely in the interest of reducing the time it takes to test. |
You could use CJS'
AVA will still apply a Babel transform, I doubt disabling the default presets will dramatically speed up your tests. |
For me, it's because I put all my app code and tests through a single compilation step before I run my tests. So I don't miss out on async/await, or anything else from ESNext. I just put everything (both Personally I don't want my test runner / assertion library (AVA) to concern itself with on-the-fly compilation; it's too many things in one tool. I don't think Babel is really stable enough to use transparently like that. Babel is a great tool, but imo it's better done as a distinct build step, not magically at runtime/testtime. This way, all your compiled code exists as real files on disk (not just fleeting ideas in RAM) that can run directly in your target runtime, and which you can debug directly without relying on sourcemaps (also flakey). I've had way fewer problems since switching to this approach. |
My five cents here: the traces are pretty bad when using babel in some cases. |
@paulmillr could you elaborate? |
@callumlocke We're not just using Babel for the syntax. Babel enables |
Is there a way to disable Babel transforming test files? I'm trying to use ava for Babel core and I'm running into issues getting it to work because Babel links up all it's dependencies and ava is resolving
babel-core
to my 6.0master
development version. Happy to submit a PR if necessary!The text was updated successfully, but these errors were encountered: