forked from keplergl/kepler.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
72 lines (67 loc) · 1.96 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
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
const {resolve} = require('path');
const KeplerPackage = require('./package');
const {RESOLVE_ALIASES} = require('./webpack/shared-webpack-configuration');
const nodeModules = resolve(__dirname, 'node_modules');
const PRESETS = ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'];
const PLUGINS = [
['@babel/plugin-transform-typescript', {isTSX: true, allowDeclareFields: true}],
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-transform-class-properties',
'@babel/plugin-transform-optional-chaining',
'@babel/plugin-transform-logical-assignment-operators',
'@babel/plugin-transform-nullish-coalescing-operator',
'@babel/plugin-transform-export-namespace-from',
[
'@babel/transform-runtime',
{
regenerator: true
}
],
[
'module-resolver',
{
extensions: ['.js', '.ts', '.tsx', '.json'],
root: ['./src'],
alias: {
test: './test',
// We explicitly transpile this ESM library in scripts/fix-dependencies.js and consume the transpiled version here
// This may not be needed once switch to Jest is complete as it is handled by transformIgnorePatterns
'@mapbox/tiny-sdf': `${nodeModules}/@mapbox/tiny-sdf/index.cjs`,
// compile from @kepler.gl src
...RESOLVE_ALIASES,
// loaders.gl cjs bundle of polyfills is not transpiled properly, use esm instead
'@loaders.gl/polyfills': `${nodeModules}/@loaders.gl/polyfills/src`
}
}
],
[
'search-and-replace',
{
rules: [
{
search: '__PACKAGE_VERSION__',
replace: KeplerPackage.version
}
]
}
]
];
const ENV = {
test: {
plugins: ['istanbul']
},
debug: {
sourceMaps: 'inline',
retainLines: true
}
};
module.exports = function babel(api) {
api.cache(true);
return {
presets: PRESETS,
plugins: PLUGINS,
env: ENV
};
};