-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Deno support #2583
Comments
Hi, sharp is a "native" module that interfaces with Node.js through N-API. This API isn't currently available in Deno, although there appears to be (or at least have been) a desire to support it - see denoland/deno#237 (comment) and denoland/deno#241 |
I know very little about native/systems programming and stuff - but couldn't you create Rust bindings to the C++ API and then have it hook into Deno's unstable native plugin API or have it compile to WASM/WASI? Again, I know very little about this stuff. |
Perhaps this link will be useful to you https://github.com/emscripten-core/emscripten |
Sorry if this sounds rude, but it doesn't seem like there is an interest from the sharp maintainers so I guess someone from the community could just use emscripten with a simple c++ project importing sharp and just publish that. |
At the moment, there are no photo processing modules for Deno. |
Here is the lib mentioned above: @michailVestnik can you reopen please? I & I'm sure others would love to use this lib on Deno someday.... |
Would be killer |
For those who haven't yet seen, Deno is in the process of adding support for Node-API (N-API) via denoland/deno#13633 Once this is made available we can assess how much additional work, if any, would be required by sharp to integrate. |
Looks like denoland/deno#13633 was merged yesterday @lovell! 😄 |
Why is there no deno-native implementation? |
Node API (formerly NAPI), was implemented into Deno a while ago. Could this issue be opened again, I think it deserves some discussion |
The merged PR was part of Deno v1.26.1 published on the 6th October, 35 days ago. I haven't yet seen any documentation or examples relating to this feature. Has anyone tried using sharp with Deno since then? Happy to reopen if there are specific things that need to be done in sharp. I note Deno has its own dependency management, and features of the Node.js/npm/yarn ecosystem such as install scripts are not (yet?) available, so it's unclear how to get platform and architecture specific binaries installed. Perhaps manually-managed import maps might be required to handle this? |
A quick check reveals that the latest Deno allows me to use sharp, albeit after running $ deno --version
deno 1.27.2 (release, x86_64-unknown-linux-gnu)
v8 10.8.168.4
typescript 4.8.3 Here's my import sharp from 'npm:sharp@0.31.2'
console.log(sharp.format) Running it first time populates Deno's cache from npm, but doesn't install binaries and fails. $ cat test.ts | deno run --allow-all --unstable -
error: Uncaught Error:
Something went wrong installing the "sharp" module
... Manually install the binaries by running $ cd ~/.cache/deno/npm/registry.npmjs.org/sharp/0.31.2
$ npm install Running the test script again appears to work: $ cat test.ts | deno run --allow-all --unstable -
napi_add_finalizer is not yet supported.
...
{
jpeg: {
id: "jpeg",
input: { file: true, buffer: true, stream: true, fileSuffix: [ ".jpg", ".jpeg", ".jpe" ] },
output: { file: true, buffer: true, stream: true, alias: [ "jpe", "jpg" ] }
},
... Is anyone aware of a better/easier way to get Deno to run install scripts, rather than manually running In summary, we should add something to the documentation about this, but it looks like there are no code changes required. 🚀 |
Deno is talking about postinstall script support, but with a prompt (and assume a flag to force?) |
Why was this closed? /cc @lovell |
@deeprobin The person who opened the issue also closed it (on the 7th April 2021). Had there been an obvious change required to sharp then I would happily have reopened it. At the time it appeared that Deno was planning to add support for Node-API, and now they have and it works, which is great news, and I'm sure you'll join me in thanking the Deno maintainers for this. |
Thanks Lovell. I can maybe port some of my old node stuff over to Deno now, which I find more maintainable (less dev tooling/packaging overhead) for little scripts/CLIs. |
I have tried on a windows host nodeJS version: v18.12.0 deno version: 1.29.4 with and I start the npm install from the np, cached folded, and I still get the error: deno run -A --unstable .\test-sharp.ts
error: Uncaught Error:
Something went wrong installing the "sharp" module
Error in native callback
Possible solutions:
- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
- Install for the current win32-x64 runtime: "npm install --platform=win32 --arch=x64 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
at Object.<anonymous> (file:///C:/Users/uriel/AppData/Local/deno/npm/registry.npmjs.org/sharp/0.31.2/lib/sharp.js:34:9)
at Object.<anonymous> (file:///C:/Users/uriel/AppData/Local/deno/npm/registry.npmjs.org/sharp/0.31.2/lib/sharp.js:37:4)
at Module._compile (deno:ext/node/02_require.js:747:36)
at Object.Module._extensions..js (deno:ext/node/02_require.js:780:12)
at Module.load (deno:ext/node/02_require.js:658:34)
at Function.Module._load (deno:ext/node/02_require.js:515:14)
at Module.require (deno:ext/node/02_require.js:680:21)
at require (deno:ext/node/02_require.js:820:18)
at Object.<anonymous> (file:///C:/Users/uriel/AppData/Local/deno/npm/registry.npmjs.org/sharp/0.31.2/lib/constructor.js:8:1)
at Object.<anonymous> (file:///C:/Users/uriel/AppData/Local/deno/npm/registry.npmjs.org/sharp/0.31.2/lib/constructor.js:425:4) I all so tried to run and with Same error. |
Are there any updates on this? Some users have expressed interest to use Transformers.js in Deno, but haven't been able to due to this issue. |
The somewhat manual steps outlined in #2583 (comment) should already allow the use of sharp with Deno. Installation will hopefully be much simpler when the feature being tracked at denoland/deno#16164 is made available, at which point we can do things like add Deno to CI environments and update documentation. |
Great, thanks for the quick response. |
I manually installed Sharp as suggested above, but I am getting the following error on Mac M1. Looks like I will park Deno - Sharp experiments for now.
|
@VelinGeorgiev Best guess would be that denoland/deno@512d533 altered Deno to expect a native module to register itself using |
Thanks @lovell! I will ask at the Deno repo. |
@lovell I propose to change the way the binary is installed in sharp. Instead of using the For example, Esbuild publishes a binary for each platform/architecture supported as Pagefind does something similar: https://github.com/CloudCannon/pagefind/blob/main/wrappers/node/package.json The package manager (NPM or Deno) pick automatically the dependency based on this suffix. Edit: Sorry I just realized this is on the roadmap (great!): #3750 |
I'm using sharp with deno: import sharp from "npm:sharp@0.33.0";
... That works great if I just run it with
Is that a know limitation? Or is there a solution? |
@some-user123 For |
Hi!
It would be very nice to make an ES import for Deno and place the documentation and examples in the main repository at https://deno.land
For example:
import { sharp } from 'https://deno.land/x/sharp@v0.27.0/mod.ts'
Thanks!
The text was updated successfully, but these errors were encountered: