forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
54 lines (51 loc) · 1.95 KB
/
babel.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// @ts-check
const logger = require('gulplog')
const semver = require('semver')
/** @type {import('@babel/core').ConfigFunction} */
module.exports = api => {
const isTest = api.env('test')
api.cache.forever()
/**
* Whether to instrument files with istanbul for code coverage.
* This is needed for e2e test coverage.
*/
const instrument = Boolean(process.env.COVERAGE_INSTRUMENT && JSON.parse(process.env.COVERAGE_INSTRUMENT))
if (instrument) {
logger.info('Instrumenting code for coverage tracking')
}
return {
presets: [
// Can't put this in plugins because it needs to run as the last plugin.
...(instrument ? [{ plugins: [['babel-plugin-istanbul', { exclude: ['node_modules/**'] }]] }] : []),
[
'@babel/preset-env',
{
// Node (used for testing) doesn't support modules, so compile to CommonJS for testing.
modules: isTest ? 'commonjs' : false,
bugfixes: true,
useBuiltIns: 'entry',
include: [
// Polyfill URL because Chrome and Firefox are not spec-compliant
// Hostnames of URIs with custom schemes (e.g. git) are not parsed out
'web.url',
// URLSearchParams.prototype.keys() is not iterable in Firefox
'web.url-search-params',
// Commonly needed by extensions (used by vscode-jsonrpc)
'web.immediate',
// Avoids issues with RxJS interop
'esnext.symbol.observable',
],
// See https://github.com/zloirock/core-js#babelpreset-env
corejs: semver.minVersion(require('./package.json').dependencies['core-js']),
},
],
'@babel/preset-typescript',
'@babel/preset-react',
],
plugins: [
'babel-plugin-lodash',
// Node 12 (released 2019 Apr 23) supports these natively, but there seem to be issues when used with TypeScript.
['@babel/plugin-proposal-class-properties', { loose: true }],
],
}
}