kibana/packages/kbn-babel-preset/common_preset.js

52 lines
2.1 KiB
JavaScript
Raw Normal View History

/*
* 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 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 or the Server
* Side Public License, v 1.
*/
const plugins = [
require.resolve('babel-plugin-add-module-exports'),
// The class properties proposal was merged with the private fields proposal
// into the "class fields" proposal. Babel doesn't support this combined
// proposal yet, which includes private field, so this transform is
// TECHNICALLY stage 2, but for all intents and purposes it's stage 3
//
// See https://github.com/babel/proposals/issues/12 for progress
require.resolve('@babel/plugin-proposal-class-properties'),
// Optional Chaining proposal is stage 4 (https://github.com/tc39/proposal-optional-chaining)
// Need this since we are using TypeScript 3.7+
require.resolve('@babel/plugin-proposal-optional-chaining'),
// Nullish coalescing proposal is stage 4 (https://github.com/tc39/proposal-nullish-coalescing)
// Need this since we are using TypeScript 3.7+
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
Bump TypeScript to v3.9 (#67666) * add babel support for export type * bump ts version to 3.9.3 * rebuild kbn-pm * bump typescript-eslint * fix error in security plugin UI * check export as works * fix app migration type * use correct test subj attribute * fix errors from the old PR * embeddable is already passed in props * explicitly define type of fetch * add some types for viz * fix fetch type p.2 * add null to allow spreading without type errors due to override * add type guard to fix type error * cast to any, since cannot assign unknown * add timestamp to known types * fix type error in fetch * fix type error. id is always defined in attibutes * declare a type * move ts-ignore to the lines with errors * declare tuple type explicitly * mute type error. cannot assign unknown * fix errors. id is always defined * fix error type * fix override errors. id is always defined * fix error. extends any doesn't work anymore * fix type error. type is always defined * env doesn't always contain values * fix type error * cast to string * add: logs is already declared in getNodeLogsUrl * state is already passed in props * fix some errors in timelion * number of fragments is always defined * 'absolute' is not just string, but value * TEMP: option is always defined * always true if cast to promise manually * both props are always defined * explicitly define returned SO type * workaround type * bump tslib to be compatible with ts v3.9 * test private property * rebuild kbn-pm * Fix ts errors for beats management * Fix type inference broken by the TS 3.9 upgrade * Fix ingest manager saved object attributes typings * Fix TS errors in cross_cluster_replication and index_management. * Fix TS error in Watcher. * roll back colorRange wrong type * fix security plugin types * TypeScript 3.9 fixes for APM * Fix ColorRange types. * fix actions & alerts errors. ByGidi * fix lists error * More APM fixes * Remove paramaterization from `removeEmpty in agent config SettingsPage component (it's only used there and doesn't need to be parameterized.) * Add option chain for case in registerTransactionDurationAlertType * Cast `overallValue` in transform_metrics_chart * Use more specific type for custom link filters * Add more option chaining for local UI filters buckets response * Remove unused parameters from routes * Fix getProjection type parameter * Use destructuring in serviceNodesLocalFiltersRoute to hide `never` error * Revert `UnionToIntersection` change in `AggregationResponseMap` Fixes #67804. * fix platform type error * Fix visualizations types. * Fix data plugin types. * bump TS version to 3.9.5 * Fix telemetry TS errors * Fix dashboard code * Adding Canvas Fixes for TS 3.9 * Fix case and security_solution types * roll back to the old export syntax. new one might cause problems in api-extractor * update docs * Fix timelion code * Fix meta * Fix types * fix type errors om ingest_manager * bump babel deps * enable private props & methods syntax * update kbn-pm dist * whitelist 0BSD license * use @babel/plugin-proposal-private-methods in default set as well * disable new babel plugins * Revert "disable new babel plugins" This reverts commit 04d959431d456a082666bf7834f129f1aafd0772. * cleanup security_solution types * Fixes type error for newer TypeScript * update docs Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co> Co-authored-by: Felix Stürmer <stuermer@weltenwort.de> Co-authored-by: CJ Cenizal <cj@cenizal.com> Co-authored-by: Larry Gregory <larry.gregory@elastic.co> Co-authored-by: Nathan L Smith <smith@nlsmith.com> Co-authored-by: Walter Rafelsberger <walter@elastic.co> Co-authored-by: Luke Elmers <luke.elmers@elastic.co> Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co> Co-authored-by: Tim Roes <tim.roes@elastic.co> Co-authored-by: Clint Andrew Hall <clint.hall@elastic.co> Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com> Co-authored-by: FrankHassanabad <frank.hassanabad@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-06-11 10:04:09 +02:00
// Proposal is on stage 4, and included in ECMA-262 (https://github.com/tc39/proposal-export-ns-from)
Bump TypeScript to v3.9 (#67666) * add babel support for export type * bump ts version to 3.9.3 * rebuild kbn-pm * bump typescript-eslint * fix error in security plugin UI * check export as works * fix app migration type * use correct test subj attribute * fix errors from the old PR * embeddable is already passed in props * explicitly define type of fetch * add some types for viz * fix fetch type p.2 * add null to allow spreading without type errors due to override * add type guard to fix type error * cast to any, since cannot assign unknown * add timestamp to known types * fix type error in fetch * fix type error. id is always defined in attibutes * declare a type * move ts-ignore to the lines with errors * declare tuple type explicitly * mute type error. cannot assign unknown * fix errors. id is always defined * fix error type * fix override errors. id is always defined * fix error. extends any doesn't work anymore * fix type error. type is always defined * env doesn't always contain values * fix type error * cast to string * add: logs is already declared in getNodeLogsUrl * state is already passed in props * fix some errors in timelion * number of fragments is always defined * 'absolute' is not just string, but value * TEMP: option is always defined * always true if cast to promise manually * both props are always defined * explicitly define returned SO type * workaround type * bump tslib to be compatible with ts v3.9 * test private property * rebuild kbn-pm * Fix ts errors for beats management * Fix type inference broken by the TS 3.9 upgrade * Fix ingest manager saved object attributes typings * Fix TS errors in cross_cluster_replication and index_management. * Fix TS error in Watcher. * roll back colorRange wrong type * fix security plugin types * TypeScript 3.9 fixes for APM * Fix ColorRange types. * fix actions & alerts errors. ByGidi * fix lists error * More APM fixes * Remove paramaterization from `removeEmpty in agent config SettingsPage component (it's only used there and doesn't need to be parameterized.) * Add option chain for case in registerTransactionDurationAlertType * Cast `overallValue` in transform_metrics_chart * Use more specific type for custom link filters * Add more option chaining for local UI filters buckets response * Remove unused parameters from routes * Fix getProjection type parameter * Use destructuring in serviceNodesLocalFiltersRoute to hide `never` error * Revert `UnionToIntersection` change in `AggregationResponseMap` Fixes #67804. * fix platform type error * Fix visualizations types. * Fix data plugin types. * bump TS version to 3.9.5 * Fix telemetry TS errors * Fix dashboard code * Adding Canvas Fixes for TS 3.9 * Fix case and security_solution types * roll back to the old export syntax. new one might cause problems in api-extractor * update docs * Fix timelion code * Fix meta * Fix types * fix type errors om ingest_manager * bump babel deps * enable private props & methods syntax * update kbn-pm dist * whitelist 0BSD license * use @babel/plugin-proposal-private-methods in default set as well * disable new babel plugins * Revert "disable new babel plugins" This reverts commit 04d959431d456a082666bf7834f129f1aafd0772. * cleanup security_solution types * Fixes type error for newer TypeScript * update docs Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co> Co-authored-by: Felix Stürmer <stuermer@weltenwort.de> Co-authored-by: CJ Cenizal <cj@cenizal.com> Co-authored-by: Larry Gregory <larry.gregory@elastic.co> Co-authored-by: Nathan L Smith <smith@nlsmith.com> Co-authored-by: Walter Rafelsberger <walter@elastic.co> Co-authored-by: Luke Elmers <luke.elmers@elastic.co> Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co> Co-authored-by: Tim Roes <tim.roes@elastic.co> Co-authored-by: Clint Andrew Hall <clint.hall@elastic.co> Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com> Co-authored-by: FrankHassanabad <frank.hassanabad@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-06-11 10:04:09 +02:00
// Need this since we are using TypeScript 3.8+
require.resolve('@babel/plugin-proposal-export-namespace-from'),
// Proposal is on stage 4, and included in ECMA-262 (https://github.com/tc39/proposal-export-ns-from)
Bump TypeScript to v3.9 (#67666) * add babel support for export type * bump ts version to 3.9.3 * rebuild kbn-pm * bump typescript-eslint * fix error in security plugin UI * check export as works * fix app migration type * use correct test subj attribute * fix errors from the old PR * embeddable is already passed in props * explicitly define type of fetch * add some types for viz * fix fetch type p.2 * add null to allow spreading without type errors due to override * add type guard to fix type error * cast to any, since cannot assign unknown * add timestamp to known types * fix type error in fetch * fix type error. id is always defined in attibutes * declare a type * move ts-ignore to the lines with errors * declare tuple type explicitly * mute type error. cannot assign unknown * fix errors. id is always defined * fix error type * fix override errors. id is always defined * fix error. extends any doesn't work anymore * fix type error. type is always defined * env doesn't always contain values * fix type error * cast to string * add: logs is already declared in getNodeLogsUrl * state is already passed in props * fix some errors in timelion * number of fragments is always defined * 'absolute' is not just string, but value * TEMP: option is always defined * always true if cast to promise manually * both props are always defined * explicitly define returned SO type * workaround type * bump tslib to be compatible with ts v3.9 * test private property * rebuild kbn-pm * Fix ts errors for beats management * Fix type inference broken by the TS 3.9 upgrade * Fix ingest manager saved object attributes typings * Fix TS errors in cross_cluster_replication and index_management. * Fix TS error in Watcher. * roll back colorRange wrong type * fix security plugin types * TypeScript 3.9 fixes for APM * Fix ColorRange types. * fix actions & alerts errors. ByGidi * fix lists error * More APM fixes * Remove paramaterization from `removeEmpty in agent config SettingsPage component (it's only used there and doesn't need to be parameterized.) * Add option chain for case in registerTransactionDurationAlertType * Cast `overallValue` in transform_metrics_chart * Use more specific type for custom link filters * Add more option chaining for local UI filters buckets response * Remove unused parameters from routes * Fix getProjection type parameter * Use destructuring in serviceNodesLocalFiltersRoute to hide `never` error * Revert `UnionToIntersection` change in `AggregationResponseMap` Fixes #67804. * fix platform type error * Fix visualizations types. * Fix data plugin types. * bump TS version to 3.9.5 * Fix telemetry TS errors * Fix dashboard code * Adding Canvas Fixes for TS 3.9 * Fix case and security_solution types * roll back to the old export syntax. new one might cause problems in api-extractor * update docs * Fix timelion code * Fix meta * Fix types * fix type errors om ingest_manager * bump babel deps * enable private props & methods syntax * update kbn-pm dist * whitelist 0BSD license * use @babel/plugin-proposal-private-methods in default set as well * disable new babel plugins * Revert "disable new babel plugins" This reverts commit 04d959431d456a082666bf7834f129f1aafd0772. * cleanup security_solution types * Fixes type error for newer TypeScript * update docs Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co> Co-authored-by: Felix Stürmer <stuermer@weltenwort.de> Co-authored-by: CJ Cenizal <cj@cenizal.com> Co-authored-by: Larry Gregory <larry.gregory@elastic.co> Co-authored-by: Nathan L Smith <smith@nlsmith.com> Co-authored-by: Walter Rafelsberger <walter@elastic.co> Co-authored-by: Luke Elmers <luke.elmers@elastic.co> Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co> Co-authored-by: Tim Roes <tim.roes@elastic.co> Co-authored-by: Clint Andrew Hall <clint.hall@elastic.co> Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com> Co-authored-by: FrankHassanabad <frank.hassanabad@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-06-11 10:04:09 +02:00
// Need this since we are using TypeScript 3.9+
require.resolve('@babel/plugin-proposal-private-methods'),
// It enables the @babel/runtime so we can decrease the bundle sizes of the produced outputs
[
require.resolve('@babel/plugin-transform-runtime'),
{
version: '^7.12.5',
},
],
];
module.exports = {
presets: [
[require.resolve('@babel/preset-typescript'), { allowNamespaces: true }],
require.resolve('@babel/preset-react'),
],
plugins,
};