Unverified Commit a79bacca authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Remove noDirtyAmp option (#7032)

parent cf889d60
......@@ -23,7 +23,6 @@ const defaultConfig = {
},
experimental: {
amp: false,
noDirtyAmp: false,
cpus: Math.max(
1,
(Number(process.env.CIRCLE_NODE_TOTAL) ||
......
......@@ -36,7 +36,6 @@ export default class Server {
buildId: string
renderOpts: {
poweredByHeader: boolean
noDirtyAmp: boolean
ampBindInitData: boolean
staticMarkup: boolean
buildId: string
......@@ -75,7 +74,6 @@ export default class Server {
this.buildId = this.readBuildId()
this.renderOpts = {
noDirtyAmp: this.nextConfig.experimental.noDirtyAmp,
ampBindInitData: this.nextConfig.experimental.ampBindInitData,
poweredByHeader: this.nextConfig.poweredByHeader,
staticMarkup,
......
......@@ -13,18 +13,17 @@ interface IOptimizer {
interface IOptimizeOptions {
amphtml?: boolean
noDirtyAmp?: boolean
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
try {
ampOptimizer = require('amp-toolbox-optimizer')
} catch (_) {
return html
}
const validAmp = Boolean(noDirtyAmp || (amphtml && query && query.amp))
const validAmp = Boolean(amphtml && query && query.amp)
// Examples below
//
// pages/foo.js
......
......@@ -113,7 +113,6 @@ function render(
}
type RenderOpts = {
noDirtyAmp: boolean
ampBindInitData: boolean
staticMarkup: boolean
buildId: string
......@@ -228,7 +227,6 @@ export async function renderToHTML(
dev = false,
ampBindInitData = false,
staticMarkup = false,
noDirtyAmp = false,
ampPath = '',
App,
Document,
......@@ -445,7 +443,7 @@ export async function renderToHTML(
})
if (amphtml && html) {
html = await optimizeAmp(html, { amphtml, noDirtyAmp, query })
html = await optimizeAmp(html, { amphtml, query })
// don't validate dirty AMP
if (renderOpts.ampValidator && query.amp) {
......
......@@ -94,8 +94,7 @@ export default async function (dir, options, configuration) {
distDir,
dev: false,
staticMarkup: false,
hotReloader: null,
noDirtyAmp: nextConfig.experimental.noDirtyAmp
hotReloader: null
}
const { serverRuntimeConfig, publicRuntimeConfig } = nextConfig
......
......@@ -25,7 +25,6 @@ process.on(
exportPathMap,
outDir,
renderOpts,
noDirtyAmp,
serverRuntimeConfig,
concurrency
}) => {
......@@ -90,8 +89,7 @@ process.on(
await validateAmp(html, path)
}
if (
(curRenderOpts.amphtml && !query.amp && !noDirtyAmp) ||
curRenderOpts.hasAmp
(curRenderOpts.amphtml && !query.amp) || curRenderOpts.hasAmp
) {
// we need to render a clean AMP version
const ampHtmlFilename = `${ampPath}${sep}index.html`
......
......@@ -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 () => {
nextConfig.replace('// exportPathMap',
`exportPathMap: function(defaultMap) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment