jnordberg / gif.js

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

import / require as module for bundler? #117

Closed ebrensi closed 4 years ago

ebrensi commented 4 years ago

I have been using gifjs for a while and it works great!

My app has grown to the point where just including script tags or concatenating .js files is no longer feasible. I am trying to figure out how to go about importing the main script and worker scripts. I npm installed `gif.js.optimized' but now I'm not sure what to do.

As far as I can tell from index.js, the exports of this npm package are

module.exports = {
  NeuQuant: require('./src/NeuQuant.js'),
  TypedNeuQuant: require('./src/TypedNeuQuant.js'),
  GIFEncoder: require('./src/GIFEncoder.js'),
  LZWEncoder: require('./src/LZWEncoder.js')
};

none of which are the GIF() constructor. I am new to this so pardon me if I am missing something obvious. Would it be something like

const GIF = require("gif.js.optimized").GIFEncoder

?

And what about the worker? How do I import that?

I would be happy to submit a pull request documenting how to do these things when I figure it out.

ebrensi commented 4 years ago

never mind, I figured it out. For anyone who may be wondering, the "default export" of this repo as an npm module is not actually the gif.js with the GIF object that we want to use. gif.js is created by the build script in /bin.

DaniEzzeddine commented 2 years ago

@ebrensi so in order to use worker I have to provide pass to the gif.js/dist/ in node_modules?

ebrensi commented 2 years ago

@ebrensi so in order to use worker I have to provide pass to the gif.js/dist/ in node_modules?

Hey sorry for taking so long. I just saw this. I hope you figured it out by now. Did you?

DaniEzzeddine commented 2 years ago

@ebrensi yep:)