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

Use Babel 7 #2813

Merged
merged 7 commits into from Sep 26, 2018
Merged

Use Babel 7 #2813

merged 7 commits into from Sep 26, 2018

Conversation

kibertoad
Copy link
Collaborator

Implements #2793

@@ -0,0 +1,22 @@
'use strict';

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

babel.config.js is the officially recommended way to configure Babel

babel.config.js Outdated
'@babel/preset-env',
Object.assign(
{},
isDev ? { targets: { node: 'current' } } : { targets: { node: '6' } }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we do not officially support Node versions below 6, I've explicitly locked transpilation at that version. This results in much more readable (and debuggable) code being generated.

package.json Outdated
@@ -7,7 +7,7 @@
"node": ">=6"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"@babel/runtime": "^7.0.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this?

"babel-cli": "^6.26.0",
"babel-eslint": "^8.2.6",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-runtime": "^6.23.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed transform-runtime since it seems to be mostly useful when building to very old Node versions and using it causes babel/babel-loader#152

'@babel/preset-env',
Object.assign(
{},
isDev ? { targets: { node: 'current' } } : { targets: { node: 6 } }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we do not officially support Node versions below 6, I've explicitly locked transpilation at that version. This results in much more readable (and debuggable) code being generated.

@@ -89,7 +85,7 @@
"pre_test": "npm run lint",
"tape": "node test/tape/index.js | tap-spec",
"debug_tape": "node --inspect-brk test/tape/index.js",
"test": "npm run pre_test && nyc mocha --exit --check-leaks -t 10000 -R spec test/index.js && npm run tape",
"test": "npm run pre_test && nyc mocha --exit --check-leaks --globals __core-js_shared__ -t 10000 -R spec test/index.js && npm run tape",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore for "core-js_shared" was added since currently there is no way around it, Tedious brings babel-runtime into test execution and that results in an expected leakage (see babel/babel-loader#152). This is not a problem with Knex nor something we should address.

@@ -155,9 +151,9 @@
"tonicExampleFilename": "scripts/runkit-example.js",
"nyc": {
"check-coverage": true,
"lines": 85,
"statements": 83,
"lines": 84,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generate more concise code now, this decreased coverage slightly.

@@ -132,7 +132,7 @@ TableCompiler_SQLite3.prototype.renameColumn = function(from, to) {

TableCompiler_SQLite3.prototype.dropColumn = function() {
const compiler = this;
const columns = Object.values(arguments);
const columns = values(arguments);
Copy link
Collaborator Author

@kibertoad kibertoad Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently Object.values is one thing that Babel has no idea how to transpile (see https://github.com/IBM/carbon-components-react/issues/638), and polyfilling just for this one case feels like an overkill.

@kibertoad
Copy link
Collaborator Author

@elhigu Is this one missing anything?

@elhigu
Copy link
Member

elhigu commented Sep 26, 2018

Very nice +1

@elhigu elhigu merged commit 093f722 into knex:master Sep 26, 2018
@kibertoad kibertoad deleted the feature/babel-7 branch September 26, 2018 20:15
@ricardograca ricardograca mentioned this pull request Sep 28, 2018
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.

None yet

2 participants