-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
76 lines (74 loc) · 2.29 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
const { NODE_ENV } = process.env;
const isTest = NODE_ENV === 'test';
const stripSymbolObservableMethodPlugin = ({ types: t }) => {
const isSymbolObservable = t.buildMatchMemberExpression('Symbol.observable');
return {
visitor: {
Class(path) {
path
.get('body.body')
.filter(
(p) => p.isClassMethod() && isSymbolObservable(p.get('key').node)
)
.forEach((p) => p.remove());
}
}
};
};
module.exports = {
assumptions: {
constantReexports: true, // only matters for tests (since only there we transpile to CJS using Babel), it makes debugging easier
setClassMethods: true,
setComputedProperties: true,
setPublicClassFields: true,
setSpreadProperties: true
},
presets: [
[
'@babel/preset-env',
{
targets: {
// Even though our packages are not node-only, we can use this as an approximation of the "target syntax level"
// as Babel doesn't support targets like "ES2022". We currently target the latest LTS version of node here.
// When targeting browsers, the code is usually going through some kind of bundler anyway
// and thus it's the user's responsibility to downlevel the code to what they need.
node: 18
},
exclude: [
'@babel/plugin-proposal-optional-chaining' // despite being supported by node 16 optional chaining was still transpiled by some reason
]
}
],
['@babel/preset-react', { runtime: 'automatic' }],
[
'@babel/preset-typescript',
{ isTSX: true, allExtensions: true, disallowAmbiguousJSXLike: true }
]
],
overrides: [
{
test: /\.svelte$/,
presets: [
[
'@babel/preset-typescript',
{
isTSX: true,
allExtensions: true,
disallowAmbiguousJSXLike: true,
// this is the only overridden option
// potentially we could just configure it for all the files but surprisingly something crashes when we try to do it
onlyRemoveTypeImports: true
}
]
]
},
{
test: /\/coaction-solid\//,
presets: ['babel-preset-solid']
}
],
plugins: [
stripSymbolObservableMethodPlugin,
'@babel/proposal-class-properties'
]
};