interval-tree2 icon indicating copy to clipboard operation
interval-tree2 copied to clipboard

compiling for web use

Open jedierikb opened this issue 9 years ago • 4 comments

Could you add details about how to compile your code for use in the web?

On your homepage, you show: <script src="dist/interval-tree.js"></script>

but there is no dist/folder in your repository.

jedierikb avatar Feb 26 '16 02:02 jedierikb

Alright, so per the readme (should have started there), I $ npm install interval-tree2 and found the dist directory.

And, then to make it in a library I can drop into a browser, I ran browserify interval-tree.js -o my-interval-tree.js

And then I successfully add <script src="dist/my-interval-tree.js"></script>

But then when I try to instantiate an IntervalTree, Uncaught ReferenceError: IntervalTree is not defined

jedierikb avatar Mar 01 '16 16:03 jedierikb

OK, I should prepare browser field in package.json. Now, why don't you run with standalone option?

browserify --standalone IntervalTree dist/interval-tree.js > /path/to/web/dir/interval-tree.js

shinout avatar Mar 02 '16 01:03 shinout

I did not use standalone because I did not know about it. Thank you!

jedierikb avatar Mar 02 '16 14:03 jedierikb

This seems like a great lib but it's not easy at all to use in the browser. it is coupled with using the require way of browserify (which I don't use or will ever)..I would wish there was a way to just get a single javascript file and use it..

yairEO avatar Mar 26 '16 18:03 yairEO