Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browserify can't handle Node 12 language features in certain situations #12134

Closed
patrickhulce opened this issue Feb 24, 2021 · 1 comment
Closed

Comments

@patrickhulce
Copy link
Collaborator

patrickhulce commented Feb 24, 2021

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

@connorjclark
Copy link
Collaborator

we've rid of browserify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants