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

Unstable on Deno #46

Closed
raunakdoesdev opened this issue Mar 26, 2023 · 2 comments
Closed

Unstable on Deno #46

raunakdoesdev opened this issue Mar 26, 2023 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@raunakdoesdev
Copy link

Running the await Vips() snippet form the README on Deno results in the following:

Deno 1.32.1
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> import Vips from 'https://cdn.jsdelivr.net/npm/wasm-vips/lib/vips-es6.js';

undefined
> const vips = await Vips();
error: Uncaught (in worker "") TypeError: na is not a function
    at https://cdn.jsdelivr.net/npm/wasm-vips/lib/vips-es6.js:116:217
    at new Promise (<anonymous>)
    at e (https://cdn.jsdelivr.net/npm/wasm-vips/lib/vips-es6.js:116:191)
    at f (https://cdn.jsdelivr.net/npm/wasm-vips/lib/vips-es6.js:116:467)
    at dd (https://cdn.jsdelivr.net/npm/wasm-vips/lib/vips-es6.js:117:361)
    at https://cdn.jsdelivr.net/npm/wasm-vips/lib/vips-es6.js:118:327
@kleisauke kleisauke added the bug Something isn't working label Apr 1, 2023
@kleisauke kleisauke added this to the v0.0.5 milestone Apr 1, 2023
@kleisauke
Copy link
Owner

This is due to missing dynamic modules support on Deno, which was fixed with commit 997031a.

You can workaround this by disabling support for this (which implies that support for JPEG XL images is also disabled). For example:

import Vips from 'https://cdn.jsdelivr.net/npm/wasm-vips/lib/vips-es6.js';

const vips = await Vips({
  dynamicLibraries: []
});

// Load a formatted image from buffer
const buffer = await Deno.readFile('playground/src/images/banana.webp');
const thumbnail = vips.Image.thumbnailBuffer(buffer, 500, {
  option_string: '[n=-1]',
  height: 500
});

// Write the result to a blob
const outBuffer = thumbnail.writeToBuffer('.gif');
await Deno.writeFile('banana.gif', outBuffer);

// Exit the Deno runtime (i.e. a more "commandline" experience)
Deno.exit();
$ deno run --allow-net --allow-read --allow-write test.js

@kleisauke
Copy link
Owner

v0.0.5 now available, which includes support for dynamic modules on Deno.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants