mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Improve babel settings (#976)
* fix babelrc settings * use only transform-es2015-modules-commonjs for transpiling emitting files
This commit is contained in:
parent
3143e0d0a1
commit
ddd93e9865
|
@ -50,6 +50,7 @@
|
||||||
"babel-plugin-react-require": "^3.0.0",
|
"babel-plugin-react-require": "^3.0.0",
|
||||||
"babel-plugin-transform-async-to-generator": "6.22.0",
|
"babel-plugin-transform-async-to-generator": "6.22.0",
|
||||||
"babel-plugin-transform-class-properties": "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-object-rest-spread": "6.22.0",
|
||||||
"babel-plugin-transform-runtime": "6.22.0",
|
"babel-plugin-transform-runtime": "6.22.0",
|
||||||
"babel-preset-es2015": "6.22.0",
|
"babel-preset-es2015": "6.22.0",
|
||||||
|
|
|
@ -109,7 +109,6 @@ export default async function createCompiler (dir, { dev = false, quiet = false
|
||||||
.filter((p) => !!p)
|
.filter((p) => !!p)
|
||||||
|
|
||||||
const mainBabelOptions = {
|
const mainBabelOptions = {
|
||||||
babelrc: true,
|
|
||||||
cacheDirectory: true,
|
cacheDirectory: true,
|
||||||
sourceMaps: dev ? 'both' : false,
|
sourceMaps: dev ? 'both' : false,
|
||||||
presets: []
|
presets: []
|
||||||
|
@ -119,8 +118,10 @@ export default async function createCompiler (dir, { dev = false, quiet = false
|
||||||
if (configLocation) {
|
if (configLocation) {
|
||||||
console.log(`> Using external babel configuration`)
|
console.log(`> Using external babel configuration`)
|
||||||
console.log(`> location: "${configLocation}"`)
|
console.log(`> location: "${configLocation}"`)
|
||||||
|
mainBabelOptions.babelrc = true
|
||||||
} else {
|
} else {
|
||||||
mainBabelOptions.presets.push(require.resolve('./babel/preset'))
|
mainBabelOptions.presets.push(require.resolve('./babel/preset'))
|
||||||
|
mainBabelOptions.babelrc = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const rules = (dev ? [{
|
const rules = (dev ? [{
|
||||||
|
@ -158,7 +159,7 @@ export default async function createCompiler (dir, { dev = false, quiet = false
|
||||||
const babelRuntimePath = require.resolve('babel-runtime/package')
|
const babelRuntimePath = require.resolve('babel-runtime/package')
|
||||||
.replace(/[\\/]package\.json$/, '')
|
.replace(/[\\/]package\.json$/, '')
|
||||||
const transpiled = babelCore.transform(content, {
|
const transpiled = babelCore.transform(content, {
|
||||||
presets: [require.resolve('babel-preset-es2015')],
|
babelrc: false,
|
||||||
sourceMaps: dev ? 'both' : false,
|
sourceMaps: dev ? 'both' : false,
|
||||||
// Here we need to resolve all modules to the absolute paths.
|
// Here we need to resolve all modules to the absolute paths.
|
||||||
// Earlier we did it with the babel-preset.
|
// Earlier we did it with the babel-preset.
|
||||||
|
@ -166,6 +167,7 @@ export default async function createCompiler (dir, { dev = false, quiet = false
|
||||||
// That's why we need to do it here.
|
// That's why we need to do it here.
|
||||||
// See more: https://github.com/zeit/next.js/issues/951
|
// See more: https://github.com/zeit/next.js/issues/951
|
||||||
plugins: [
|
plugins: [
|
||||||
|
[require.resolve('babel-plugin-transform-es2015-modules-commonjs')],
|
||||||
[
|
[
|
||||||
require.resolve('babel-plugin-module-resolver'),
|
require.resolve('babel-plugin-module-resolver'),
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue