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
abcaba7f
Unverified
Commit
abcaba7f
authored
Aug 05, 2019
by
Lukáš Huvar
Committed by
GitHub
Aug 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add warning for API export (#8250)
parent
b31c2967
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
index.js
packages/next/export/index.js
+16
-1
index.test.js
test/integration/api-support/test/index.test.js
+12
-0
No files found.
packages/next/export/index.js
View file @
abcaba7f
...
...
@@ -19,6 +19,7 @@ import {
import
createProgress
from
'tty-aware-progress'
import
{
promisify
}
from
'util'
import
{
recursiveDelete
}
from
'../lib/recursive-delete'
import
{
API_ROUTE
}
from
'../lib/constants'
import
{
formatAmpMessages
}
from
'../build/output/index'
const
mkdirp
=
promisify
(
mkdirpModule
)
...
...
@@ -35,6 +36,7 @@ export default async function (dir, options, configuration) {
const
threads
=
options
.
threads
||
Math
.
max
(
cpus
().
length
-
1
,
1
)
const
distDir
=
join
(
dir
,
nextConfig
.
distDir
)
const
subFolders
=
nextConfig
.
exportTrailingSlash
let
apiPage
=
false
if
(
!
options
.
buildExport
&&
nextConfig
.
target
!==
'server'
)
{
throw
new
Error
(
...
...
@@ -60,7 +62,20 @@ export default async function (dir, options, configuration) {
for
(
const
page
of
pages
)
{
// _document and _app are not real pages
// _error is exported as 404.html later on
if
(
page
===
'/_document'
||
page
===
'/_app'
||
page
===
'/_error'
)
{
const
isApiRoute
=
page
.
match
(
API_ROUTE
)
// Warn about API pages export
if
(
isApiRoute
&&
!
apiPage
)
{
apiPage
=
true
log
(
` API pages are not supported in export`
)
}
if
(
page
===
'/_document'
||
page
===
'/_app'
||
page
===
'/_error'
||
isApiRoute
)
{
continue
}
...
...
test/integration/api-support/test/index.test.js
View file @
abcaba7f
...
...
@@ -10,6 +10,7 @@ import {
renderViaHTTP
,
nextBuild
,
nextStart
,
runNextCommand
,
File
}
from
'next-test-utils'
import
json
from
'../big.json'
...
...
@@ -285,6 +286,17 @@ function runTests (serverless = false) {
}
})
if
(
!
serverless
)
{
it
(
'should warn about API export'
,
async
()
=>
{
const
{
stdout
}
=
await
runNextCommand
([
'export'
,
appDir
],
{
stdout
:
true
,
stderr
:
true
})
expect
(
stdout
).
toContain
(
'API pages are not supported in export'
)
})
}
it
(
'should return data on dynamic optional nested route'
,
async
()
=>
{
const
data
=
await
fetchViaHTTP
(
appPort
,
...
...
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