-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
babel.config.js
28 lines (26 loc) · 908 Bytes
/
babel.config.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
'use strict'
// @ts-check
/** @type {babel.ConfigFunction} */
module.exports = (api) => ({
presets: [
// Transpile modern JavaScript into code compatible with njs.
// This is used only for building the dist bundle with Rollup.
...api.env('njs') ? [
'babel-preset-njs',
] : [],
// Parse TypeScript syntax and transform it to JavaScript (i.e. it strips
// type annotations, but does not perform type checking).
['@babel/preset-typescript', {
allowDeclareFields: true,
}],
],
plugins: [
...!api.caller(c => c && c.supportsStaticESM) ? [
// Transform ES modules to CommonJS if needed needed for Mocha tests).
// Mocha, babel-node, babel/register etc. don't understand ES module
// syntax, so we have to transform it to CommonJS.
// This is not used with Rollup.
'@babel/plugin-transform-modules-commonjs'
] : [],
],
})