-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel.config.js
100 lines (88 loc) · 2.58 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Babel config.
*
* @license Apache-2.0
* @copyright Mat. 2018-present
*/
"use strict";
// ...
const
conf = {
plugins: [
"@babel/plugin-transform-export-namespace-from",
],
};
// configuration
module.exports = function (api) {
api.cache.using(() => process.env.BABEL_ENV);
// eslint-disable-next-line
console.log(`Compiling for '${api.env()}' ...`)
return {
env: {
// linting and jsdoc generation
development: {
plugins: [
...conf.plugins,
],
presets: [
"@babel/preset-env",
"@babel/preset-typescript",
],
},
// node-compatible modules generation
commonjs: {
plugins: [
...conf.plugins,
],
comments: false,
shouldPrintComment: () => false,
presets: [
[
"@babel/preset-env",
{
exclude: [
"transform-async-to-generator",
"transform-regenerator",
],
modules: "commonjs",
targets: {
node: "16.0.0",
},
useBuiltIns: false,
},
],
[
"@babel/preset-typescript",
],
],
},
// es-modules generation
es: {
plugins: [
...conf.plugins,
],
comments: false,
shouldPrintComment: () => false,
presets: [
[
"@babel/preset-env",
{
exclude: [
"transform-async-to-generator",
"transform-regenerator",
],
modules: false,
targets: {
esmodules: true,
},
useBuiltIns: false,
},
],
[
"@babel/preset-typescript",
],
],
},
},
};
};