go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/babel.config.json (about)

     1  // Copyright 2023 The LUCI Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  {
    16    "plugins": [
    17      [
    18        "@babel/plugin-proposal-decorators",
    19        {
    20          // TypeScript's documentation says `experimentalDecorators` enables
    21          // support for TC39 stage 2 draft decorators [1], the actual
    22          // implementation matches closer to the "legacy" version (i.e. stage 1)
    23          // than the "2018-08" version (i.e. stage 2).
    24          //
    25          // There are still a key difference between Babel legacy decorator and
    26          // TypeScript's decorator: Babel decorators can't be used to decorate
    27          // properties/methods with computed names. For example,
    28          // `@decorate [propName] = 2` will fail to transpile.
    29          //
    30          // [1]: https://www.typescriptlang.org/tsconfig#experimentalDecorators
    31          "version": "legacy"
    32        }
    33      ],
    34      "@babel/plugin-proposal-class-properties"
    35    ],
    36    "env": {
    37      "test": {
    38        // Code doesn't go through the Vite's building pipeline when testing.
    39        // We need some additional plugins for JS transpilation.
    40        "plugins": [
    41          "@babel/plugin-proposal-private-methods",
    42          "transform-es2015-modules-commonjs"
    43        ]
    44      }
    45    }
    46  }