-
Notifications
You must be signed in to change notification settings - Fork 41
/
babel.config.js
66 lines (64 loc) · 1.99 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
'use strict';
// ? https://nodejs.org/en/about/releases
const NODE_LTS = 'maintained node versions';
/**
* @type {import('@babel/core').TransformOptions}
*/
module.exports = {
comments: false,
parserOpts: { strictMode: true },
plugins: ['@babel/plugin-proposal-export-default-from'],
// ? Sub-keys under the "env" config key will augment the above
// ? configuration depending on the value of NODE_ENV and friends. Default
// ? is: development
env: {
// * Used by Jest and `npm test`
test: {
comments: true,
sourceMaps: process.env.JEST_TRANSPILED ? false : 'inline',
presets: [
['@babel/preset-env', { targets: { node: true } }],
['@babel/preset-typescript', { allowDeclareFields: true }]
],
plugins: [
// ? Only active when testing, the plugin solves the following problem:
// ? https://stackoverflow.com/q/40771520/1367414
'explicit-exports-references'
]
},
// * Used when NODE_ENV === production (usually for generating types w/ tsc)
production: {
presets: [
[
'@babel/preset-env',
{
// ? https://babeljs.io/docs/en/babel-preset-env#modules
modules: 'auto',
targets: NODE_LTS,
exclude: ['proposal-dynamic-import']
}
],
['@babel/preset-typescript', { allowDeclareFields: true }]
// ? Minification is handled externally (e.g. by webpack)
]
},
// * Used by `npm run build` for compiling CJS to code output in ./dist
'production-cjs': {
presets: [
[
'@babel/preset-env',
{
// ? https://babeljs.io/docs/en/babel-preset-env#modules
modules: 'cjs',
targets: NODE_LTS,
useBuiltIns: 'usage',
corejs: '3.36',
shippedProposals: true,
exclude: ['proposal-dynamic-import']
}
],
['@babel/preset-typescript', { allowDeclareFields: true }]
]
}
}
};