jshemas / openGraphScraper

Node.js scraper service for Open Graph Info and More!
MIT License
643 stars 102 forks source link

Package is not exporting a proper types for ESM, unable to use with typescript set to NodeNext module and module resolution. #224

Closed michalkvasnicak closed 1 week ago

michalkvasnicak commented 3 weeks ago

Describe the bug

Package does not have correct typings. When you set typescript to "module": "NodeNext", "moduleResolution": "NodeNext" it fails to compile.

To Reproduce Steps to reproduce the behavior:

https://stackblitz.com/edit/vitejs-vite-dj4sv9?file=src%2Findex.ts

Expected behavior

Should import the package without any issues.

Actual behavior

Fails with an error:

Type 'typeof import("stackblitz:/node_modules/open-graph-scraper/dist/index")' has no call signatures.(2349)

Additional context

jshemas commented 3 weeks ago

Okay, i'm able to see the issue now locally.

I still see the error even if I build a dist for ESM, so I will need to dig into some more. In the meantime you can use ogs.default(); to fix the issue.

jshemas commented 1 week ago

Hello,

This should be fixed in open-graph-scraper@6.6.0. I was able to get your code example working with my new build.

image

jshemas commented 1 week ago

Closing this for now. Please open a new issue if you have any other problems.