Skip to content
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

Node.js version specific Babel presets #148

Closed
sindresorhus opened this issue Nov 7, 2015 · 9 comments
Closed

Node.js version specific Babel presets #148

sindresorhus opened this issue Nov 7, 2015 · 9 comments
Labels

Comments

@sindresorhus
Copy link
Member

So Babel only transpiles features not already supported by the platform.

@jamestalmage said he's interested in looking into this.

@sindresorhus sindresorhus added the enhancement new functionality label Nov 7, 2015
@jamestalmage
Copy link
Contributor

Looks like work has already begun:

https://www.npmjs.com/package/babel-preset-es2015-node5
https://www.npmjs.com/package/babel-preset-es2015-node4
https://www.npmjs.com/package/babel-preset-node5

Still, I think it might be better to automate this.

I am thinking of create a test-file for each of the available plugins that uses the specific feature that plugin provides.

Then a script to require each in a try/catch and see if they throw / fail to compile. That gives us a nice automated update path as future versions are released. I am hoping babel's own test suite will make this all a simple matter of cutting and pasting code samples... There are a lot of plugins.

@sindresorhus
Copy link
Member Author

Wouldn't live feature testing be slow? I had a similar idea of doing the feature testing for every major Node.js version before publishing.

@jamestalmage
Copy link
Contributor

Yes - as part of the update process. Not live testing.

After the test suite runs we output a file for that specific version in a subfolder:

// index.js
module.exports = require('./plugin-lists/' + process.version);  // probably not necessary to the patch level, but you get the idea

or something like that.

@sindresorhus
Copy link
Member Author

👍 That's exactly what I was thinking.

@jamestalmage
Copy link
Contributor

It might be cool to fetch the actual plugins from npm on demand as well (so npm install goes faster in newer versions of node). We could give back a few CPU cycles to travis-ci.org that way.

Definitely not something to target for the first release, but might be interesting to play with down the road.

@hzoo
Copy link

hzoo commented Apr 22, 2016

Haven't implemented it yet but I would like to see at least a preset where you can specify that environment you want to target and it would have a predetermined list of transforms based on what it supports. You could just use the data or use env to do different things. babel/babel#3476

@novemberborn
Copy link
Member

@sindresorhus
Copy link
Member Author

sindresorhus commented Sep 27, 2016

@novemberborn I'm a little bit sceptical of feature testing. New features might be buggy or slow. I would be more comfortable with a preset that choose plugins based on vetted testing on various Node.js versions. Maybe babel-preset-env when it gets more mature.

@novemberborn
Copy link
Member

Is fixed by #1193.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants