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
d61eced9
Unverified
Commit
d61eced9
authored
Apr 01, 2020
by
JJ Kasper
Committed by
GitHub
Apr 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to make sure AMP only bundles are always removed in pro… (#11527)
parent
fa5da6d2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
1 deletion
+30
-1
index.ts
packages/next/build/index.ts
+19
-0
utils.ts
packages/next/build/utils.ts
+2
-0
another-amp.js
test/integration/amphtml/pages/another-amp.js
+8
-0
index.test.js
test/integration/amphtml/test/index.test.js
+1
-1
No files found.
packages/next/build/index.ts
View file @
d61eced9
...
...
@@ -547,6 +547,25 @@ export default async function build(dir: string, conf = null): Promise<void> {
hybridAmpPages
.
add
(
page
)
}
if
(
result
.
isAmpOnly
)
{
// ensure all AMP only bundles got removed
try
{
await
fsUnlink
(
path
.
join
(
distDir
,
'static'
,
buildId
,
'pages'
,
actualPage
+
'.js'
)
)
}
catch
(
err
)
{
if
(
err
.
code
!==
'ENOENT'
)
{
throw
err
}
}
}
if
(
result
.
hasStaticProps
)
{
ssgPages
.
add
(
page
)
isSsg
=
true
...
...
packages/next/build/utils.ts
View file @
d61eced9
...
...
@@ -665,6 +665,7 @@ export async function isPageStatic(
runtimeEnvConfig
:
any
):
Promise
<
{
isStatic
?:
boolean
isAmpOnly
?:
boolean
isHybridAmp
?:
boolean
hasServerProps
?:
boolean
hasStaticProps
?:
boolean
...
...
@@ -756,6 +757,7 @@ export async function isPageStatic(
return
{
isStatic
:
!
hasStaticProps
&&
!
hasGetInitialProps
&&
!
hasServerProps
,
isHybridAmp
:
config
.
amp
===
'hybrid'
,
isAmpOnly
:
config
.
amp
===
true
,
prerenderRoutes
,
prerenderFallback
,
hasStaticProps
,
...
...
test/integration/amphtml/pages/another-amp.js
0 → 100644
View file @
d61eced9
import
{
useAmp
}
from
'next/amp'
const
config
=
{
amp
:
true
,
}
export
default
()
=>
(
useAmp
()
?
'AMP mode'
:
'Normal mode'
)
export
{
config
}
test/integration/amphtml/test/index.test.js
View file @
d61eced9
...
...
@@ -66,7 +66,7 @@ describe('AMP Usage', () => {
it
(
'should not output client pages for AMP only'
,
async
()
=>
{
const
buildId
=
readFileSync
(
join
(
appDir
,
'.next/BUILD_ID'
),
'utf8'
)
const
ampOnly
=
[
'only-amp'
,
'root-hmr'
]
const
ampOnly
=
[
'only-amp'
,
'root-hmr'
,
'another-amp'
]
for
(
const
pg
of
ampOnly
)
{
expect
(()
=>
accessSync
(
join
(
appDir
,
'.next/static'
,
buildId
,
'pages'
,
pg
+
'.js'
))
...
...
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