Rails 7 failing to import yarn package (https://github.com/keisto/vanilla-rangeslider)

100 Views Asked by At

This is a non-jQuery version of IonRangeSlider (https://github.com/IonDen/ion.rangeSlider):

https://github.com/keisto/vanilla-rangeslider

I have used this before by trying to stick to pure JS and avoid adding another layer with JQ.

I installed this via yarn and it's in my node_modules folder.

I added this to my app/javascript/application.js file:

import IonRangeSlider from 'vanilla-rangeslider/js/rangeslider'

after also trying just:

import IonRangeSlider from 'vanilla-rangeslider'

In my compiled JS file in dev all it has is this:

  // ../../node_modules/vanilla-rangeslider/js/rangeslider.js
  var require_rangeslider = __commonJS({
    "../../node_modules/vanilla-rangeslider/js/rangeslider.js"() {
    }
  });

and if I try and initialize a slider all I get is:

Uncaught ReferenceError: ionRangeSlider is not defined

Any ideas here as to what I am missing? I have added some other yarn based JS package with no issues.

1

There are 1 best solutions below

1
On BEST ANSWER

The range slider has no exported functions, meaning you won't be able to import anything from it.

The only way to use its functions would be to add it in a script tag unfortunately.