Skip to content
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

Failed to import - webtorrent #450

Closed
ThaUnknown opened this issue Nov 11, 2022 · 10 comments
Closed

Failed to import - webtorrent #450

ThaUnknown opened this issue Nov 11, 2022 · 10 comments
Labels
browser Not working in Browser

Comments

@ThaUnknown
Copy link
Contributor

Failing module

import WebTorrent from 'https://esm.sh/webtorrent'

Error message

After onload I got this:

GET https://esm.sh/error.js?type=unsupported-nodejs-builtin-module&name=dgram&importer=bittorrent-lsd net::ERR_ABORTED 500
Uncaught TypeError: Failed to fetch dynamically imported module: https://esm.sh/webtorrent
k-rpc-socket.js:2          GET https://esm.sh/error.js?type=unsupported-nodejs-builtin-module&name=dgram&importer=k-rpc-socket net::ERR_ABORTED 500
k-rpc-socket.js:2          GET https://esm.sh/error.js?type=unsupported-nodejs-builtin-module&name=dns&importer=k-rpc-socket net::ERR_ABORTED 500

Additional info

  • esm.sh version: 98
  • Browser version: Chromium: 107.0.5304.110
@ThaUnknown ThaUnknown added the browser Not working in Browser label Nov 11, 2022
@ije
Copy link
Member

ije commented Nov 12, 2022

torrent uses UDP socket that can not work in browser

@ije ije closed this as completed Nov 12, 2022
@ThaUnknown
Copy link
Contributor Author

torrent uses UDP socket that can not work in browser

which in the packages browser field is resolved to false, browserfiy handed webtorrent just fine

@ThaUnknown
Copy link
Contributor Author

@ije
Copy link
Member

ije commented Nov 12, 2022

thanks, currently esm.sh doesn't respect browser defines in package.json. i will fix this asap!

@ije ije reopened this Nov 12, 2022
@ThaUnknown
Copy link
Contributor Author

ThaUnknown commented Nov 12, 2022

thanks, currently esm.sh doesn't respect browser defines in package.json. i will fix this asap!

also its sub dependencies, also browserify allowed custom fields like in the link above "chromeapp" so I guess we'd need a buildflag like target, something like

import WebTorrent from 'https://esm.sh/webtorrent?target=deno'
import WebTorrent from 'https://esm.sh/webtorrent?target=browser'
import WebTorrent from 'https://esm.sh/webtorrent?target=chromeapp'
import WebTorrent from 'https://esm.sh/webtorrent?target=customfield'

?

@ThaUnknown
Copy link
Contributor Author

@ije is there any ETA from this? I understand that the browser field is already resolved and import aliases are already implemented in other places, seems like after v100 this only encountered more issues:

GET https://esm.sh/error.js?type=unsupported-nodejs-builtin-module&name=dgram&importer=bittorrent-lsd net::ERR_ABORTED 500
Uncaught TypeError: Failed to fetch dynamically imported module: https://esm.sh/webtorrent@1.9.6
simple-get.js:2          GET https://esm.sh/v100/https-browserify@1.0.0/es2022/https-browserify.bundle.js net::ERR_ABORTED 502
simple-get.js:2          GET https://esm.sh/v100/url@0.11.0/es2022/url.bundle.js net::ERR_ABORTED 502
simple-get.js:2          GET https://esm.sh/v100/stream-http@3.2.0/es2022/stream-http.bundle.js net::ERR_ABORTED 502
load-ip-set.js:2          GET https://esm.sh/v100/browserify-zlib@0.2.0/es2022/browserify-zlib.bundle.js net::ERR_ABORTED 502
bittorrent-protocol.js:2          GET https://esm.sh/v100/crypto-browserify@3.12.0/es2022/crypto-browserify.bundle.js net::ERR_ABORTED 502
webtorrent.js:2          GET https://esm.sh/v100/stream-browserify@3.0.0/es2022/stream-browserify.bundle.js net::ERR_ABORTED 502

@ThaUnknown
Copy link
Contributor Author

@ije v101 now has less errors or more like different ones, seems like the v101 prefix isn't getting embedded on polyfills?

bittorrent-lsd.js:2          GET https://esm.sh/error.js?type=unsupported-nodejs-builtin-module&name=dgram&importer=bittorrent-lsd net::ERR_ABORTED 500
Uncaught TypeError: Failed to fetch dynamically imported module: https://esm.sh/v101/webtorrent@1.9.6
crypto-browserify.bundle.js:1          GET https://esm.sh/string_decoder@1.3.0/es2022/string_decoder.bundle.js net::ERR_ABORTED 500
crypto-browserify.bundle.js:1          GET https://esm.sh/events@3.3.0/es2022/events.bundle.js net::ERR_ABORTED 500
crypto-browserify.bundle.js:1          GET https://esm.sh/util@0.12.5/es2022/util.bundle.js net::ERR_ABORTED 500
crypto-browserify.bundle.js:1          GET https://esm.sh/crypto-browserify@3.12.0/es2022/crypto-browserify.bundle.js net::ERR_ABORTED 500
crypto-browserify.bundle.js:1          

@ThaUnknown
Copy link
Contributor Author

ThaUnknown commented Dec 27, 2022

@ije v101 now has the same errors, seems like the v101 prefix isn't getting embedded on polyfills?

bittorrent-lsd.js:2          GET https://esm.sh/error.js?type=unsupported-nodejs-builtin-module&name=dgram&importer=bittorrent-lsd net::ERR_ABORTED 500
Uncaught TypeError: Failed to fetch dynamically imported module: https://esm.sh/v101/webtorrent@1.9.6
crypto-browserify.bundle.js:1          GET https://esm.sh/string_decoder@1.3.0/es2022/string_decoder.bundle.js net::ERR_ABORTED 500
crypto-browserify.bundle.js:1          GET https://esm.sh/events@3.3.0/es2022/events.bundle.js net::ERR_ABORTED 500
crypto-browserify.bundle.js:1          GET https://esm.sh/util@0.12.5/es2022/util.bundle.js net::ERR_ABORTED 500
crypto-browserify.bundle.js:1          GET https://esm.sh/crypto-browserify@3.12.0/es2022/crypto-browserify.bundle.js net::ERR_ABORTED 500
crypto-browserify.bundle.js:1          

@ije
Copy link
Member

ije commented Dec 27, 2022

Screenshot 2022-12-28 at 00 44 36

i am working on it~

@ije ije closed this as completed in 612b9df Dec 27, 2022
@ThaUnknown
Copy link
Contributor Author

haha sick, this package is trully a stress test for this kind of bundler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser Not working in Browser
Projects
None yet
Development

No branches or pull requests

2 participants