Package: src:node-cheerio
Version: 1.2.0+~cs2.1.0-3
Severity: important
Tags: patch
User: [email protected]
Usertags: origin-ubuntu stonking ubuntu-patch

Dear Maintainer,

In node-cheerio 1.2.0, debian/patches/debian-build-adjustments.patch stripped 
the "require" export conditions from package.json and restricted tshy to 
"dialects": ["esm"]. Consequently, the package does not ship dist/commonjs, and 
attempting to load cheerio via require() fails with:

  Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in 
/usr/share/nodejs/cheerio/package.json

While upstream cheerio sets "type": "module", it is built using tshy and is 
specifically designed to provide hybrid dual CJS/ESM exports (shipping 
dist/commonjs and defining the "require" condition in package.json).

Debian's TypeScript toolchain builds the hybrid bundle cleanly via tshy without 
requiring ESM-only output. Restoring the CommonJS build preserves backward 
compatibility for all CommonJS consumers without forcing them to migrate to 
dynamic import().

This issue is also tracked in Ubuntu at:
https://bugs.launchpad.net/ubuntu/+source/node-cheerio/+bug/2169270

The patch below reverts the package.json modification in 
debian/patches/debian-build-adjustments.patch and adds .tshy/ to debian/clean:

--- a/debian/clean
+++ b/debian/clean
@@ -1,3 +1,4 @@
 cheerio-select/lib/
 dist/
 node_modules/
+.tshy/
--- a/debian/patches/debian-build-adjustments.patch
+++ b/debian/patches/debian-build-adjustments.patch
@@ -641,48 +641,3 @@
 +  },
 +  "type": "module"
  }
---- a/package.json
-+++ b/package.json
-@@ -36,10 +36,6 @@
-       "import": {
-         "types": "./dist/esm/index.d.ts",
-         "default": "./dist/esm/index.js"
--      },
--      "require": {
--        "types": "./dist/commonjs/index.d.ts",
--        "default": "./dist/commonjs/index.js"
-       }
-     },
-     "./slim": {
-@@ -50,10 +46,6 @@
-       "import": {
-         "types": "./dist/esm/slim.d.ts",
-         "default": "./dist/esm/slim.js"
--      },
--      "require": {
--        "types": "./dist/commonjs/slim.d.ts",
--        "default": "./dist/commonjs/slim.js"
-       }
-     },
-     "./utils": {
-@@ -64,10 +56,6 @@
-       "import": {
-         "types": "./dist/esm/utils.d.ts",
-         "default": "./dist/esm/utils.js"
--      },
--      "require": {
--        "types": "./dist/commonjs/utils.d.ts",
--        "default": "./dist/commonjs/utils.js"
-       }
-     },
-     "./package.json": "./package.json"
-@@ -177,6 +165,9 @@
-       "**/*.spec.ts",
-       "**/__fixtures__/*",
-       "**/__tests__/*"
-+    ],
-+    "dialects": [
-+      "esm"
-     ]
-   }
- }

-- 
Pkg-javascript-devel mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-javascript-devel

Reply via email to