Summary
Lighthouse's keeping up with latest LTS is starting to bump into outdated browserify deps. This issue tracks solving them without the need for workarounds, but also documents how to solve them.
Workarounds
In #12129 I bumped into two scenarios where browserify fails with relatively cryptic error messages that took a fair bit of time to decipher, so capturing here in case others run into them too.
Error: Parsing file file.js: visitor[(override || node.type)] is not a function
class MyClass {
instanceField = require('./some-dependency.js').someValue
}
Fix
Move the require outside of the instance field definition.
const someValue = require('./some-dependency.js').someValue;
class MyClass {
instanceField = someValue;
}
TypeError: baseVisitor[type] is not a function while parsing file
const someContent = fs.readFileSync('../path/to/file.js');
class MyClass {
instanceField = 1;
}
/** @type {string} */
// @ts-ignore
const x = 1;
class MyClass {
instanceField = 1;
}
Fix
Revert back to older constructor assignment
Summary
Lighthouse's keeping up with latest LTS is starting to bump into outdated browserify deps. This issue tracks solving them without the need for workarounds, but also documents how to solve them.
Workarounds
In #12129 I bumped into two scenarios where browserify fails with relatively cryptic error messages that took a fair bit of time to decipher, so capturing here in case others run into them too.
Error: Parsing file file.js: visitor[(override || node.type)] is not a functionFix
Move the require outside of the instance field definition.
TypeError: baseVisitor[type] is not a function while parsing fileFix
Revert back to older
constructorassignment