-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
Copy pathnode_preset.js
44 lines (41 loc) · 1.79 KB
/
node_preset.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
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
module.exports = (_, options = {}) => {
return {
presets: [
[
require.resolve('@babel/preset-env'),
{
targets: {
// only applies the necessary transformations based on the
// current node.js processes version. For example: running
// `nvm install 8 && node ./src/cli` will run kibana in node
// version 8 and babel will stop transpiling async/await
// because they are supported in the "current" version of node
node: 'current',
},
// replaces `import "core-js/stable"` with a list of require statements
// for just the polyfills that the target versions don't already supply
// on their own
useBuiltIns: 'entry',
modules: 'cjs',
// right now when using `corejs: 3` babel does not use the latest available
// core-js version due to a bug: https://github.com/babel/babel/issues/10816
// Because of that we should use for that value the same version we install
// in the package.json in order to have the same polyfills between the environment
// and the tests
corejs: '3.37.1',
bugfixes: true,
...(options['@babel/preset-env'] || {}),
},
],
[require('./common_preset'), options],
],
};
};