Dan Tappin
Dan Tappin

Reputation: 3032

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

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.

Upvotes: 0

Views: 100

Answers (1)

Cjmarkham
Cjmarkham

Reputation: 9681

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.

Upvotes: 1

Related Questions