forked from radix-ui/primitives
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
42 lines (39 loc) · 1.08 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
const template = require('@babel/template');
const buildAssign = template.smart('Object.assign(COMPONENT, { displayName: DISPLAY_NAME });');
const pureDisplayNames = () => ({
visitor: {
AssignmentExpression(path) {
if (
path.node.left.type === 'MemberExpression' &&
path.node.left.property.name === 'displayName' &&
path.node.right.name
) {
const COMPONENT = path.node.left.object.name;
const DISPLAY_NAME = path.node.right.name;
const ast = buildAssign({ COMPONENT, DISPLAY_NAME });
path.replaceWith(ast);
path.addComment('leading', '#__PURE__');
}
},
},
});
module.exports = {
presets: [
[
'@parcel/babel-preset-env',
{
bugfixes: true,
targets: {
browsers: 'Chrome >= 74, Safari >= 13.1, iOS >= 13.3, Firefox >= 78, Edge >= 79',
node: 12,
},
},
],
'@babel/preset-react',
],
plugins: [
pureDisplayNames,
'@parcel/babel-plugin-transform-runtime',
['@babel/plugin-transform-typescript', { isTSX: true }],
],
};