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
feat(babel): migrate to babel@7 #790
Conversation
affects: @commercetools/csv-parser-discount-code, @commercetools/csv-parser-orders, @commercetools/csv-parser-price, @commercetools/csv-parser-state, @commercetools/custom-objects-exporter, @commercetools/custom-objects-importer, @commercetools/customer-groups-exporter, @commercetools/discount-code-exporter, @commercetools/discount-code-generator, @commercetools/discount-code-importer, @commercetools/get-credentials, @commercetools/inventories-exporter, @commercetools/personal-data-erasure, @commercetools/price-exporter, @commercetools/product-exporter, @commercetools/product-json-to-csv, @commercetools/state-importer
Codecov Report
@@ Coverage Diff @@
## master #790 +/- ##
=======================================
Coverage 98.75% 98.75%
=======================================
Files 107 107
Lines 2737 2737
Branches 624 624
=======================================
Hits 2703 2703
Misses 30 30
Partials 4 4 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks legit on a first glance! 👌
package.json
Outdated
"@commitlint/cli": "7.1.1", | ||
"@commitlint/config-conventional": "7.1.1", | ||
"babel-cli": "6.26.0", | ||
"babel-core": "6.26.3", | ||
"babel-core": "7.0.0-bridge.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is still needed for babel-jest
below (ref).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup.
@@ -1,7 +1,8 @@ | |||
{ | |||
"lerna": "2.7.1", | |||
"lerna": "2.11.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can not yet update to lerna 3.x because of cz-lerna-changelog
not being updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, why are we still using that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used by commitizen
when running the commit script.
Line 15 in 083e559
"commit": "git-cz", |
I'm not sure its very effective though, looking at the changelog it doesnt seem to be updated...
https://github.com/commercetools/nodejs/blob/master/CHANGELOG.md
Maybe we could get rid of it instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would get rid of it. I think no one is using that command...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, will do. I'll keep commitizen itself tho as it's amazing for on-boarding students and introducing them to angular commit convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ask around in the team. I am not aware of anyone using it anymore. It was good introducing the style but should not be needed anymore. I would recommend removing it in amothrr PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commitizen itself is so drilled into my spine that it is part of my muscle memory now.
However, if you feel that you want to keep this to ease "onboarding", or in some extent ensuring consistency in commit messages, then don't listen to us 👍
@@ -28,7 +28,7 @@ | |||
"lib" | |||
], | |||
"scripts": { | |||
"build": "babel src --out-dir lib" | |||
"build": "babel src --out-dir lib --config-file '../../babel.config.js'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other ideas would be appreciated here. I do prefer this over having a config file inside of every package but it's definitely not ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is fine. To my knowledge the idea of a babel.config over an rc without being breaking is to be more explicit. Meaning you pass it, you import it etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯👍🏼
babel.config.js
Outdated
break | ||
} | ||
return {} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done.
@@ -0,0 +1,3 @@ | |||
const babelConfig = require('./babel.config') | |||
|
|||
module.exports = require('babel-jest').createTransformer(babelConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Have the same on mc-fe and flopflip. This js good and does he job.
@@ -1,7 +1,8 @@ | |||
{ | |||
"lerna": "2.7.1", | |||
"lerna": "2.11.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ask around in the team. I am not aware of anyone using it anymore. It was good introducing the style but should not be needed anymore. I would recommend removing it in amothrr PR.
package.json
Outdated
"@commitlint/cli": "7.1.1", | ||
"@commitlint/config-conventional": "7.1.1", | ||
"babel-cli": "6.26.0", | ||
"babel-core": "6.26.3", | ||
"babel-core": "7.0.0-bridge.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup.
@@ -28,7 +28,7 @@ | |||
"lib" | |||
], | |||
"scripts": { | |||
"build": "babel src --out-dir lib" | |||
"build": "babel src --out-dir lib --config-file '../../babel.config.js'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is fine. To my knowledge the idea of a babel.config over an rc without being breaking is to be more explicit. Meaning you pass it, you import it etc.
@@ -4,7 +4,7 @@ | |||
"description": "Import states to the commercetools platform", | |||
"main": "lib/main.js", | |||
"scripts": { | |||
"build": "babel src --out-dir lib" | |||
"build": "babel src --out-dir lib --config-file '../../babel.config.js'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could maybe also pass it as an env var fro, the host project. BABEL_CONFIG=„blub“ and use it here via interpolation. I may have seen that somewhere. Not sure it serves a bug benefit however as it never moves etc.
}), | ||
babel( | ||
Object.assign( | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you could spread here. Not sure what the nvmrc says in the repo these days 🎃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that this file is not getting transpiled by babel and as we support node from version v6 we should not use any of new syntax here. Also, the spread operator based on ES6 works only with arrays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, it doesn't.
I tried ES7 Object spread first but it failed on Node6 :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @daern91 .. you did really a good job here in this PR.. I added just two nitpicks
babel.config.js
Outdated
default: | ||
break | ||
} | ||
return {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nitpick: this return {}
can be in default
branch instead of break
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, good find, fixed here 4fbe7d3
}), | ||
babel( | ||
Object.assign( | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that this file is not getting transpiled by babel and as we support node from version v6 we should not use any of new syntax here. Also, the spread operator based on ES6 works only with arrays.
602231c
to
8bdbca7
Compare
Summary
PR migrates from babel@6 to @7.
Big thanks for the pointers and inspiration from @tdeekens's PR that did the same here: tdeekens/flopflip#465
Description
One thing to notice here is the solution on how to use the config file. Babel 7 removes support for
.babelrc
inside of monorepos (ref).We will now use
babel.config.js
instead (ref). However, please see the following quote:So, PR also changes the
build script
across all packages. This might not be the ideal solution so I'd love to get any thoughts and input on it. Would be great if we could find another way.resolves #768
resolves #773
resolves #763
resolves #766