jnordberg / gif.js

JavaScript GIF encoding library
http://jnordberg.github.io/gif.js/
MIT License
4.74k stars 668 forks source link

Bundling gif.js almost works... #118

Open ebrensi opened 4 years ago

ebrensi commented 4 years ago

I am not familiar with other bundlers, but using Parcel I can import the gif.js CoffeScript directly from the a clone of this repo, or from the npm install.

import * as GIF from "node_modules/gif.js.optimized/src/gif.coffee"

but then there is a problem with the file path for the worker. Parcel is able to successfully bundle the worker script if the worker is instantiated with a string-literal url, but unfortunately we have https://github.com/jnordberg/gif.js/blob/92d27a02841339e202c75150dcf6fe5f4fa42ec5/src/gif.coffee#L107 which abstracts the worker filename by having it in options.

This could be fixed by changing the above line to

worker = new Worker "./gif.worker.coffee"

and taking the worker file name out of options.

For people not using a bundler, this would mean they no longer have the option of renaming the worker and putting it in a different folder.

Is this a merge you would be willing to do?