benwiley4000 / gif-frames

🖼 Extract frames from an animated GIF with pure JS
MIT License
167 stars 26 forks source link

Problem with using Vite + Vue #48

Open 6474131 opened 1 year ago

6474131 commented 1 year ago

image

I get this error and I'm not really sure how to fix it, although it seems similar to https://github.com/benwiley4000/gif-frames/issues/37. For reference all I'm doing is importing gif-frames, I'm not doing anything else at the moment.

liangtian123 commented 9 months ago

me too

benwiley4000 commented 9 months ago

My guess is this is due to the dependencies (get pixels, save pixels) relying on node.js packages built into browserify, webpack etc and perhaps they're not supported by vite. Really wild guess, I'm not sure.

liangtian123 commented 9 months ago

The following information is key to resolving this issue: I copied gif-frames.js into my project and then processed it

var EE = require_events().EventEmitter;
if (!EE.listenerCount)
EE.listenerCount = function(emitter, type) {
return emitter.listeners(type).length;
};

save-pixels-jpeg-js-upgrade.js?v=88a5b38b:39 Module "events" has been externalized for browser compatibility. Cannot access "events.EventEmitter" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

image

liangtian123 commented 9 months ago

I downloaded https://unpkg.com/gif-frames@1.0.1/dist/gif-frames.min.js locally, put it into my project, and then introduced it in index.html, and the problem was solved

Note that package.json does not need to introduce "gif-frames": "^1.0.1" again

benwiley4000 commented 9 months ago

I guess Vite doesn't handle UMDs

Ben

Le lun. 18 déc. 2023, 4 h 17 a.m., Oliver @.***> a écrit :

I downloaded @.***/dist/gif-frames.min.js locally, put it into my project, and then introduced it in index.html, and the problem was solved

Note that package.json does not need to introduce "gif-frames": "^1.0.1" again

— Reply to this email directly, view it on GitHub https://github.com/benwiley4000/gif-frames/issues/48#issuecomment-1859867906, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADHOD3NS6JBUQF2PVADNPTTYKAC2LAVCNFSM6AAAAAAWODV3JCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZHA3DOOJQGY . You are receiving this because you commented.Message ID: @.***>