-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbabel.config.js
46 lines (38 loc) · 898 Bytes
/
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
// @flow strict
/*::
type ApiType = {
+assertVersion: number => void,
+cache: {
forever: () => void,
},
+caller: (Caller => boolean) => boolean,
};
type Caller = {
+name: string,
};
type BabelConfig = {
+presets: $ReadOnlyArray<string | [string, { ... }]>,
+babelrcRoots: $ReadOnlyArray<string>,
};
*/
function isWebpack(caller /*: Caller */) /*: boolean */ {
// https://github.com/babel/babel-loader
return !!(caller && caller.name === 'babel-loader');
}
module.exports = function (api /*: ApiType */) /*: BabelConfig */ {
api.assertVersion(7);
return {
presets: [
[
'@adeira/babel-preset-adeira',
{
target: api.caller(isWebpack) ? 'js-esm' : 'js',
},
],
],
babelrcRoots: [
'.', // keep the root as a root
'./src/*', // also consider all packages and load their .babelrc files.
],
};
};