-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.js
52 lines (40 loc) · 1.35 KB
/
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
function getBabelConfiguration(nodeVersion, entryPointPath, omitExtensions) {
var language = entryPointPath.endsWith('.ts') || entryPointPath.endsWith('.tsx') ? 'ts' : 'js';
var presets = [];
if (language === 'js') {
presets.push([require('@babel/preset-flow').default]);
}
if (language === 'ts') {
presets.push([
require('./build/babel-preset-typescript').default
]);
}
presets.push([
require('@babel/preset-env').default,
{
targets: {node: nodeVersion || 'current'}
}
]);
var plugins = [];
if (language === 'ts') {
require('reflect-metadata');
plugins.push([require('@babel/plugin-syntax-decorators').default, {legacy: true}]);
plugins.push([require('./build/typescript-babel-decorators.js').default]);
}
if (language === 'js') {
plugins.push([require('@babel/plugin-proposal-decorators').default, { legacy: true }]);
}
plugins.push([require('@babel/plugin-proposal-class-properties').default, { loose: true }]);
var enableLocalBabelRc = process.env.ENABLE_LOCAL_BABEL_RC;
var configuration = {
presets: presets,
plugins: plugins,
babelrc: !!enableLocalBabelRc,
extensions: ['.es6', '.es', '.jsx', '.js', '.mjs', '.ts', '.tsx']
};
if (omitExtensions) {
delete configuration.extensions;
}
return configuration;
}
module.exports = getBabelConfiguration;