babel.config.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 = [
  22. 'babel-preset-typescript-vue3',
  23. '@babel/typescript',
  24. '@babel/preset-env',
  25. '@babel/preset-react'
  26. ];
  27. const plugins = [
  28. [
  29. 'module-resolver',
  30. {
  31. root: ['./desktop/core/src/desktop/js']
  32. }
  33. ],
  34. ['@babel/plugin-proposal-decorators', { version: '2023-11' }]
  35. ];
  36. const overrides = [
  37. {
  38. test: parserFileRegex,
  39. compact: false
  40. },
  41. {
  42. test: aceRegex,
  43. compact: false
  44. }
  45. ];
  46. const env = {
  47. test: {
  48. presets: ['@babel/typescript', '@babel/preset-env'],
  49. plugins: [
  50. [
  51. 'module-resolver',
  52. {
  53. root: ['./desktop/core/src/desktop/js']
  54. }
  55. ]
  56. ]
  57. }
  58. };
  59. return {
  60. env,
  61. overrides,
  62. presets,
  63. plugins
  64. };
  65. };