catdad-experiments / libheif-js

🤳 libheif as an npm module
GNU Lesser General Public License v3.0
63 stars 2 forks source link

require function is used in a way in which dependencies cannot be statically extracted #23

Open swissspidy opened 10 months ago

swissspidy commented 10 months ago

Webpack is emitting this warning when I require( 'libheif-js/wasm-bundle' ) in my project.

The contents of wasm-bundle.js:

https://github.com/catdad-experiments/libheif-js/blob/d58327650ae188dd1a9b0e8827907ae4bc39dafe/wasm-bundle.js#L1

Not sure how this can be best addressed, I'd have to look into that, but I thought I'd share it here just in case in case anyone has ideas.

ashuvssut commented 7 months ago

This solution worked for me:

i changed the import statement like so:-

image

EDIT

@swissspidy ah sorry. its a bad solution

The warning went away. but the heic to jpeg conversions were failing. its a no-go

catdad commented 6 months ago

I am not all that familiar with this issue in particular -- it's been a while since I used webpack.

One question I have is: this shows as a warning. Warnings don't typically fail the build? Is this failing in some way or just causing annoying noise? I am finding that there are ways to ignore known warnings causing me to think this is not actually a blocking problem / failure as much as just scary looking.

Second question: I believe statically extracting dependencies has to do with treeshaking. Is that correct? This module can't really be slimmed down, since it doesn't include anything that is used.

Finally, it seems a few folks have reported it. Does anyone have a repro? Sharing a minimal code sample that reproduces the issue is very helpful in getting an issue debugged.

jocluzet commented 6 months ago

If it helps, I have this error with version ^1.17.1 but not with 1.10.0. I use the program very simply as a dependency of heic-convert.

ashuvssut commented 6 months ago

Is this failing in some way or just causing annoying noise?

its not blocking anything. its just a noise in devtools console tab

btw thankyou for your awesome work! i tried other different libs but failed miserably. But libheif-js works nicely

sagarchoudhary96 commented 2 months ago

Found the way to supress this critical dependency warninig: check it out here