diff --git a/lighthouse-extension/gulpfile.js b/lighthouse-extension/gulpfile.js index ace721e2526c..92d877585427 100644 --- a/lighthouse-extension/gulpfile.js +++ b/lighthouse-extension/gulpfile.js @@ -22,9 +22,12 @@ const pkg = require('../package.json'); const distDir = 'dist'; // HACK: patch astw, see https://github.com/GoogleChrome/lighthouse/issues/5152 +const acornPath = require.resolve('acorn'); const ASTW_PATH = require.resolve('astw/index.js'); const astwOriginalContent = fs.readFileSync(ASTW_PATH, 'utf8'); -const astwPatchedContent = astwOriginalContent.replace(/ecmaVersion: .* 8,/, 'ecmaVersion: 2018,'); +const astwPatchedContent = astwOriginalContent + .replace(/ecmaVersion: .* 8,/, 'ecmaVersion: 2018,') + .replace(/require\('acorn'\)/, `require("${acornPath}")`); fs.writeFileSync(ASTW_PATH, astwPatchedContent); const VERSION = pkg.version;