Skip to content

Commit

Permalink
Update config to support specific browser versions
Browse files Browse the repository at this point in the history
The Babel config had previously supported all browsers with greater than
0.25% global usage (according to `browserlist`). This resulted in
`babel-preset-env` including plugins sufficient to support the following
minimum browser versions:

```
{
  "chrome": "49",
  "android": "4.4",
  "edge": "16",
  "firefox": "52",
  "ios": "9.3",
  "safari": "11"
}
```

Instead, the babel config now explicitly supports chrome >= 58 and
firefox >= 53. Chrome and Firefox are the only browsers we currently
publish to, and these were the minimum versions with no additional Babel
transformations.

The minimum browser versions we support should be re-evaluated later,
after we have added tests and documentation.

The `stage-0` Babel preset has also been replaced with the specific
Babel plugins that we depend upon. We don't use most of `stage-0`, so
this allowed us to remove many unnecessary transformations. We had to
remove this preset soon anyway, because all of the stage presets are
deprecated in Babel 7.

The `stage-0` preset consisted of these plugins:
```
"transform-do-expressions"
"transform-function-bind"
"transform-class-constructor-call"
"transform-export-extensions"
"transform-class-properties"
"transform-decorators"
"syntax-dynamic-import"
"syntax-trailing-function-commas"
"transform-async-generator-functions"
"transform-async-to-generator"
"transform-exponentiation-operator"
"transform-object-rest-spread"
```

Of that list, only 'transform-class-properties' and 'transform-object-
rest-spread' were required. 'transform-async-to-generator' was being
used (as we are using async/await), but our browser targets all support
async/await, so that could be removed. The remainder of the plugins were
completely unused.

Removing some of these transformations exposed bugs in `uglify-es` that
only presented themselves in the production build. `gulp-uglify-es` has
been updated to a version that uses `terser` instead of `uglify-es`,
which has resolved these issues.

Relates to MetaMask#6805
  • Loading branch information
Gudahtt committed Jul 4, 2019
1 parent ca62b14 commit ca36a5a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 256 deletions.
14 changes: 6 additions & 8 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
{
"targets": {
"browsers": [
">0.25%",
"not ie 11",
"not op_mini all"
"chrome >= 58",
"firefox >= 53"
]
}
}
],
"react",
"stage-0"
"react"
],
"plugins": [
"transform-runtime",
"transform-async-to-generator",
"transform-class-properties"
"transform-class-properties",
"transform-object-rest-spread"
]
}
}
Loading

0 comments on commit ca36a5a

Please sign in to comment.