-
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
Stop reading .babelrc
files.
#398
Conversation
I still need to write a test for this. I can get to it later today. |
@jamestalmage It's already tested in Babel I assume, but sure, if you want. |
FWIW, using this branch fixed the issue I was having. Thanks again @jamestalmage. |
c202a74
to
bd059fb
Compare
Yeah, but I could have sworn I already addressed this once before, adding a regression test ensures we don't accidentally drop it. Test added. |
Wait, @jamestalmage, @sindresorhus: Why wouldn't we want this? (Sorry if I missed some earlier conversation). |
Because it prevents them from using a |
@jamestalmage: Ok, but as a user of AVA, having AVA transpile my tests with babel, yet not follow my |
@jamestalmage Looks good to me. Just merge when you've fixed the merge conflict ;) |
@jamestalmage, @sindresorhus: I would like to say that I really think that if we're going to block .babelrc (I don't think we should). Then we should prioritize allowing additional babel config, because being forced to use diffrent babel settings for tests and production code is really bad. |
We are already doing that. Without this change, our babel settings from If users really want
I don't think that's true at all, in fact I think the opposite. If your production code requires Babel, then you need to include a build step as part of |
@jamestalmage: That's not what I meant. Here's my situation: I use the babel-require hook, with |
Why not?
I don't like that idea. I am certainly open to the idea of allowing users to customize the test transpiler as they see fit. (If you hunt back into the early 100's you'll find half a dozen PR's where I explore the idea). Doing it automatically isn't a good idea, users should have to be explicit about it. |
bd059fb
to
5f5be31
Compare
Stop reading `.babelrc` files.
@jamestalmage: your can't use bluebird because it overrides 'Promise' anywhere it finds it, regardless of scope. Why would it ever be a bad thing for babel to read babel configuration? What I've personally done for a project that i started yesterday was to transpile it with babel ahead of time. So while I think that es2015 support is a cool idea, I think that has having a '--no-babel' flag for more complex projects. might be a good idea. (And, you know, being able to babel config would be great too). Thoughts? |
Well that's annoying. As for the rest of it:
|
It's also not true: // foo.js
import Promise from 'bluebird'
import test from '../../'
Promise.longStackTraces();
test(async t => {
await Promise.resolve('foo');
}); // transpiled foo.js
'use strict';
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _bluebird = require('bluebird');
var _bluebird2 = _interopRequireDefault(_bluebird);
var _ = require('../../');
var _2 = _interopRequireDefault(_);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_bluebird2.default.longStackTraces();
(0, _2.default)((function () {
var _this = this;
var ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(t) {
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return _bluebird2.default.resolve('foo');
case 2:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
}));
return function (_x) {
return ref.apply(this, arguments);
};
})()); |
@jamestalmage: Weird... It didn't work for me, and according to the maintainers, it shouldn't. I still disagree that AVA shouldn't read the config automatically, but it's not that big of a deal if we document it. @sindresorhus: Thoughts on a |
For what purpose exactly? |
@sindresorhus: Until we can modify babel config, I pre-compile my code with babel. Running the transpiled code through babel again doesn't make any sense (This can come with a warning like |
Or not. We already handle assertions that are not enhanced by the plugin (throws, doesNotThrow). Personally, I would rather just wait until we figure out configurable transforms instead of adding a feature we intend to replace. @ariporad - Would the ability to include |
@jamestalmage: Not really. I also use |
@jamestalmage I agree with @ariporad -- it's unintuitive that if my lib code is using Personally, I think the More generally, AVA works well for the (increasingly less common) case of packages written in ES5 with no transpilation step (since you get to write your tests using modern syntax "for free"). However, I'd argue that it drops the ball for the (increasingly more common) case where library code is transpiled anyway: now, despite you having set up tooling to use the syntax you want in lib code, you have to write your tests in a predetermined (and typically strictly smaller) subset of new syntax. |
I've never said we won't allow configuration of how your tests get transpiled, that's a feature I think is worthwhile. Just that it's not going to automatically happen because you have a I'm not sure what's "most common"/"typical", though I am sure ES2015 use is on the rise. I do find it hard to believe that However we solve configurable transpiling, I want it to be able to participate in the caching-main thread-precompiler stuff we just added that has given us a huge performance boosts. |
@jamestalmage: Think about it like this: AVA says that it invokes babel for you. If you've explicitly said that you want babel to do X, it would be confusing when AVA's babel doesn't. Since this seems to be a matter of opinion, why don't we just do a poll? |
@ariporad @billyjanitsch I disagree that it would be confusing, because of the docs outlining AVA's approach to ES2015 that say:
Of course I'm a bit biased towards this because this PR solved the issue I was having with conflicting A healthy compromise IMHO would be an |
@sindresorhus: what are your thoughts on having AVA's babel automatically ignore the explicit babel configuration that users have set. (In my mind, this seems absolutely crazy and the wrong thing to do). And since this seems to be a debated topic, would everyone be open to a poll of AVA users on what they'd prefer? |
This is a really weird breaking change. I am using AVA to test some react (jsx yeah) and now I just cannot (=> I cannot upgrade to 0.10 and I am stuck with 0.9 until there is a solution). Are you aware that babel have an option to specify config depending on the NODE_ENV variable? AVA should use babelrc by default, otherwise UX is like superweird. |
@MoOx - as stated elsewhere. The problem is that without this, the configs end up getting merged with the one AVA automatically creates(which is not always what you want). Specifically, I would generally prefer only to ship production code with fully ratified language constructs (i.e. only the We are working on a
I wasn't until just a few hours ago, and my thought was similar to yours. My question now is: Is there a way to specify an environment on a per-file basis via the API? |
Is there something uncommon that AVA need?
No idea. But maybe process.env.BABEL_ENV/NODE_ENV can be adjusted during the runtime (because babel read from that)? |
AVA automatically includes |
Let's continue further discussion in #448. |
If a
.babelrc
file is present, it is being read, and the settings merged with the ones we specify for tests. We don't want that.Reference:
http://babeljs.io/docs/usage/options/