Skip to content

Commit

Permalink
fix(babel): compatibility with create-react-app
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jan 25, 2022
1 parent 91a07f6 commit 137cf4d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
14 changes: 14 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
presets: [
['@babel/preset-env', {
include: [
// required for create-react-app
'@babel/plugin-proposal-nullish-coalescing-operator'
]
}],
'@babel/preset-typescript'
],
plugins: [
['@babel/plugin-transform-runtime', { corejs: 3 }]
]
}
9 changes: 0 additions & 9 deletions babel.config.json

This file was deleted.

7 changes: 5 additions & 2 deletions babel.esm.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const config = require('./babel.config.json')
const config = require('./babel.config.js')

config.presets
.filter(plugin => Array.isArray(plugin))
.find(([name]) => name === '@babel/preset-env')[1].modules = false

config.presets[0] = ['@babel/preset-env', { modules: false }]
config.plugins.push(['add-import-extension', { extension: 'mjs' }])
config.plugins.push('transform-default-named-imports')

Expand Down

0 comments on commit 137cf4d

Please sign in to comment.