-
Notifications
You must be signed in to change notification settings - Fork 146
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
SyntaxError: import not found #70
Comments
@behunin Hi Levi, could you show the code used and I'll take a look at it! Thanks 😄 |
function resize() {
const ctx = small.value.getContext("2d");
ctx.drawImage(orig.value, 0, 0);
try {
import("@silvia-odwyer/photon")
.then((photon) => {
let img = photon.open_image(small.value, ctx);
photon.resize(img, 50, 50, 1);
photon.putImageData(small.value, ctx, img);
})
.catch((e) => {
console.log(e);
});
} catch (e) {
console.log(e);
}
} This is inside a Vue 3 setup function. I get the same error whether I use references or Thank you for your time! 😃 |
I am getting the same (or a similar) error when using Vite (https://vitejs.dev) as build tool. The problem seems to come from the fact that Vite uses the following WASM import mechanism: https://vitejs.dev/guide/features.html#webassembly. But in I found no easy solution, even copying the whole package in my repo and editing the import only led to a new error:
Inspection of the .wasm showed that there are indeed imports from Being no JS/WASM expert, I have no idea how to solve this. Is it required to build the WASM with another type, like @silvia-odwyer Could you tell us if you plan to support Vite or if you have any idea how to approach or work around this issue? |
The problem comes from wasm-bindgen, the way it packages wasm causes all sorts of problems. Even when you do target web. I had to rework the whole package in order to get something working. Hopefully I will have some free time this winter to submit some PRs to wasm-bindgen. |
@andilem Thanks for letting me know about this! I'd recommend opening an issue in the wasm-bindgen repository, as the WASM version of photon is built using it, so it's definitely worth letting them know also, and you'll be able to get it working with Vite in the future hopefully then 👍 |
HI @andilem @silvia-odwyer I made a vite build example, please check. Demo: Code: I just forked photon and republished a npm package with https://www.npmjs.com/package/photon-web with vite-plugin-wasm-pack , it works. |
@nshen Thanks very much for this, it'll be incredibly useful for those who wish to use Photon with vite 😄 Your help is much appreciated, so thanks again! 🎉 |
Chrome88:
SyntaxError: The requested module '/node_modules/@silvia-odwyer/photon/photon_bg.wasm?import' does not provide an export named 'hsl'
Firefox85:
SyntaxError: import not found: monochrome
I was trying the resize function.
The text was updated successfully, but these errors were encountered: