forked from Opentrons/opentrons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
73 lines (72 loc) · 2.48 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict'
module.exports = {
env: {
// Note(isk: 3/2/20): Must have babel-plugin-styled-components in each env,
// see here for further details: s https://styled-components.com/docs/tooling#babel-plugin
production: {
plugins: ['babel-plugin-styled-components', 'babel-plugin-unassert'],
},
development: {
plugins: ['babel-plugin-styled-components', 'react-hot-loader/babel'],
},
test: {
plugins: [
// NOTE(mc, 2020-05-08): disable ssr, displayName to fix toHaveStyleRule
// https://github.com/styled-components/jest-styled-components/issues/294
['babel-plugin-styled-components', { ssr: false, displayName: false }],
'@babel/plugin-transform-modules-commonjs',
'babel-plugin-dynamic-import-node',
],
},
},
plugins: [
'@babel/plugin-proposal-class-properties',
// ensure opentrons packages written in TS resolve to source code in
// unit tests and bundling by rewriting import statements with babel
[
'babel-plugin-module-resolver',
{
alias: {
'^@opentrons/discovery-client$': `@opentrons/discovery-client/src/index.ts`,
'^@opentrons/components$': `@opentrons/components/src/index.ts`,
'^@opentrons/shared-data$': `@opentrons/shared-data/js/index.ts`,
'^@opentrons/step-generation$': `@opentrons/step-generation/src/index.ts`,
'^@opentrons/api-client$': `@opentrons/api-client/src/index.ts`,
'^@opentrons/react-api-client$': `@opentrons/react-api-client/src/index.ts`,
},
},
],
],
presets: [
'@babel/preset-react',
['@babel/preset-env', { modules: false, useBuiltIns: false }],
],
overrides: [
{
test: ['**/*.ts', '**/*.tsx'],
presets: ['@babel/preset-typescript'],
},
{
test: 'app-shell/**/*',
plugins: [['react-hot-loader/babel', false]],
presets: [['@babel/preset-env', { targets: { electron: '6' } }]],
},
{
test: ['discovery-client/**/*'],
plugins: [['react-hot-loader/babel', false]],
presets: [['@babel/preset-env', { targets: { node: '8' } }]],
},
// apps that should be polyfilled
// these projects require `core-js` in their package.json `dependencies`
{
test: [
'app/**/*',
'labware-library/**/*',
'protocol-designer/**/*',
'react-api-client/**/*',
'api-client/**/*',
],
presets: [['@babel/preset-env', { useBuiltIns: 'usage', corejs: 3 }]],
},
],
}