-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbabel.config.js
33 lines (31 loc) · 1.06 KB
/
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
29
30
31
32
33
'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'
] : [],
...api.env('mocha') ? [
// Transform power-assert. This is used only for Mocha tests.
'babel-plugin-empower-assert',
'babel-plugin-espower',
] : [],
],
})