forked from gcanti/tcomb-json-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel.config.js
51 lines (45 loc) · 1.56 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
module.exports = function(api) {
const isTest = api.env("test")
// Cache based on environment
api.cache.using(() => process.env.NODE_ENV)
const targets = isTest ? { node: "current" } : "last 2 versions, ie 11"
const presets = [
// Import core-js and regenerator-runtime in index.jsx to
// auto-include required polyfills
[
"@babel/preset-env",
{
corejs: 3,
modules: false,
targets: targets,
useBuiltIns: "entry"
}
],
// Support for TypeScript syntax
"@babel/preset-typescript",
// Support for React JSX
"@babel/preset-react"
]
const plugins = [
// Stops us from bundling unused parts of lodash
"lodash",
// `async function*() { await 1; yield 2; }`
"@babel/plugin-proposal-async-generator-functions",
// `const { foo, ...rest } = { foo: 1, bar: 2, baz: 3 }`
"@babel/plugin-proposal-object-rest-spread",
// These are used to support "experimental" TypeScript syntax
["@babel/plugin-proposal-decorators", { legacy: true }],
["@babel/plugin-proposal-class-properties", { loose: true }]
]
if (isTest) {
// Transpile modules to commonjs format
plugins.push("@babel/plugin-transform-modules-commonjs")
// Support dynamic import statements
plugins.push("@babel/plugin-syntax-dynamic-import")
plugins.push("dynamic-import-node")
}
return {
presets,
plugins
}
}