Requiring a module from CustomJS Callback

I’m new to javascript and have a situation where I’d like to use math.js from within a CustomJS callback. What steps do I need to take to hit this dependency? I’ve installed via npm, but simply calling require("mathjs") from the CustomJS source doesn’t work:

Error: Cannot find module ‘mathjs’

``

My guess is that I’m missing something simple about javascript…

Hi,

···

On Thu, May 17, 2018 at 8:04 PM, [email protected] wrote:

I’m new to javascript and have a situation where I’d like to use math.js from within a CustomJS callback. What steps do I need to take to hit this dependency? I’ve installed via npm, but simply calling require("mathjs") from the CustomJS source doesn’t work:

Error: Cannot find module ‘mathjs’

``

My guess is that I’m missing something simple about javascript…

the simplest solution would be to just include a <script src="path/to/math.js> in the HTML document (possibly use a CDN) and then reference math.js from a CustomJS callback by using mathjs global. If you want to to include math.js as a module (which require() implies), then you would have to create a custom bokehjs module bundle, which, I think, is an overkill in this scenario. Obviously a lot depends on what exactly is the goal. If you just want to make it work, then the former solution should be much more straight forward to work out.

Mateusz

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/cce04cd6-3f82-4b66-8f53-977eae09c09b%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.