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 - https://esm.sh/v111/ws@8.13.0/denonext/ws.js:2:2713 #556

Closed
vixalien opened this issue Mar 21, 2023 · 4 comments
Closed
Labels
deno Not working in Deno

Comments

@vixalien
Copy link

Failing module

// very complicated but basically
import * as ws from 'https://github.com/websockets/ws'

Error message

After running deno run I got this:

error: Uncaught TypeError: __Buffer$.alloc is not a function
    at https://esm.sh/v111/ws@8.13.0/denonext/ws.js:2:2713
    at https://esm.sh/v111/ws@8.13.0/denonext/ws.js:2:969
    at https://esm.sh/v111/ws@8.13.0/denonext/ws.js:2:2982
    at https://esm.sh/v111/ws@8.13.0/denonext/ws.js:2:969
    at https://esm.sh/v111/ws@8.13.0/denonext/ws.js:2:4355
    at https://esm.sh/v111/ws@8.13.0/denonext/ws.js:2:969
    at https://esm.sh/v111/ws@8.13.0/denonext/ws.js:2:11129
    at https://esm.sh/v111/ws@8.13.0/denonext/ws.js:2:969
    at https://esm.sh/v111/ws@8.13.0/denonext/ws.js:8:182

Additional info

I believe this is caused by incorrect importing of the node:buffer package.

In fact, https://esm.sh/v111/ws@8.13.0/denonext/ws.js:2:2713 links to the following source line:

https://github.com/websockets/ws/blob/45e17acea791d865df6b255a55182e9c42e5877a/lib/constants.js#L5

This gets transpired to:

import __Buffer$ from "node:buffer";
//...
EMPTY_BUFFER:__Buffer$.alloc(0)
//...

which is incorrect, as the correct import should be import { Buffer } from "node:buffer" .

In short, it imports the default export instead of the named export Buffer

  • esm.sh version: 111
  • Deno version: deno 1.31.3
@vixalien vixalien added the deno Not working in Deno label Mar 21, 2023
@ije ije closed this as completed in c02899a Mar 21, 2023
@ije
Copy link
Member

ije commented Mar 21, 2023

thanks for reporting, i just fixed. please use deno target for now, i will release the change soon

@vixalien
Copy link
Author

okay. thanks

@vixalien
Copy link
Author

wait, by using the deno target, does it still import node compat packages from std/node? I don't want that behavior.

@ije
Copy link
Member

ije commented Mar 21, 2023

please wait v112

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

No branches or pull requests

2 participants