blacklabel / annotations

Annotations plugin for Highstock by Black Label
http://blacklabel.github.io/annotations/
Other
22 stars 16 forks source link

Correspondng NPM module for this plugin #45

Closed late-warrior closed 8 years ago

late-warrior commented 9 years ago

Hi, is there a npm counterpart to this plugin so that I can use it on the server side ?

One possible way to do this (without having to change existing code too much):

 // Change the IIFE from this
 (function (Highcharts,HighchartsAdapter) {

 }(Highcharts,HighchartsAdapter)

 // To making it available on module.exports
 module.exports = function (Highcharts,HighchartsAdapter)
 // and we require it like this:
 var mod = require('highcharts-annotations')(Highcharts,HighchartsAdapter);

I haven't given thought to how to keep the 'browser' version and 'npm' version in sync though.

pawelfus commented 9 years ago

We don't have repo for NPM, but the best solution would be to add separate files to this repo for NPM. However keeping both files (browser+npm) would be a pain. Another solution may be to create shim repo like Highcharts did (only for NPM), and with each release update files in that repo too. Again, maintaining this would be troublesome.

Any suggestions?

Probably automated process to build files (ant?) from parts would resolve that case:

And before each commit, build this project.

late-warrior commented 9 years ago

For the 'build from parts' approach - here is a crude one without using ant - https://github.com/golyakov/highstock-browserify . The 'build script' is run using npm (using the 'scripts' tag in package.json) - https://github.com/golyakov/highstock-browserify/blob/master/build.sh .

I think the best approach might be to use tools like browserify/webpack.
We can author in commonjs format (to keep npm happy) and then use webpack to build a 'browser' version which shims the npm 'require'. Then have a post commit hook (like you suggested) which will 'build' the browser version.