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

Unable to install @gltf-transform/functions in deno #1092

Closed
CITIZENDOT opened this issue Sep 14, 2023 · 5 comments
Closed

Unable to install @gltf-transform/functions in deno #1092

CITIZENDOT opened this issue Sep 14, 2023 · 5 comments
Labels
external Problems or limitations traced back to other tools. needs investigation package:functions

Comments

@CITIZENDOT
Copy link
Contributor

Describe the bug
Cannot import/install @gltf-transform/functions

To Reproduce
Open deno REPL and import something from @gltf-transform/functions.

> import { quantize } from 'https://esm.sh/@gltf-transform/functions';
Uncaught TypeError: Import 'https://esm.sh/v132/sharp@0.32.5/denonext/sharp.mjs' failed: 500 Internal Server Error
    at https://esm.sh/v132/ndarray-pixels@3.0.4/denonext/ndarray-pixels.mjs:2:71
    at async <anonymous>:2:23

Versions:

  • Version: 3.5.1
  • Environment: Deno

Additional context
It appears to be sharp isn't built correctly: https://esm.sh/v132/sharp@0.32.5/denonext/sharp.mjs

@CITIZENDOT CITIZENDOT added the bug Something isn't working label Sep 14, 2023
@donmccurdy donmccurdy added package:functions external Problems or limitations traced back to other tools. labels Sep 14, 2023
@donmccurdy donmccurdy added this to the Backlog milestone Sep 14, 2023
@donmccurdy donmccurdy added needs investigation and removed bug Something isn't working labels Sep 14, 2023
@donmccurdy
Copy link
Owner

donmccurdy commented Sep 14, 2023

Related:

It seems like this "should" work, but the error is two levels down in the dependencies. Do you know if Deno supports tree-shaking? Or what version of Deno you're using? I'm not sure I understand why it would be importing sharp when only the quantize function is loaded.

The only solutions I see at the moment would be:

  1. Add another image processing implementation to ndarray-pixels specifically for Deno. Not appealing if sharp should work in Deno...
  2. Try to ensure sharp is always lazily imported in ndarray-pixels. Not sure whether I can do that in a sanity-preserving way without switching to ESM-only builds. I'd like to go ESM-only eventually, but the whole CJS/ESM situation is a headache.
  3. ???

As a workaround you could also copy/paste the bits of quantize.js that you need, though I understand that's probably not appealing. :)

https://github.com/donmccurdy/glTF-Transform/blob/main/packages/functions/src/quantize.ts

@CITIZENDOT
Copy link
Contributor Author

❯ deno --version
deno 1.36.0 (release, x86_64-unknown-linux-gnu)
v8 11.6.189.12
typescript 5.1.6

Tree shaking is added to deno in v1.5. I'll copy/paste the quantize.js for now. I think lazy import is a good approach though.

@birkskyum
Copy link

birkskyum commented Sep 20, 2023

Fixing sharp in deno:

@donmccurdy
Copy link
Owner

@donmccurdy
Copy link
Owner

I think upcoming Sharp versions will fix this, but in any case let's track general support for the Deno runtime in #457.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Problems or limitations traced back to other tools. needs investigation package:functions
Projects
None yet
Development

No branches or pull requests

3 participants