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

request: cloudflare worker support #248

Closed
1 task done
KhafraDev opened this issue Mar 3, 2023 · 5 comments · Fixed by #249
Closed
1 task done

request: cloudflare worker support #248

KhafraDev opened this issue Mar 3, 2023 · 5 comments · Fixed by #249

Comments

@KhafraDev
Copy link
Contributor

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

when bundling with cloudflare workers, I get an error:

    ../../node_modules/@sapphire/shapeshift/dist/index.mjs:2:24:
      2 │ import { inspect } from 'node:util';
        ╵                         ~~~~~~~~~~~

  The package "node:util" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, 
which will remove this error.


X [ERROR] Build failed with 1 error:

  ../../node_modules/@sapphire/shapeshift/dist/index.mjs:2:24: ERROR: Could not resolve "node:util"

Desired solution

all that's needed is to remove the node: prefix, then the node_compat flag can actually work. Yeah it's really annoying.

Alternatives considered

using another library I guess

Additional context

No response

@favna
Copy link
Member

favna commented Mar 3, 2023

Urgh... Frigging CF. The node: prefix is really stylistically better.

Wdyt @vladfrangu ?

@vladfrangu
Copy link
Member

One of these days we should move away from importing anything from node: modules and implement them ourselves...

For now lets just drop the prefix I guess :(

@favna
Copy link
Member

favna commented Mar 3, 2023

Can you make a PR for this @KhafraDev ?

@kyranet
Copy link
Member

kyranet commented Mar 3, 2023

Part of what would be the proper fix, is to have a build that completely skips all node:-dependent code, aka removes the inspect imports and all of the inspect overrides on the error classes (or replaces inspect with a JSON.stringify stub).

@favna
Copy link
Member

favna commented Mar 4, 2023

Considering we want Shapeshift to be browser compatible again in due time we do indeed need to eventually remove all native dependencies but idk how to do inspect in browsers.

Forgot that we polyfill inspect for browsers. I verified the dist files and they're still the same barring the removal of the node: prefix so the polyfill works just fine.

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

Successfully merging a pull request may close this issue.

4 participants