Import jQuery Plugin with JSPM

3.6k views Asked by At

I'm trying to import the jQuery plugin jQuery.scrollTo with JSPM.

So far I installed it with

jspm install npm:jquery.scrollto

and now I'm trying to import it with

import $ from 'jquery';
import scrollTo from 'jquery.scrollto';

Now I'm only getting

$(...).scrollTo is not a function

errors.

I tried to shim it, but I never did it before and can't find a good explanation how to do it, if it is necessary. Can you help me or show me a good explanation when and how do I need to shim things?

1

There are 1 answers

2
Aurelio On BEST ANSWER

I tested on a clean project and here are the steps that i followed:

  1. jspm install jquery

  2. jspm install npm:jquery.scrollto -o "{format: 'global'}" - (see this answer)

  3. add the imports in my app.js as described in the question.

  4. tested both from dev mode and from a self executing bundle with no errors.

You can clone a test repo I've put up here on Github, the steps to build are in the readme. Hope this helps.