forked from babel/babel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.babelrc.js
63 lines (55 loc) · 1.54 KB
/
.babelrc.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
55
56
57
58
59
60
61
62
63
"use strict";
// Blame Logan for this.
// This works around https://github.com/istanbuljs/istanbuljs/issues/92 until
// we have a version of Istanbul that actually works with 7.x.
function istanbulHacks() {
return {
inherits: require("babel-plugin-istanbul").default,
visitor: {
Program: {
exit: function(path) {
if (!this.__dv__) return
const node = path.node.body[0];
if (
node.type !== "VariableDeclaration" ||
node.declarations[0].id.type !== "Identifier" ||
!node.declarations[0].id.name.match(/cov_/) ||
node._blockHoist !== 3
) {
throw new Error("Something has gone wrong in Logan's hacks.");
}
// Gross hacks to put the code coverage block above all compiled
// import statement output.
node._blockHoist = 5;
},
},
},
};
}
let envOpts = {
loose: true,
};
const config = {
comments: false,
presets: [
["@babel/env", envOpts],
"@babel/flow"
],
plugins: [
["@babel/proposal-class-properties", { loose: true }],
"@babel/proposal-export-namespace-from",
"@babel/proposal-numeric-separator",
["@babel/proposal-object-rest-spread", { useBuiltIns: true }],
]
};
if (process.env.BABEL_ENV === "cov") {
config.auxiliaryCommentBefore = "istanbul ignore next";
config.plugins.push(istanbulHacks);
}
if (process.env.BABEL_ENV === "development") {
envOpts.targets = {
node: "current"
};
envOpts.debug = true;
}
module.exports = config;