Search code examples
javascriptobservablehq

It is not possible to import JS package BigDecimal inside ObservableHQ


I'm playing around with ObservableHQ and decided to use the BigDecimal package. But as I use the require function to make it available I get the following feedback:

error feedback

I tried to follow the instructions in the Introduction to require and debug it with the Module require debugger but I'm new to JavaScript, that information wasn't of much help.

I'm running it in Firefox 75.0 in Ubuntu 18.04.

Why can't I import the package? Is this a problem with my setup or a particular condition of the package?


Solution

  • You can import it using require and big-decimal for the web

    bigDecimal = await require('js-big-decimal/dist/web/js-big-decimal.min.js').catch(
      () => window.bigDecimal
    )
    

    https://github.com/royNiladri/js-big-decimal#usage