Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

Use external Electron to Chromium library #144

Merged
merged 7 commits into from
Jan 19, 2017

Conversation

Kilian
Copy link
Contributor

@Kilian Kilian commented Jan 16, 2017

Per the suggestion in ticket #142 this pull request switches out the local list of electron-to-chromium mappings for a more complete external library.

I had to update a number of tests, because Electron 1.5 is not out yet and it's not guaranteed it will use the assumed chrome version. Additionally, the old data file linked electron 1.0 to chrome 50 but that should have been 49, which I updated in the tests as well.

I updated the external library to allow both string and numerical input, but it always returns a string (because it can return full chromium versions too, which require it) so I parseInt() that in the script. I hope that's ok.

Copy link
Member

@yavorsky yavorsky left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks!

Just a few points.

Also, electron version logs as "chrome": 52.
I think should be better to log it as "electron": 1.3 and left all the magic with chrome behind the scenes 🎩

@@ -2,7 +2,7 @@
"presets": [
["../../../../lib", {
"targets": {
"electron": 1.5
"electron": "1.4"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe avoid strings unless we will maintain it for all targets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do. I did this before updating my library to also handle numbers, so it can be reverted.

@@ -141,7 +121,10 @@ export const getTargets = (targets = {}) => {

// Rewrite Electron versions to their Chrome equivalents
if (targetOps.electron) {
targetOps.chrome = electronVersionToChromeVersion(targetOps.electron);
targetOps.chrome = parseInt(electronToChromium(targetOps.electron), 10);
Copy link
Member

Choose a reason for hiding this comment

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

If we have for ex:

"targets": {
  "chrome": 50,
  "electron": 1.3 // 52
}

looks like it will just rewrite chrome version with higher. So the result will be chrome: 52, but not 50.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do a Math.min()

Copy link
Member

Choose a reason for hiding this comment

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

@Kilian 👍

@Kilian
Copy link
Contributor Author

Kilian commented Jan 17, 2017

I didn't want to change the way the behaviour worked with regards to how it handles the electron -> chrome conversion so that works the same as it currently does: set the targetOps.chrome and delete targetOps.electron. Logging it as electron and keeping the chrome conversion on a lower level is better suited for a different PR, I think.

@Kilian
Copy link
Contributor Author

Kilian commented Jan 17, 2017

Just pushed the requested changes!

throw new Error(`Electron version ${targetOps.electron} is either too old or too new`);
}

if (targetOps.chrome) {
Copy link
Member

Choose a reason for hiding this comment

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

This might be a good test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right! will add it tonight.

@Kilian
Copy link
Contributor Author

Kilian commented Jan 18, 2017

@yavorsky I think all the requested changes are put in!
@existentialism two test cases!

...And now it can not be merged back to master :( I'll see how much trouble it is to rebase.

@Kilian
Copy link
Contributor Author

Kilian commented Jan 18, 2017

Rebased on latest master and all green, should be good to go now.

Copy link
Member

@yavorsky yavorsky left a comment

Choose a reason for hiding this comment

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

👍

@@ -124,7 +103,18 @@ export const getTargets = (targets = {}) => {

// Rewrite Electron versions to their Chrome equivalents
if (targetOps.electron) {
targetOps.chrome = electronVersionToChromeVersion(targetOps.electron);
const electronChromeVersion = parseInt(electronToChromium(targetOps.electron), 10);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think parseInt(a, 10); is necessary anymore in ES5? Can remove later

@hzoo hzoo merged commit 55aa7ff into babel:master Jan 19, 2017
@hzoo
Copy link
Member

hzoo commented Jan 19, 2017

Thanks for the library + PR!

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

Successfully merging this pull request may close these issues.

4 participants