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

extension: allow use of ES2018 features #5377

Merged
merged 9 commits into from
Jun 8, 2018
Merged

Conversation

patrickhulce
Copy link
Collaborator

Related Issues/PRs
closes #5152

@patrickhulce
Copy link
Collaborator Author

alright @paulirish @brendankenny, bring it on!

come at me bro

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to say can we file an issue/PR on astw, but looks like that's already been done: https://github.com/substack/astw/pull/14 :(

Interesting that @paulirish's comment isn't what we actually went with. So one last iteration on this: should we just do that and use that branch (maybe to the exact commit instead of just the branch)? It would let us specify the ecmaVersion (and even version of acorn) as an option at that point.

@patrickhulce
Copy link
Collaborator Author

Interesting that @paulirish's comment isn't what we actually went with.

heh, paul just bumped us to 2.2.0 instead but seems like that goto-bus-stop's fork is really what we wanted :)

should we just do that and use that branch (maybe to the exact commit instead of just the branch)? It would let us specify the ecmaVersion (and even version of acorn) as an option at that point.

I have a ever so slight preference for not relying on a particular github user's fork and doing the hack patch ourselves, but if you and @paulirish would prefer that resolutions fix, that WFM 👍

@@ -185,8 +185,7 @@ class OptimizedImages extends Gatherer {
}

/** @type {LH.Artifacts.OptimizedImage} */
// @ts-ignore TODO(bckenny): fix browserify/Object.spread. See https://github.com/GoogleChrome/lighthouse/issues/5152
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget about line 202 - 203

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch thanks @underbyte! :)


const fs = require('fs');
// HACK: patch astw before it's required to use acorn with ES2018
// see https://github.com/GoogleChrome/lighthouse/issues/5152
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add expand this comment some more? also note the resolution addition in package.json and the new acorn in devDeps

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const astwPath = require.resolve('astw/index.js');
const astwOriginalContent = fs.readFileSync(astwPath, 'utf8');
const astwPatchedContent = astwOriginalContent
.replace(/ecmaVersion: .* 8,/, 'ecmaVersion: 2018,')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

straight text match since we dont plan on making this be flexible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const astwOriginalContent = fs.readFileSync(astwPath, 'utf8');
const astwPatchedContent = astwOriginalContent
.replace(/ecmaVersion: .* 8,/, 'ecmaVersion: 2018,')
.replace(/require\('acorn'\)/, `require(${JSON.stringify(acornPath)})`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string match since we dont need it global

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -7,9 +7,11 @@
"scripts": {
"watch": "gulp watch",
"build": "gulp build:production",
"debug-build": "node --inspect-brk ./node_modules/.bin/gulp build:production",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure but imo ndb gulp build is the besttt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it is, but seeing as the only ndb I have access to is 7 years old https://www.npmjs.com/package/ndb us pleebs have to make due with this 😛

@patrickhulce patrickhulce merged commit e02d517 into master Jun 8, 2018
@patrickhulce patrickhulce deleted the browserify_spread branch June 8, 2018 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix browserify to support Object spread/rest across all files
4 participants