Skip to content

Commit a76ae9a

Browse files
committed
Ignore AMP errors caused by React (for now)
1 parent 435eb5f commit a76ae9a

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

packages/next/src/export/routes/pages.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,40 @@ export async function exportPagesPage(
138138
) => {
139139
const validator = await getAmpValidatorInstance(validatorPath)
140140
const result = validator.validateString(rawAmpHtml)
141-
const errors = result.errors.filter((e) => e.severity === 'ERROR')
141+
const errors = result.errors.filter((error) => {
142+
if (error.severity === 'ERROR') {
143+
// Unclear yet if these actually prevent the page from being indexed by the AMP cache.
144+
// These are coming from React so all we can do is ignore them for now.
145+
146+
// <link rel="expect" blocking="render" />
147+
// https://github.com/ampproject/amphtml/issues/40279
148+
if (
149+
error.code === 'DISALLOWED_ATTR' &&
150+
error.params[0] === 'blocking' &&
151+
error.params[1] === 'link'
152+
) {
153+
return false
154+
}
155+
// <template> without type
156+
if (
157+
error.code === 'MANDATORY_ATTR_MISSING' &&
158+
error.params[0] === 'type' &&
159+
error.params[1] === 'template'
160+
) {
161+
return false
162+
}
163+
// <template> without type
164+
if (
165+
error.code === 'MISSING_REQUIRED_EXTENSION' &&
166+
error.params[0] === 'template' &&
167+
error.params[1] === 'amp-mustache'
168+
) {
169+
return false
170+
}
171+
return true
172+
}
173+
return false
174+
})
142175
const warnings = result.errors.filter((e) => e.severity !== 'ERROR')
143176

144177
if (warnings.length || errors.length) {

0 commit comments

Comments
 (0)