5febe218a6
This adds ncc'ing the AMP optimizer package to speed up install times and cache the runtime. Closes: https://github.com/vercel/next.js/issues/20404
13 lines
330 B
TypeScript
13 lines
330 B
TypeScript
export default async function optimize(
|
|
html: string,
|
|
config: any
|
|
): Promise<string> {
|
|
let AmpOptimizer
|
|
try {
|
|
AmpOptimizer = require('next/dist/compiled/@ampproject/toolbox-optimizer')
|
|
} catch (_) {
|
|
return html
|
|
}
|
|
const optimizer = AmpOptimizer.create(config)
|
|
return optimizer.transformHtml(html, config)
|
|
}
|