forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbabel.config.js
36 lines (33 loc) · 1020 Bytes
/
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
// @ts-check
/** @type {import('@babel/core').ConfigFunction} */
module.exports = api => {
const isTest = api.env('test')
api.cache.forever()
/**
* Do no use babel-preset-env for mocha tests transpilation in Bazel.
* This is temporary workaround to allow us to use modern language featurs in `drive.page.evaluate` calls.
*/
const disablePresetEnv = Boolean(process.env.DISABLE_PRESET_ENV && JSON.parse(process.env.DISABLE_PRESET_ENV))
return {
presets: [
...(disablePresetEnv
? []
: [
[
'@babel/preset-env',
{
// Node (used for testing) doesn't support modules, so compile to CommonJS for testing.
modules: process.env.BABEL_MODULE ?? (isTest ? 'commonjs' : false),
},
],
]),
['@babel/preset-typescript', { isTSX: true, allExtensions: true }],
[
'@babel/preset-react',
{
runtime: 'automatic',
},
],
],
}
}