Skip to content

Commit

Permalink
fix: separate babel core config and register config
Browse files Browse the repository at this point in the history
  • Loading branch information
KagamiChan committed Nov 26, 2020
1 parent 80481ec commit c68b392
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion assets/js/plugin-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
7 changes: 7 additions & 0 deletions babel-register.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const babelConfig = require('./babel.config')

module.exports = {
...babelConfig,
extensions: ['.es', '.ts', '.tsx'],
cache: false,
}
13 changes: 1 addition & 12 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const { omit } = require('lodash')

const config = {
module.exports = {
presets: [
[
require.resolve('@babel/preset-env'),
Expand Down Expand Up @@ -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'])
}
2 changes: 1 addition & 1 deletion content/merge-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script>
window.isMain = true
require('coffee-script/register');
require('@babel/register')(require('./babel.config'));
require('@babel/register')(require('./babel-register.config'));
require('./views/env');
</script>
</head>
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
2 changes: 1 addition & 1 deletion views/env.es
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit c68b392

Please sign in to comment.