-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbabel.config.js
49 lines (45 loc) · 1.92 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
/*
* Used by JEST Unit Test (where this config file is auto pickedup) & Build/Bundle (where this config file is imported)
*/
module.exports = {
plugins: [
/**
* Shared by build/bundle + Jest Test
* - used for Ant Design UI Components + "babel-plugin-import" to resolve `import` issue and large final bundle size issue
* - ref: https://github.com/ant-design/babel-plugin-import#note
* - Component Library Usage in Jx/Ts:
* `import {Button} from 'antd';` does NOT work for Prod build (as it import all modules resulting in large file)
* (even specifying in babel config `"libraryDirectory": "lib"` does not work)
*
* `import Button from 'antd/es/button';` does NOT work for JEST (as it doesnt allow ES6 import/export in "node_modules/")
*
* `import Button from 'antd/lib/button';` works for both Prod build (Browserify) + JEST
*/
["import", {"libraryName": "antd"}],
/**
* For ES6 Class property defined on top of `constructor`
*/
["@babel/plugin-proposal-class-properties", { "loose": true }],
/*
* For Code that uses `async/await`
*/
["@babel/plugin-transform-runtime"]
],
presets: [
/**
* Shared by both build/bundle + Jest Test
* - `['react-app', {'typescript': true}]` (from pkg "babel-preset-react-app") does not work for Jest
*/
"@babel/preset-env", "@babel/preset-react",
'@babel/preset-typescript'
],
/**
* Support for importing from a Library in "node_modules"which uses ES6 via `import/export`
* - `ignore` requires `global: true`
* - `ignore` filters down the allowed path
*/
// global: true,
// ignore: [
// './node_modules/<ui-library-path-where-it-is-imported-in-your-js/ts-file>'
// ]
};