Skip to content

Babel feature detection #366

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

Closed
wants to merge 2 commits into from

Conversation

ariporad
Copy link
Contributor

This fixes #348. It uses babel-preset-features to auto-detect ES6 features. Also includes tests.

Enjoy!

@ariporad
Copy link
Contributor Author

Grr... A dependency has a require with an uppercase letter, which is killing travis. I submitted a PR, but the author is on the other side of the world. Give it a few hours, then it should be ready.

@sindresorhus
Copy link
Member

I like the idea, but I'm a bit wary of it. What if the native implementation has bugs and we want to use Babel for that? What is the runtime overhead of doing a bunch of feature detections? And https://github.com/hax/babel-features doesn't look very actively maintained nor used much https://www.npmjs.com/package/babel-features.

I just don't want this to cause us a lot of extra overhead with support issues, etc.

// @hax

@ariporad
Copy link
Contributor Author

@sindresorhus: Check the 2.x (currently in beta) branch, it was last worked on 5 days ago 😉. It even already supports Babel 6.

I think there's a little overhead, but not a whole lot. I'm not sure how we'd go about it any other way, regardless. And I guess we'd just assume that V8 isn't going to ship something horrifically broken. The overhead is going to down once we move babel to the main thread.

@sindresorhus
Copy link
Member

I think there's a little overhead, but not a whole lot. I'm not sure how we'd go about it any other way,

We could create a preset for each Node.js major version →#148. Albeit that won't work when we eventually add browser support → #24.

And I guess we'd just assume that V8 isn't going to ship something horrifically broken.

They do all the time. That's the price for rapid evolution.

The overhead is going to down once we move babel to the main thread.

That's a good point.

@hax
Copy link

hax commented Dec 28, 2015

Sorry I have cold last week and not check the github notifications.

What is the runtime overhead of doing a bunch of feature detections?

The runtime overhead of feature detection < 10ms, so I think it's ok for most applications.

What if the native implementation has bugs and we want to use Babel for that?

Yes they have. But Babel also have 😀 . So we need to check it case by case. For example, whether to use regenerator. (node 0.12+ have generators, but missing some minor features such as Generator.prototype.return. babel-preset-es2015-node-5 decide to not use regenerator. If there is any other case like that please let me know.)

@sindresorhus
Copy link
Member

There's also the case of many of the ES2015 features being a lot slower than the transpiled ones.

@hax
Copy link

hax commented Dec 28, 2015

@sindresorhus
This is due to V8 (and other implementations) seem focus on es2015 features not performance up to now. Even simple const/let could cause deoptimization.

But I never see a real case such performance degradation is significant for a webapp (browser-side) in my daily work. Maybe heavy-load Node.js apps would affected by it. Anyway they can just switch from babel-preset-es2015-node-* to normal babel-preset-es2015.

@jamestalmage
Copy link
Contributor

My vote is to punt on this until a later date. AVA and Babel both are currently moving at breakneck speed. I would prefer not to introduce an extra layer of complexity.

@novemberborn
Copy link
Member

Closing due to inactivity. #148 is the issue for this feature. Would love your help if you have the time @ariporad!

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.

Don't use regenerator in babel-preset-es2015 for newer Node.js versions
5 participants