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 = { ...@@ -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) ||
......
...@@ -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,
......
...@@ -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
......
...@@ -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) {
......
...@@ -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
......
...@@ -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`
......
...@@ -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) {
......
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