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
c1528e4f
Unverified
Commit
c1528e4f
authored
May 14, 2021
by
Tim Neutkens
Committed by
GitHub
May 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove experimental-modern-preset option (#25100)
parent
5bff9eac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
35 deletions
+1
-35
preset.ts
packages/next/build/babel/preset.ts
+1
-13
next-babel.unit.test.js
test/unit/next-babel.unit.test.js
+0
-22
No files found.
packages/next/build/babel/preset.ts
View file @
c1528e4f
...
@@ -41,7 +41,6 @@ type NextBabelPresetOptions = {
...
@@ -41,7 +41,6 @@ type NextBabelPresetOptions = {
'preset-react'
?:
any
'preset-react'
?:
any
'class-properties'
?:
any
'class-properties'
?:
any
'transform-runtime'
?:
any
'transform-runtime'
?:
any
'experimental-modern-preset'
?:
PluginItem
'styled-jsx'
?:
StyledJsxBabelOptions
'styled-jsx'
?:
StyledJsxBabelOptions
'preset-typescript'
?:
any
'preset-typescript'
?:
any
}
}
...
@@ -89,10 +88,6 @@ export default (
...
@@ -89,10 +88,6 @@ export default (
(
Boolean
(
api
.
caller
((
caller
:
any
)
=>
!!
caller
&&
caller
.
hasJsxRuntime
))
&&
(
Boolean
(
api
.
caller
((
caller
:
any
)
=>
!!
caller
&&
caller
.
hasJsxRuntime
))
&&
options
[
'preset-react'
]?.
runtime
!==
'classic'
)
options
[
'preset-react'
]?.
runtime
!==
'classic'
)
const
isLaxModern
=
options
[
'preset-env'
]?.
targets
&&
options
[
'preset-env'
].
targets
.
esmodules
===
true
const
presetEnvConfig
=
{
const
presetEnvConfig
=
{
// In the test environment `modules` is often needed to be set to true, babel figures that out by itself using the `'auto'` option
// In the test environment `modules` is often needed to be set to true, babel figures that out by itself using the `'auto'` option
// In production/development this option is set to `false` so that webpack can handle import/export with tree-shaking
// In production/development this option is set to `false` so that webpack can handle import/export with tree-shaking
...
@@ -122,17 +117,10 @@ export default (
...
@@ -122,17 +117,10 @@ export default (
}
}
}
}
// specify a preset to use instead of @babel/preset-env
const
customModernPreset
=
isLaxModern
&&
options
[
'experimental-modern-preset'
]
return
{
return
{
sourceType
:
'unambiguous'
,
sourceType
:
'unambiguous'
,
presets
:
[
presets
:
[
customModernPreset
||
[
[
require
(
'next/dist/compiled/babel/preset-env'
),
presetEnvConfig
],
require
(
'next/dist/compiled/babel/preset-env'
),
presetEnvConfig
,
],
[
[
require
(
'next/dist/compiled/babel/preset-react'
),
require
(
'next/dist/compiled/babel/preset-react'
),
{
{
...
...
test/unit/next-babel.unit.test.js
View file @
c1528e4f
...
@@ -165,28 +165,6 @@ describe('next/babel', () => {
...
@@ -165,28 +165,6 @@ describe('next/babel', () => {
})
})
})
})
describe
(
'experimental-modern-preset'
,
()
=>
{
it
(
'should allow passing a custom Babel preset'
,
()
=>
{
const
code
=
trim
`
const [, b, c] = [...[1,2,3]];
({a}) => a;
`
const
output
=
babel
(
code
,
true
,
{
'preset-env'
:
{
targets
:
{
esmodules
:
true
,
},
},
// our modern preset is no preset at all
'experimental-modern-preset'
:
()
=>
({}),
})
expect
(
output
).
toMatch
(
trim
`
const[,b,c]=[...[1,2,3]];({a})=>a;
`
)
})
})
describe
(
'respect preset-react runtime'
,
()
=>
{
describe
(
'respect preset-react runtime'
,
()
=>
{
it
(
'should allow forcing on automatic mode'
,
()
=>
{
it
(
'should allow forcing on automatic mode'
,
()
=>
{
const
code
=
trim
`const a = ()=><a href="/">home</a>`
const
code
=
trim
`const a = ()=><a href="/">home</a>`
...
...
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