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 support #268

Closed
sindresorhus opened this issue Sep 11, 2013 · 4 comments · Fixed by #420
Closed

Browserify support #268

sindresorhus opened this issue Sep 11, 2013 · 4 comments · Fixed by #420

Comments

@sindresorhus
Copy link
Contributor

It would be useful if Cheerio could be browserified (or even better, offered an official browserified build). I need it for Titanium, but it could also be useful in Web Workers and any other non-browser/node JS platform. Seeing as Cheerio is mostly a string manipulations library it should be possible.

I had to do a few changes to Cheerio to get it running (i used brfs to inline the two fs calls), but I'm having issues with it not persisting any of the changes.

Testcase (gist) (open console)

^ It doesn't change the text.

fb55 added a commit to fb55/css-select that referenced this issue Sep 11, 2013
@fb55
Copy link
Member

fb55 commented Sep 11, 2013

Okay, we've got multiple problems:

First of all, I opened fb55/entities#12, which will cover the entity support.

Next, cheerio should, as discussed before, remove the wrapper around CSSselect. There is no reason to keep it, and it causes problems in this case.

Finally, the API import is still problematic; it should probably be changed in cheerio. (It would be awesome if browserify would support ['mod1', 'mod2', 'mod3'].map(require) chains, so we could remove at least a bit of the overhead.)

As far as the functionality is concerned: I recently played with using CSSselect for querying the browser DOM, and left the replacement in the package.json. As a result, it found no elements. This is fixed now; I'll publish a new version soon, which will contain the fix.

FYI, you can load your browserified cheerio version in jsconsole, which is much better for playing with it :)

@matthewmueller
Copy link
Member

@sindresorhus the web workers is a good point.

My personal preference for package managers is to use component, which I believe is compatible with browserify using a repository field in the component.json, so I think we should start from there.

@sindresorhus
Copy link
Contributor Author

Next, cheerio should, as discussed before, remove the wrapper around CSSselect. There is no reason to keep it, and it causes problems in this case.

@matthewmueller any reason to keep it around?

Finally, the API import is still problematic; it should probably be changed in cheerio. (It would be awesome if browserify would support ['mod1', 'mod2', 'mod3'].map(require) chains, so we could remove at least a bit of the overhead.)

Shouldn't be too bad manually requiring them for now.

FYI, you can load your browserified cheerio version in jsconsole, which is much better for playing with it :)

Nice, didn't know about that one :)

kirbysayshi added a commit to kirbysayshi/cheerio that referenced this issue Dec 19, 2013
Simple fix to get around the conditional require for lib-cov.
@fb55
Copy link
Member

fb55 commented Mar 22, 2014

entities shouldn't be a problem anymore. The CSSselect wrapper was removed. Now, only cheerio's require statements have to be fixed to resolve this issue.

@fb55 fb55 closed this as completed in #420 Apr 8, 2014
fb55 added a commit to fb55/css-select that referenced this issue Oct 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants