esm-dev / esm.sh

A fast, smart, & global CDN for modern(es2015+) web development.
https://esm.sh
MIT License
3.07k stars 147 forks source link

Failed to run - ipfs-core & helia due to {current throwing dependency} #562

Open jcc10 opened 1 year ago

jcc10 commented 1 year ago

IPFS

This is the one I eventually want to use... Eventually.

Current throwing dep: undici

This is the one I eventually want to use... Eventually.

import { request as undiciRequest} from "http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs";

Error message

After running deno run I got this:

✅ Granted all env access.
error: Uncaught TypeError: Class extends value undefined is not a constructor or null
    at http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs:3:16310
    at http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs:2:2114
    at http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs:5:374
    at http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs:2:2114
    at http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs:5:3554
    at http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs:2:2114
    at http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs:45:8659
    at http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs:2:2114
    at http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs:45:77525
    at http://127.0.0.1:8080/v113/undici@5.21.0/deno/undici.mjs:2:2114

Additional info

jcc10 commented 1 year ago

I'm gonna start to work on helia (the "successor" to IPFS-core) while this one is stewing.

jcc10 commented 1 year ago

So... turns out helia also relies on default-gateway. So that's neat.

561 is also required for helia to work.

jcc10 commented 1 year ago

Manual edit of

x=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,s)=>(typeof require<"u"?require:r)[s]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});

to

x=(x=>{return import(x)});

Fixed the issue, though I'm not sure if this is really feasible to fix here or if it should be fixed in the module... I'll look into it.

Opening new issue for the next roadblock I found.

ije commented 1 year ago

does https://github.com/esm-dev/esm.sh/pull/561 fix this?

jcc10 commented 1 year ago

Sorry for spam but it turns out that it is just a normal dynamic require on the side of default-gateway, so this is actually something in the transpiler pipeline.

Had I done a bit more searching I would have found #368 which is the same error.

It looks like this is a problem in esbuild itself as it has bug reports of this message.

It may need to be a regex rewrite where if a module is flagged as having a dynamic require it gets the require statement overwritten with a dynamic import. However this would also effect code maps so that should be taken into account.

561 does not fix this but is required to get far enough for this error to occur. (and once this error is fixed there is at least one more after it.)

ije commented 1 year ago

i see, i will look into it. thanks !

ije commented 1 year ago
Screenshot 2023-03-24 at 06 14 36

comfirms your PR #561 fixed xml2js and netmask deps, i am looking into default-gateway problem

ije commented 1 year ago
Screenshot 2023-03-24 at 18 14 47

after some dig-in works, i found there is a dynamic require in this package

ije commented 1 year ago

damn, the deps of ipfs is so crazy....

ije commented 1 year ago

trying to fix @achingbrain/nat-port-mapper which actually throws the Dynamic require and createRequire only supports errors

ije commented 1 year ago
Screenshot 2023-03-24 at 22 05 07

i gave up, seems ipfs-core is not compatible with deno

jcc10 commented 1 year ago

I'll take a look at the work you did and try to continue it.

jcc10 commented 1 year ago

Current error is with undici that seems to be some unknown class it's trying to extend. Doing research now.

jcc10 commented 1 year ago

Is there a option for non-minified files? Or does anyone know a way to view code with a source map?

If no one has any good ideas I'm gonna have to build my own.

ije commented 1 year ago

Is there a option for non-minified files? Or does anyone know a way to view code with a source map?

If no one has any good ideas I'm gonna have to build my own.

use ?dev

jcc10 commented 1 year ago

SNIP: Moved to a new bug for tracking, once that is done will continue working here.