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
a79bacca
Unverified
Commit
a79bacca
authored
Apr 15, 2019
by
JJ Kasper
Committed by
GitHub
Apr 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove noDirtyAmp option (#7032)
parent
cf889d60
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
5 additions
and
31 deletions
+5
-31
config.js
packages/next-server/server/config.js
+0
-1
next-server.ts
packages/next-server/server/next-server.ts
+0
-2
optimize-amp.ts
packages/next-server/server/optimize-amp.ts
+2
-3
render.tsx
packages/next-server/server/render.tsx
+1
-3
index.js
packages/next/export/index.js
+1
-2
worker.js
packages/next/export/worker.js
+1
-3
index.test.js
test/integration/amp-export-validation/test/index.test.js
+0
-17
No files found.
packages/next-server/server/config.js
View file @
a79bacca
...
@@ -23,7 +23,6 @@ const defaultConfig = {
...
@@ -23,7 +23,6 @@ const defaultConfig = {
},
},
experimental
:
{
experimental
:
{
amp
:
false
,
amp
:
false
,
noDirtyAmp
:
false
,
cpus
:
Math
.
max
(
cpus
:
Math
.
max
(
1
,
1
,
(
Number
(
process
.
env
.
CIRCLE_NODE_TOTAL
)
||
(
Number
(
process
.
env
.
CIRCLE_NODE_TOTAL
)
||
...
...
packages/next-server/server/next-server.ts
View file @
a79bacca
...
@@ -36,7 +36,6 @@ export default class Server {
...
@@ -36,7 +36,6 @@ export default class Server {
buildId
:
string
buildId
:
string
renderOpts
:
{
renderOpts
:
{
poweredByHeader
:
boolean
poweredByHeader
:
boolean
noDirtyAmp
:
boolean
ampBindInitData
:
boolean
ampBindInitData
:
boolean
staticMarkup
:
boolean
staticMarkup
:
boolean
buildId
:
string
buildId
:
string
...
@@ -75,7 +74,6 @@ export default class Server {
...
@@ -75,7 +74,6 @@ export default class Server {
this
.
buildId
=
this
.
readBuildId
()
this
.
buildId
=
this
.
readBuildId
()
this
.
renderOpts
=
{
this
.
renderOpts
=
{
noDirtyAmp
:
this
.
nextConfig
.
experimental
.
noDirtyAmp
,
ampBindInitData
:
this
.
nextConfig
.
experimental
.
ampBindInitData
,
ampBindInitData
:
this
.
nextConfig
.
experimental
.
ampBindInitData
,
poweredByHeader
:
this
.
nextConfig
.
poweredByHeader
,
poweredByHeader
:
this
.
nextConfig
.
poweredByHeader
,
staticMarkup
,
staticMarkup
,
...
...
packages/next-server/server/optimize-amp.ts
View file @
a79bacca
...
@@ -13,18 +13,17 @@ interface IOptimizer {
...
@@ -13,18 +13,17 @@ interface IOptimizer {
interface
IOptimizeOptions
{
interface
IOptimizeOptions
{
amphtml
?:
boolean
amphtml
?:
boolean
noDirtyAmp
?:
boolean
query
?:
ParsedUrlQuery
query
?:
ParsedUrlQuery
}
}
export
default
async
function
optimize
(
html
:
string
,
{
amphtml
,
noDirtyAmp
,
query
}:
IOptimizeOptions
):
Promise
<
string
>
{
export
default
async
function
optimize
(
html
:
string
,
{
amphtml
,
query
}:
IOptimizeOptions
):
Promise
<
string
>
{
let
ampOptimizer
:
IOptimizer
let
ampOptimizer
:
IOptimizer
try
{
try
{
ampOptimizer
=
require
(
'amp-toolbox-optimizer'
)
ampOptimizer
=
require
(
'amp-toolbox-optimizer'
)
}
catch
(
_
)
{
}
catch
(
_
)
{
return
html
return
html
}
}
const
validAmp
=
Boolean
(
noDirtyAmp
||
(
amphtml
&&
query
&&
query
.
amp
)
)
const
validAmp
=
Boolean
(
amphtml
&&
query
&&
query
.
amp
)
// Examples below
// Examples below
//
//
// pages/foo.js
// pages/foo.js
...
...
packages/next-server/server/render.tsx
View file @
a79bacca
...
@@ -113,7 +113,6 @@ function render(
...
@@ -113,7 +113,6 @@ function render(
}
}
type
RenderOpts
=
{
type
RenderOpts
=
{
noDirtyAmp
:
boolean
ampBindInitData
:
boolean
ampBindInitData
:
boolean
staticMarkup
:
boolean
staticMarkup
:
boolean
buildId
:
string
buildId
:
string
...
@@ -228,7 +227,6 @@ export async function renderToHTML(
...
@@ -228,7 +227,6 @@ export async function renderToHTML(
dev
=
false
,
dev
=
false
,
ampBindInitData
=
false
,
ampBindInitData
=
false
,
staticMarkup
=
false
,
staticMarkup
=
false
,
noDirtyAmp
=
false
,
ampPath
=
''
,
ampPath
=
''
,
App
,
App
,
Document
,
Document
,
...
@@ -445,7 +443,7 @@ export async function renderToHTML(
...
@@ -445,7 +443,7 @@ export async function renderToHTML(
})
})
if
(
amphtml
&&
html
)
{
if
(
amphtml
&&
html
)
{
html
=
await
optimizeAmp
(
html
,
{
amphtml
,
noDirtyAmp
,
query
})
html
=
await
optimizeAmp
(
html
,
{
amphtml
,
query
})
// don't validate dirty AMP
// don't validate dirty AMP
if
(
renderOpts
.
ampValidator
&&
query
.
amp
)
{
if
(
renderOpts
.
ampValidator
&&
query
.
amp
)
{
...
...
packages/next/export/index.js
View file @
a79bacca
...
@@ -94,8 +94,7 @@ export default async function (dir, options, configuration) {
...
@@ -94,8 +94,7 @@ export default async function (dir, options, configuration) {
distDir
,
distDir
,
dev
:
false
,
dev
:
false
,
staticMarkup
:
false
,
staticMarkup
:
false
,
hotReloader
:
null
,
hotReloader
:
null
noDirtyAmp
:
nextConfig
.
experimental
.
noDirtyAmp
}
}
const
{
serverRuntimeConfig
,
publicRuntimeConfig
}
=
nextConfig
const
{
serverRuntimeConfig
,
publicRuntimeConfig
}
=
nextConfig
...
...
packages/next/export/worker.js
View file @
a79bacca
...
@@ -25,7 +25,6 @@ process.on(
...
@@ -25,7 +25,6 @@ process.on(
exportPathMap
,
exportPathMap
,
outDir
,
outDir
,
renderOpts
,
renderOpts
,
noDirtyAmp
,
serverRuntimeConfig
,
serverRuntimeConfig
,
concurrency
concurrency
})
=>
{
})
=>
{
...
@@ -90,8 +89,7 @@ process.on(
...
@@ -90,8 +89,7 @@ process.on(
await
validateAmp
(
html
,
path
)
await
validateAmp
(
html
,
path
)
}
}
if
(
if
(
(
curRenderOpts
.
amphtml
&&
!
query
.
amp
&&
!
noDirtyAmp
)
||
(
curRenderOpts
.
amphtml
&&
!
query
.
amp
)
||
curRenderOpts
.
hasAmp
curRenderOpts
.
hasAmp
)
{
)
{
// we need to render a clean AMP version
// we need to render a clean AMP version
const
ampHtmlFilename
=
`
${
ampPath
}${
sep
}
index.html`
const
ampHtmlFilename
=
`
${
ampPath
}${
sep
}
index.html`
...
...
test/integration/amp-export-validation/test/index.test.js
View file @
a79bacca
...
@@ -34,23 +34,6 @@ describe('AMP Validation on Export', () => {
...
@@ -34,23 +34,6 @@ describe('AMP Validation on Export', () => {
}))
}))
})
})
it
(
'should disable dirty AMP with noDirtyAmp set'
,
async
()
=>
{
nextConfig
.
replace
(
/experimental:
[\w\W]
*
?
}/
,
`
experimental: {
amp: true,
noDirtyAmp: true
}
`
)
await
nextExport
(
appDir
,
{
outdir
:
outDir
})
const
ampOnly
=
[
'first'
,
'second'
,
'third'
]
await
Promise
.
all
(
ampOnly
.
map
(
async
page
=>
{
const
html
=
await
readFile
(
join
(
outDir
,
`
${
page
+
(
page
===
'third'
?
'.amp'
:
''
)}
/index.html`
))
await
validateAMP
(
html
.
toString
())
}))
nextConfig
.
restore
()
})
it
(
'shows AMP warning without throwing error'
,
async
()
=>
{
it
(
'shows AMP warning without throwing error'
,
async
()
=>
{
nextConfig
.
replace
(
'// exportPathMap'
,
nextConfig
.
replace
(
'// exportPathMap'
,
`exportPathMap: function(defaultMap) {
`exportPathMap: function(defaultMap) {
...
...
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