cheerio icon indicating copy to clipboard operation
cheerio copied to clipboard

ESM build fails with import from '.'

Open egmacke opened this issue 2 years ago • 2 comments

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

egmacke avatar Mar 29 '23 16:03 egmacke

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.

nickmansrob avatar Mar 30 '23 19:03 nickmansrob

I just came across the same issue. Another work-around is to manually patch the file inside node_modules and change '.' to './index.js'.

rauschma avatar May 14 '24 17:05 rauschma

Fixed with the 1.0 release!

fb55 avatar Aug 09 '24 19:08 fb55