Skip to content

Commit

Permalink
Improve babel settings (#976)
Browse files Browse the repository at this point in the history
* fix babelrc settings

* use only transform-es2015-modules-commonjs for transpiling emitting files
  • Loading branch information
nkzawa authored and rauchg committed Feb 3, 2017
1 parent 3143e0d commit ddd93e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"babel-plugin-react-require": "^3.0.0",
"babel-plugin-transform-async-to-generator": "6.22.0",
"babel-plugin-transform-class-properties": "6.22.0",
"babel-plugin-transform-es2015-modules-commonjs": "6.22.0",
"babel-plugin-transform-object-rest-spread": "6.22.0",
"babel-plugin-transform-runtime": "6.22.0",
"babel-preset-es2015": "6.22.0",
Expand Down
6 changes: 4 additions & 2 deletions server/build/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export default async function createCompiler (dir, { dev = false, quiet = false
.filter((p) => !!p)

const mainBabelOptions = {
babelrc: true,
cacheDirectory: true,
sourceMaps: dev ? 'both' : false,
presets: []
Expand All @@ -119,8 +118,10 @@ export default async function createCompiler (dir, { dev = false, quiet = false
if (configLocation) {
console.log(`> Using external babel configuration`)
console.log(`> location: "${configLocation}"`)
mainBabelOptions.babelrc = true
} else {
mainBabelOptions.presets.push(require.resolve('./babel/preset'))
mainBabelOptions.babelrc = false
}

const rules = (dev ? [{
Expand Down Expand Up @@ -158,14 +159,15 @@ export default async function createCompiler (dir, { dev = false, quiet = false
const babelRuntimePath = require.resolve('babel-runtime/package')
.replace(/[\\/]package\.json$/, '')
const transpiled = babelCore.transform(content, {
presets: [require.resolve('babel-preset-es2015')],
babelrc: false,
sourceMaps: dev ? 'both' : false,
// Here we need to resolve all modules to the absolute paths.
// Earlier we did it with the babel-preset.
// But since we don't transpile ES2015 in the preset this is not resolving.
// That's why we need to do it here.
// See more: https://github.com/zeit/next.js/issues/951
plugins: [
[require.resolve('babel-plugin-transform-es2015-modules-commonjs')],
[
require.resolve('babel-plugin-module-resolver'),
{
Expand Down

0 comments on commit ddd93e9

Please sign in to comment.