dasmoth / dalliance

Interactive web-based genome browser.
http://www.biodalliance.org/
BSD 2-Clause "Simplified" License
226 stars 68 forks source link

Support modular import/export #225

Closed moritzschaefer closed 6 years ago

moritzschaefer commented 6 years ago

Hey,

I'm right now struggling to integrate your library into my TypeScript React project. Being able to import it with require.js or ES6 modules would be awesome. Are there plans to support this/can I help?

Best

dasmoth commented 6 years ago

Hi Moritz,

Agree that this is useful, and the current master branch is actually set up in a way to make such imports reasonably painless. There's not currently a release off this branch on NPM (something I should really remedy...), but there are snapshots. The following should be up-to-date with GitHub master:

         https://www.biodalliance.org/prerelease/dalliance-0.13.90-alpha.5.tgz

There's an example project that imports the Biodalliance API this way at https://github.com/dasmoth/headless-biodalliance. That's actually a command-line nodejs project, but you should be able to do exactly the same in a client side application if you're using a bundler (webpack or similar).

You can definitely use this general approach for embedding Biodalliance in React applications. (Obviously, you'll need a componentDidMounthook to set up the Biodalliance instance once its enclosing React component has been mounted.

I've not had much experience with Typescript myself, but would hope that everything should work out -- do let me know if you run into any issues.