-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.cjs
95 lines (92 loc) · 2.46 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
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
const config = require('@monorepo/config');
module.exports = (api) => {
const usingEsm = api.env(['production-esm', 'test-esm', 'development-esm']);
const production = api.env(['production', 'production-esm']);
const test = api.env(['test', 'test-esm']);
const classPropertyPlugin = [
'@babel/plugin-proposal-class-properties',
{ loose: false },
];
const plugins = [
classPropertyPlugin,
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
'@babel/plugin-transform-strict-mode',
];
if (test) {
plugins.push(
[
'babel-plugin-istanbul',
{
useInlineSourceMaps: true,
include: config.buildableSourceFileGlobs,
exclude: ['.yarn/**', '.pnp.js', '.pnp.cjs'],
},
],
'rewiremock/babel',
);
}
const presets = [
[
'@babel/preset-env',
{
shippedProposals: true,
// TODO: Remove this once Babel 8 is implemented
bugfixes: true,
modules: usingEsm ? false : 'commonjs',
// useBuiltIns: 'usage',
// corejs: '3',
targets: {
node: production ? '12' : 'current',
esmodules: usingEsm,
},
},
],
];
return {
presets: [...presets, '@babel/preset-typescript'],
plugins,
assumptions: {
constantReexports: true,
constantSuper: true,
enumerableModuleMeta: false,
ignoreFunctionLength: false,
//ignoreToPrimitiveHint:
iterableIsArray: false,
//mutableTemplateObject:
noClassCalls: true,
noDocumentAll: true,
noNewArrows: true,
objectRestNoSymbols: false,
//privateFieldsAsProperties:
pureGetters: false,
setClassMethods: false,
setComputedProperties: true,
setPublicClassFields: false,
//setSpreadProperties:
//skipForOfIteratorClosing:
//superIsCallableConstructor:
},
overrides: [
{
test: ['./packages/*/javascript/**/*.react.tsx'],
plugins,
presets: presets.concat(['@babel/preset-typescript', '@babel/preset-react']),
},
{
test: ['./packages/*/javascript/**/*.tsx'],
plugins: plugins.concat([
'@babel/plugin-syntax-jsx',
require.resolve('@cinderjs/babel-plugin-transform-jsx'),
]),
presets: [
[
'@babel/preset-typescript',
{
jsxPragma: 'cinder',
},
],
],
},
],
};
};