Giter Club home page Giter Club logo

Comments (8)

rwv avatar rwv commented on July 27, 2024 1

Thank you! I haven’t try yet. But I found an issue in example that Cloudflare workers ESM mode spent not support wasm in wrangler.toml anymore.

Use direct import instead

// @ts-ignore
import PNG_DEC_WASM from '../../node_modules/@jsquash/png/codec/squoosh_png_bg.wasm';
// @ts-ignore
import WEBP_ENC_WASM from '../../node_modules/@jsquash/webp/codec/enc/webp_enc_simd.wasm';

from jsquash.

rwv avatar rwv commented on July 27, 2024 1

Maybe you could mention that in readme.md

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024 1

It looks like my previous changes still work with the ESM Format 🙌

Thanks for your suggestions @rwv

Maybe you can import wasm directly in jSquash package and user don’t have to run initWASM manually.

Unfortunately I don't think we can. You cannot import "wasm" files directly in JavaScript. Cloudflare is cheating a little bit by allowing non-JS files to be imported, like wasm and html with their bundler. This improves the developer experience but makes the files invalid JavaScript files.

If you don't mind, I'll close this issue now. If you're still encountering issues feel free to re-open. Thanks again!

from jsquash.

rwv avatar rwv commented on July 27, 2024

workaround:

return moduleFactory({
  // Just to be safe, don't automatically invoke any wasm functions
  noInitialRun: true,
  instantiateWasm,
  locateFile: (url: string) => {
    return url;
  },
});

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024

Thanks for reporting this @rwv, I've published a new version that I think will fix this.

Can you try npm install -S @jsquash/[email protected] and see if that resolves the issue?

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024

Thanks for the feedback! Once I confirm I'll add. It seems to working for me locally with wrangler v3 but perhaps I am not properly in ESM mode.

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024

Ah I see the ESM mode is very different from the Service worker mode. I'll need to make additional changes.

Apologies I misunderstood the problem.

from jsquash.

rwv avatar rwv commented on July 27, 2024

Maybe you can import wasm directly in jSquash package and user don’t have to run initWASM manually. Although this may affect current users.

from jsquash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.