From 9c71f2d51fb5174a9652f1b0720541fc4363626b Mon Sep 17 00:00:00 2001
From: esikkala <esko.ikkala@aalto.fi>
Date: Wed, 15 Sep 2021 16:53:20 +0300
Subject: [PATCH] Add Babel config for JavaScript Standard Style

---
 babel.config.js | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/babel.config.js b/babel.config.js
index 377445d9..7bbdf6b8 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -1,9 +1,8 @@
 module.exports = function (api) {
   api.cache(true)
-  const isBrowser = process.env.BABEL_ENV === 'browser'
   const presets = []
   const plugins = []
-  if (isBrowser) {
+  if (process.env.BABEL_ENV === 'browser') {
     presets.push([
       // https://babeljs.io/docs/en/babel-preset-env
       '@babel/preset-env',
@@ -21,7 +20,7 @@ module.exports = function (api) {
     plugins.push('@babel/plugin-proposal-class-properties')
     plugins.push('@babel/plugin-transform-runtime')
   }
-  if (!isBrowser) {
+  if (process.env.BABEL_ENV === 'node') {
     presets.push([
       '@babel/preset-env',
       {
@@ -31,6 +30,10 @@ module.exports = function (api) {
       }
     ])
   }
+  // for JavaScript Standard Style library to support JSX syntax
+  if (process.env.BABEL_ENV === undefined) {
+    presets.push('@babel/preset-react')
+  }
 
   return {
     presets,
-- 
GitLab