jamsinclair / jSquash

Browser & Web Worker focussed wasm bundles derived from the Squoosh App.
Apache License 2.0
222 stars 14 forks source link

node 18.8 > pnpm 安装的 不能自动加载 WASM #61

Closed gowy222 closed 1 month ago

gowy222 commented 1 month ago

Describe the bug 环境: win11 pnpm: 9.7.0 node: v18.18.2

.npmrc配置:

shamefully-hoist=true
strict-peer-dependencies=false

pnpm add @jsquash/jxl

代码:

import { encode } from '@jsquash/jxl';

然后...

 try {
    const encodedImage = await encode(imageBuffer);
  } catch (error) {
    console.log(error);
    return false
  }

报错:

TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11372:11) {
  cause: Error: not implemented... yet...
      at makeNetworkError (node:internal/deps/undici/undici:4801:35)
      at schemeFetch (node:internal/deps/undici/undici:9531:18)
      at node:internal/deps/undici/undici:9409:26
      at mainFetch (node:internal/deps/undici/undici:9428:11)
      at fetching (node:internal/deps/undici/undici:9377:7)
      at fetch2 (node:internal/deps/undici/undici:9245:20)
      at Object.fetch (node:internal/deps/undici/undici:11370:18)
      at fetch (node:internal/process/pre_execution:242:25)
      at instantiateAsync (..  

求解..

jamsinclair commented 1 month ago

Hey @gowy222 - this library is not primarily focussed on supporting Web Browsers.

It is possible to get Node.js working if you follow the examples at https://github.com/jamsinclair/jSquash/blob/main/examples/with-node/index.js