cheerio
cheerio copied to clipboard
ESM build fails with import from '.'
The lib/esm/static.d.ts file in the (currently) latest version (1.0.0-rc.12) defines:
import type { CheerioAPI, Cheerio } from '.';
This causes ESM projects that use cheerio to fail to build as the import should be ... from './index.js
Error:
../../common/temp/node_modules/.pnpm/[email protected]/node_modules/cheerio/lib/esm/static.d.ts:2:42 - error TS2307: Cannot find module '.' or its corresponding type declarations.
2 import type { CheerioAPI, Cheerio } from '.';
~~~
Found 1 error in ../../common/temp/node_modules/.pnpm/[email protected]/node_modules/cheerio/lib/esm/static.d.ts:2
This is linked with issue #2774. This is fixed in the source files but has not been released yet. I can confirm setting skipLibCheck to true in tsconfig.json resolves this issue for now.
I just came across the same issue. Another work-around is to manually patch the file inside node_modules and change '.' to './index.js'.
Fixed with the 1.0 release!