-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Incompatible dynamic import in npm:* commonjs context #24329
Comments
I couldn't reproduce the issue with the latest Deno (1.44.4) and cheerio (1.0.0-rc.12)
Also your langchain example worked on my end langchain.js import { CheerioWebBaseLoader } from "npm:@langchain/community/document_loaders/web/cheerio";
const loader = new CheerioWebBaseLoader(
"https://docs.smith.langchain.com/user_guide"
);
const rawDocs = await loader.load();
console.log(rawDocs); $ deno run -A langchain.js
[
Document {
pageContent: "\n" +
'!function(){function e(e){document.documentElement.setAttribute("data-theme",e)}var t=function(){var e=null;try{e=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(e){}return e}()||function(){var e=null;try{e=localStorage.getItem("theme")}catch(e){}return e}();null!==t?e(t):window.matchMedia("(prefers-color-scheme: dark)").matches?e("dark"):(window.matchMedia("(prefers-color-scheme: light)").matches,e("light"))}()\n' +
... What happens if you clear What package manager do you use for downloading npm packages? |
The exact same issue happens when using cheerio 0.22.0 with Node ESM:
To fix this issue, specify the 1.0.0-rc.12 version of cherio in a package.json (the latest tag, what langchain has a peer dep on) or add the following import: import "npm:[email protected]";
import { CheerioWebBaseLoader } from "npm:@langchain/[email protected]/document_loaders/web/cheerio";
const loader = new CheerioWebBaseLoader(
"https://docs.smith.langchain.com/user_guide"
);
const rawDocs = await loader.load(); It would be nice if Deno would error for conflicting peer dependencies. |
Version: Deno 1.44.4
Description
The result of dynamic import to type:commonjs is different between Node and Deno.
It may cause commonjs context's dynamic import.
The following issue is similar, but since this is a user-controlled code called next.config.js, it may be controversial, but since npm: protocol and below should be required to be compatible with node, this should be a Deno incompatibility.
#21149
Reproduce
This is langchain.js sample code.
Error Log
Error Reason
https://github.com/langchain-ai/langchainjs/blob/main/libs/langchain-community/src/document_loaders/web/cheerio.ts#L158
Deno's result.
Node CommonJS's result
Node ESM's dynamic import
cheerio's package.json
https://github.com/cheeriojs/cheerio/blob/main/package.json#L29-L40
The text was updated successfully, but these errors were encountered: