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

load function is marked deprecated with message saying to use function returned by load #2786

Open
mike-lang opened this issue Oct 5, 2022 · 6 comments

Comments

@mike-lang
Copy link

Hi,

I believe c370f4e marked the exported load function as deprecated in error. It looks like the documentation was simply copied from the export of a Cheerio constructor over to the load function, including a deprecation message that made sense if someone was using the constructor, but is confusing when load is used.

As an example the following code:

let $ = cheerio.load(pageHTML);

produces the following JSDoc documentation in code editors:

The default cheerio instance
@deprecated - Use the function returned by load instead.

As best I can tell, this example uses the same method of loading html as is what is shown in the project documentation.

If this was not intentional, could we update the JSDoc to remove this deprecation warning and maybe update the function description?

If it is, could the project documentation we updated to indicated what is now the preferred method of loading and parsing HTML?

@fb55
Copy link
Member

fb55 commented Oct 24, 2022

You are likely importing the default export:

import cheerio from 'cheerio';

This will import a pre-loaded instance of cheerio, which can lead to subtle bugs and issues. Instead, try

import * as cheerio from 'cheerio'

or

import { load } from 'cheerio'

Hope this helps!

@fb55 fb55 closed this as completed Oct 24, 2022
@fb55
Copy link
Member

fb55 commented Oct 24, 2022

Re-opening this as the default export should probably be removed.

@fb55 fb55 reopened this Oct 24, 2022
@sthota-fms
Copy link

Any progress on this one?

@fb55
Copy link
Member

fb55 commented Feb 23, 2023

See my response above.

@sthota-fms

This comment was marked as off-topic.

@sthota-fms

This comment was marked as off-topic.

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

No branches or pull requests

3 participants