-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel.config.cjs
60 lines (56 loc) · 2.04 KB
/
babel.config.cjs
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
const targets = {
node: "12.20.0" // See also engines.node in package.json
// With @atao/fse-cli, indeed no '.browserslistrc'
};
const plugins = [
"@babel/transform-typescript",
// must be set before @babel/proposal-decorators
"babel-plugin-transform-typescript-metadata",
[ // must be set before @babel/proposal-class-properties
"@babel/proposal-decorators",
{
legacy: true // 'legacy === true' forces using Typescript decorator specs, not EcmaScript ones
}
],
[
"@babel/proposal-class-properties",
{
loose: true // 'loose === true' is required by proposal-decorators' legacy
}
],
[ // must be the same value of 'loose' than with @babel/plugin-proposal-class-properties
"@babel/plugin-proposal-private-methods",
{
loose: true
}
],
"@babel/plugin-transform-runtime", // provided defs such as _interopRequireDefault
"babel-plugin-node-source-map-support"
];
const presets = [
"@babel/typescript",
[
"@babel/env",
{
// "debug": true,
// 'usage': includes polyfills given `.browserslistrc` and your source code (Babel analyses it - might
// not always perfectly work depending on your app and its dependencies) instead of including
//everything from core-js
useBuiltIns: "usage",
corejs: {
version: 3,
proposals: true // will enable polyfilling of every proposal supported by core-js
},
// Now Babel defaults 'modules' to 'auto', not any more to 'commonjs' (which won’t tree-shake.)
// So no more need to setup 'modules' to 'false':
modules: false,
targets
}
]
];
module.exports = (api) => {
// Cache configuration is a required option
// With 'true', same as api.cache.forever(), ie permacache the computed config and never call the function again
api.cache(true);
return { presets, plugins };
};