babel.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Licensed to Cloudera, Inc. under one
  2. // or more contributor license agreements. See the NOTICE file
  3. // distributed with this work for additional information
  4. // regarding copyright ownership. Cloudera, Inc. licenses this file
  5. // to you under the Apache License, Version 2.0 (the
  6. // "License"); you may not use this file except in compliance
  7. // with the License. You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. const aceRegex = /.*\/js\/ext\/ace\/ace.js$/;
  17. const parserFileRegex = /.*desktop\/js\/parse\/.*Parser.js$/;
  18. module.exports = function (api) {
  19. api.cache(true);
  20. api.assertVersion('^7.4.5');
  21. const presets = ['babel-preset-typescript-vue3', '@babel/typescript', '@babel/preset-env', '@babel/preset-react'];
  22. const plugins = [
  23. [
  24. 'module-resolver',
  25. {
  26. root: ['./desktop/core/src/desktop/js']
  27. }
  28. ],
  29. '@babel/plugin-syntax-dynamic-import',
  30. [
  31. '@babel/plugin-proposal-decorators',
  32. {
  33. legacy: true
  34. }
  35. ],
  36. [
  37. '@babel/proposal-class-properties',
  38. {
  39. loose: true
  40. }
  41. ],
  42. ['@babel/plugin-proposal-private-methods', { loose: true }],
  43. '@babel/proposal-object-rest-spread'
  44. ];
  45. const overrides = [
  46. {
  47. test: parserFileRegex,
  48. compact: false
  49. },
  50. {
  51. test: aceRegex,
  52. compact: false
  53. }
  54. ];
  55. const env = {
  56. test: {
  57. presets: ['@babel/typescript', '@babel/preset-env'],
  58. plugins: [
  59. [
  60. 'module-resolver',
  61. {
  62. root: ['./desktop/core/src/desktop/js']
  63. }
  64. ],
  65. '@babel/plugin-syntax-dynamic-import'
  66. ]
  67. }
  68. };
  69. return {
  70. env,
  71. overrides,
  72. presets,
  73. plugins
  74. };
  75. };