Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
b2201931
Commit
b2201931
authored
Feb 12, 2017
by
Arunoda Susiripala
Committed by
Naoyuki Kanezawa
Feb 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Babelrc false babelrc (#1094)
* Detect babelrc disabling via babelrc. * Simplify boolean condition.
parent
a0453a7b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
9 deletions
+17
-9
.babelrc
examples/.babelrc
+1
-1
find-config.js
server/build/babel/find-config.js
+2
-2
webpack.js
server/build/webpack.js
+14
-6
No files found.
examples/.babelrc
View file @
b2201931
{
{
"presets": ["../babel"]
"babelrc": false
}
}
\ No newline at end of file
server/build/babel/find-config
-location
.js
→
server/build/babel/find-config.js
View file @
b2201931
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
buildConfigChain
from
'babel-core/lib/transformation/file/options/build-config-chain'
import
buildConfigChain
from
'babel-core/lib/transformation/file/options/build-config-chain'
export
default
function
findBabelConfig
Location
(
dir
)
{
export
default
function
findBabelConfig
(
dir
)
{
// We need to provide a location of a filename inside the `dir`.
// We need to provide a location of a filename inside the `dir`.
// For the name of the file, we could be provide anything.
// For the name of the file, we could be provide anything.
const
filename
=
join
(
dir
,
'filename.js'
)
const
filename
=
join
(
dir
,
'filename.js'
)
...
@@ -12,5 +12,5 @@ export default function findBabelConfigLocation (dir) {
...
@@ -12,5 +12,5 @@ export default function findBabelConfigLocation (dir) {
// That's the config we are passing as the "options" below
// That's the config we are passing as the "options" below
const
configList
=
buildConfigChain
(
options
).
filter
(
i
=>
i
.
loc
!==
'base'
)
const
configList
=
buildConfigChain
(
options
).
filter
(
i
=>
i
.
loc
!==
'base'
)
return
configList
[
0
]
?
configList
[
0
].
loc
:
null
return
configList
[
0
]
}
}
server/build/webpack.js
View file @
b2201931
...
@@ -10,7 +10,7 @@ import WatchPagesPlugin from './plugins/watch-pages-plugin'
...
@@ -10,7 +10,7 @@ import WatchPagesPlugin from './plugins/watch-pages-plugin'
import
JsonPagesPlugin
from
'./plugins/json-pages-plugin'
import
JsonPagesPlugin
from
'./plugins/json-pages-plugin'
import
getConfig
from
'../config'
import
getConfig
from
'../config'
import
*
as
babelCore
from
'babel-core'
import
*
as
babelCore
from
'babel-core'
import
findBabelConfig
Location
from
'./babel/find-config-location
'
import
findBabelConfig
from
'./babel/find-config
'
const
documentPage
=
join
(
'pages'
,
'_document.js'
)
const
documentPage
=
join
(
'pages'
,
'_document.js'
)
const
defaultPages
=
[
const
defaultPages
=
[
...
@@ -114,16 +114,24 @@ export default async function createCompiler (dir, { dev = false, quiet = false
...
@@ -114,16 +114,24 @@ export default async function createCompiler (dir, { dev = false, quiet = false
presets
:
[]
presets
:
[]
}
}
const
configLocation
=
findBabelConfigLocation
(
dir
)
const
externalBabelConfig
=
findBabelConfig
(
dir
)
if
(
configLocation
)
{
if
(
externalBabelConfig
)
{
console
.
log
(
`> Using external babel configuration`
)
console
.
log
(
`> Using external babel configuration`
)
console
.
log
(
`> location: "
${
configLocation
}
"`
)
console
.
log
(
`> location: "
${
externalBabelConfig
.
loc
}
"`
)
mainBabelOptions
.
babelrc
=
true
// It's possible to turn off babelrc support via babelrc itself.
// In that case, we should add our default preset.
// That's why we need to do this.
const
{
options
}
=
externalBabelConfig
mainBabelOptions
.
babelrc
=
options
.
babelrc
!==
false
}
else
{
}
else
{
mainBabelOptions
.
presets
.
push
(
require
.
resolve
(
'./babel/preset'
))
mainBabelOptions
.
babelrc
=
false
mainBabelOptions
.
babelrc
=
false
}
}
// Add our default preset if the no "babelrc" found.
if
(
!
mainBabelOptions
.
babelrc
)
{
mainBabelOptions
.
presets
.
push
(
require
.
resolve
(
'./babel/preset'
))
}
const
rules
=
(
dev
?
[{
const
rules
=
(
dev
?
[{
test
:
/
\.
js
(\?[^
?
]
*
)?
$/
,
test
:
/
\.
js
(\?[^
?
]
*
)?
$/
,
loader
:
'hot-self-accept-loader'
,
loader
:
'hot-self-accept-loader'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment