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

stream-browserify #18

Closed
wojpawlik opened this issue Jan 30, 2021 · 8 comments
Closed

stream-browserify #18

wojpawlik opened this issue Jan 30, 2021 · 8 comments

Comments

@wojpawlik
Copy link

Thank you for esm.sh, of all the things I tried this gets me the closest to running telegraf on Deno. But not close enough:

~
$ deno --version
deno 1.7.1 (release, x86_64-pc-windows-msvc)
v8 8.9.255.3
typescript 4.1.3

~
$ deno eval 'import "https://esm.sh/[email protected]?dev"'
error: Uncaught SyntaxError: The requested module '/v15/[email protected]/esnext/stream-browserify.development.js' does not provide an export named 'Readable'
import {Readable} from "/v15/[email protected]/esnext/stream-browserify.development.js";
        ~~~~~~~~
    at <anonymous> (https://cdn.esm.sh/v15/[email protected]/esnext/telegraf.development.js:1542:9)

[1] ~
$

telegraf depends on sandwich-stream, which has an .mjs entry which import { Readable } from 'stream'. This is legal:

~
$ node --version
v14.0.0

~
$ node --input-type=module --eval 'import { Readable } from "stream"'

~
$

However, stream-browserify, used by esm.sh to ponyfill stream, doesn't support it. I can open a PR, but only if @goto-bus-stop or another maintainer promises to actually review it.

Otherwise, esm.sh should switch to better maintained ponyfill, perhaps https://deno.land/std/node/stream.ts?

@goto-bus-stop
Copy link

goto-bus-stop commented Jan 30, 2021

If deno provides a stream module itself, the best option would be to exclude stream from the bundle somehow.

Alternatively, esm.sh could use the readable-stream module directly. stream-browserify uses that, but adds support for some very old Node.js APIs for backwards compatibility. That is necessary for browserify which supports many legacy projects that are many years old, but maybe not for esm.sh which (presumably) targets more modern runtimes.

@ije
Copy link
Member

ije commented Jan 30, 2021

i have a plan to provide all polyfills of nodejs internal module from deno.land/std/node/** to get better deno compatibility, currently i just added the fs polyfill since the std lib doesn't implement all of them.
FYI: https://github.com/postui/esm.sh/tree/master/third_party/polyfills

@shadowtime2000
Copy link

I believe readable stream is getting (kind of) built in Deno support from it's maintainers. Might be something to look at.

@talentlessguy
Copy link
Contributor

still happens on v47

➜ deno eval 'import "https://esm.sh/[email protected]?dev"'
Download https://cdn.esm.sh/v47/@types/node/http
Download https://cdn.esm.sh/v47/@types/node/tls
Download https://cdn.esm.sh/v47/@types/node/url
error: Uncaught SyntaxError: The requested module '/v47/[email protected]/deno/stream-browserify.development.js' does not provide an export named 'Readable'
import { Readable } from "/v47/[email protected]/deno/stream-browserify.development.js";
         ~~~~~~~~
    at <anonymous> (https://cdn.esm.sh/v47/[email protected]/deno/sandwich-stream.development.js:3:10)

@talentlessguy
Copy link
Contributor

on v50 I see this instead:

error: Uncaught TypeError: Class extends value undefined is not a constructor or null
    var MultipartStream = class extends sandwich_stream_1.default {
                                                          ^
    at ../../../../../tmp/esm-build-e948e7e0c235eccfffa26ffd75dac27c9851089e/node_modules/telegraf/lib/core/network/multipart-stream.js (http://localhost:3333/v50/[email protected]/deno/telegraf.development.js:1034:59)
    at __require2 (http://localhost:3333/v50/[email protected]/deno/telegraf.development.js:31:44)
    at ../../../../../tmp/esm-build-e948e7e0c235eccfffa26ffd75dac27c9851089e/node_modules/telegraf/lib/core/network/client.js (http://localhost:3333/v50/[email protected]/deno/telegraf.development.js:1075:30)
    at __require2 (http://localhost:3333/v50/[email protected]/deno/telegraf.development.js:31:44)
    at ../../../../../tmp/esm-build-e948e7e0c235eccfffa26ffd75dac27c9851089e/node_modules/telegraf/lib/telegram.js (http://localhost:3333/v50/[email protected]/deno/telegraf.development.js:1300:20)
    at __require2 (http://localhost:3333/v50/[email protected]/deno/telegraf.development.js:31:44)
    at ../../../../../tmp/esm-build-e948e7e0c235eccfffa26ffd75dac27c9851089e/node_modules/telegraf/lib/telegraf.js (http://localhost:3333/v50/[email protected]/deno/telegraf.development.js:1764:22)
    at __require2 (http://localhost:3333/v50/[email protected]/deno/telegraf.development.js:31:44)
    at ../../../../../tmp/esm-build-e948e7e0c235eccfffa26ffd75dac27c9851089e/node_modules/telegraf/lib/index.js (http://localhost:3333/v50/[email protected]/deno/telegraf.development.js:2445:22)
    at __require2 (http://localhost:3333/v50/[email protected]/deno/telegraf.development.js:31:44)

@talentlessguy
Copy link
Contributor

on v55 it's this:

error: Uncaught TypeError: Class extends value undefined is not a constructor or null
    at https://cdn.esm.sh/v55/[email protected]/deno/telegraf.js:3:22
    at https://cdn.esm.sh/v55/[email protected]/deno/telegraf.js:2:1405
    at https://cdn.esm.sh/v55/[email protected]/deno/telegraf.js:3:559
    at https://cdn.esm.sh/v55/[email protected]/deno/telegraf.js:2:1405
    at https://cdn.esm.sh/v55/[email protected]/deno/telegraf.js:3:4797
    at https://cdn.esm.sh/v55/[email protected]/deno/telegraf.js:2:1405
    at https://cdn.esm.sh/v55/[email protected]/deno/telegraf.js:3:12296
    at https://cdn.esm.sh/v55/[email protected]/deno/telegraf.js:2:1405
    at https://cdn.esm.sh/v55/[email protected]/deno/telegraf.js:3:24524
    at https://cdn.esm.sh/v55/[email protected]/deno/telegraf.js:2:1405

@talentlessguy
Copy link
Contributor

same error on v57:

deno eval 'import "https://esm.sh/[email protected]?dev&pin=v57"'
error: Uncaught TypeError: Class extends value undefined is not a constructor or null
    var MultipartStream = class extends sandwich_stream_1.default {
                                                          ^
    at esm-build-3a32e3194a944ce6ceab7e19c7552bc1abaff33e-3acba49b/node_modules/telegraf/lib/core/network/multipart-stream.js (https://cdn.esm.sh/v57/[email protected]/deno/telegraf.development.js:1036:59)
    at __require2 (https://cdn.esm.sh/v57/[email protected]/deno/telegraf.development.js:33:44)
    at esm-build-3a32e3194a944ce6ceab7e19c7552bc1abaff33e-3acba49b/node_modules/telegraf/lib/core/network/client.js (https://cdn.esm.sh/v57/[email protected]/deno/telegraf.development.js:1077:30)
    at __require2 (https://cdn.esm.sh/v57/[email protected]/deno/telegraf.development.js:33:44)
    at esm-build-3a32e3194a944ce6ceab7e19c7552bc1abaff33e-3acba49b/node_modules/telegraf/lib/telegram.js (https://cdn.esm.sh/v57/[email protected]/deno/telegraf.development.js:1302:20)
    at __require2 (https://cdn.esm.sh/v57/[email protected]/deno/telegraf.development.js:33:44)
    at esm-build-3a32e3194a944ce6ceab7e19c7552bc1abaff33e-3acba49b/node_modules/telegraf/lib/telegraf.js (https://cdn.esm.sh/v57/[email protected]/deno/telegraf.development.js:1766:22)
    at __require2 (https://cdn.esm.sh/v57/[email protected]/deno/telegraf.development.js:33:44)
    at esm-build-3a32e3194a944ce6ceab7e19c7552bc1abaff33e-3acba49b/node_modules/telegraf/lib/index.js (https://cdn.esm.sh/v57/[email protected]/deno/telegraf.development.js:2447:22)
    at __require2 (https://cdn.esm.sh/v57/[email protected]/deno/telegraf.development.js:33:44)

@talentlessguy
Copy link
Contributor

it works on v135 now, safe to close

@ije ije closed this as completed Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants