diff --git a/assets/js/plugin-preload.js b/assets/js/plugin-preload.js index 993378bb2..f3d8ff252 100644 --- a/assets/js/plugin-preload.js +++ b/assets/js/plugin-preload.js @@ -5,7 +5,7 @@ const APPDATA_PATH = remote.getGlobal('APPDATA_PATH') const config = remote.require('./lib/config') require('module').globalPaths.unshift(MODULE_PATH) -require('@babel/register')(require(`${ROOT}/babel.config`)) +require('@babel/register')(require(`${ROOT}/babel-register.config`)) require('coffee-react/register') async function setPath() { require(`${ROOT}/lib/module-path`).setAllowedPath([ diff --git a/babel-register.config.js b/babel-register.config.js new file mode 100644 index 000000000..7f66d7f0d --- /dev/null +++ b/babel-register.config.js @@ -0,0 +1,7 @@ +const babelConfig = require('./babel.config') + +module.exports = { + ...babelConfig, + extensions: ['.es', '.ts', '.tsx'], + cache: false, +} diff --git a/babel.config.js b/babel.config.js index 8d1a039f2..e6969fac5 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,6 +1,4 @@ -const { omit } = require('lodash') - -const config = { +module.exports = { presets: [ [ require.resolve('@babel/preset-env'), @@ -41,13 +39,4 @@ const config = { ignore: [], only: [/\.(es|ts|tsx)$/], babelrc: false, - extensions: ['.es', '.ts', '.tsx'], - cache: false, -} - -module.exports = config - -// babel-jest does not support extra config options -if (process.env.NODE_ENV === 'test') { - module.exports = omit(config, ['extensions', 'cache']) } diff --git a/content/merge-content.js b/content/merge-content.js index 01fe432ca..42f1a2590 100644 --- a/content/merge-content.js +++ b/content/merge-content.js @@ -3,7 +3,7 @@ * usage: node merge-content.js */ -require('@babel/register')(require('../babel.config')) +require('@babel/register')(require('../babel-register.config')) const glob = require('glob') const matter = require('gray-matter') const Promise = require('bluebird') diff --git a/gulpfile.js b/gulpfile.js index dcb1f8d48..70593f405 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,4 +1,4 @@ -require('@babel/register')(require('./babel.config')) +require('@babel/register')(require('./babel-register.config')) const gulp = require('gulp') const childProcess = require('child_process') const { trim } = require('lodash') diff --git a/index.html b/index.html index 10d010968..f019b1a58 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ diff --git a/index.js b/index.js index ac20f3671..86b6fd91b 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ try { require('./lib/cli') } catch (e) { - require('@babel/register')(require('./babel.config')) + require('@babel/register')(require('./babel-register.config')) require('./lib/cli') } finally { require('./app') diff --git a/views/env.es b/views/env.es index 7e7a2961e..d26b702e6 100644 --- a/views/env.es +++ b/views/env.es @@ -1,5 +1,5 @@ require('coffee-react/register') -require('@babel/register')(require('../babel.config')) +require('@babel/register')(require('../babel-register.config')) import path from 'path-extra' import fs from 'fs-extra' import { remote } from 'electron'