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

deps(robots-parser): patch robots-parser to work in both node and browser env #4819

Merged
merged 2 commits into from Mar 20, 2018

Conversation

kdzwinel
Copy link
Collaborator

@kdzwinel kdzwinel commented Mar 20, 2018

I've tried creating a browserify transform that replaces request('url') calls with request('path/to/url-shim.js'). It worked, but uncovered another issue - robots-parser is using url.path that doesn't exists on the web and is deprecated in node. So I decied to go with https://github.com/ds300/patch-package as suggested by @patrickhulce and @wardpeet.

Fixes #4794, but nothing will show up in the details table due to #4818

@@ -0,0 +1,36 @@
patch-package
--- a/node_modules/robots-parser/Robots.js
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

a diff of a diff 😵

@paulirish
Copy link
Member

Presumably this also needs some post install script to apply the patch?

@kdzwinel
Copy link
Collaborator Author

kdzwinel commented Mar 20, 2018

@paulirish I also thought so, but …

Patches created by patch-package are automatically and gracefully applied when you use npm(>=5) or yarn.

🕺

[EDIT] oh whoops, I guess I was too optimistic thinking that it's a build-in npm/yarn functionality - you are right, post install script is needed 😢
[EDIT] post install script added, tested by rm -rf node_modules && yarn and looking into node_modules

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM!

@wardpeet
Copy link
Collaborator

Yeah patch-package is awesome!

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.

Is there a long term path for a real fix?

@kdzwinel
Copy link
Collaborator Author

Yeah, I agree it's not perfect. I thought about opening a PR with this patch against the original repo. We can also pull that library into LH or fork it.

@patrickhulce
Copy link
Collaborator

I thought about opening a PR with this patch against the original repo

PR to have robots-parser use real URL class and switch to have us swap require('url') with our shim sounds like most reasonable long term solution to me

@paulirish
Copy link
Member

+1 to giving @samclarke a PR.
Hi Sam, big fan. :)

@kdzwinel
Copy link
Collaborator Author

Perfect, I'll open a PR👍 should I create an issue to track this?

@brendankenny
Copy link
Member

PR to have robots-parser use real URL class and switch to have us swap require('url') with our shim sounds like most reasonable long term solution to me

SGreatTM

@brendankenny
Copy link
Member

should I create an issue to track this?

that SG too

@kdzwinel
Copy link
Collaborator Author

Issue created (#4825) 👌

@paulirish paulirish merged commit 5192079 into GoogleChrome:master Mar 20, 2018
@kdzwinel kdzwinel deleted the liburl-parse-error-fix branch March 20, 2018 21:57
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.

None yet

6 participants