SPFX – External libraries?

Home Page Forums Office 365 SharePoint SPFX – External libraries?

This topic contains 4 replies, has 3 voices, and was last updated by  Mark Stokes 1 year, 1 month ago.

  • Author
  • #471

    Tony Phillips

    Has anyone managed to get external libraries working with dependencies on another library. For example jQuery and Cycle2?
    I’ve seen a few methods and workarounds and just wondered what methods people are using….

  • #494

    Bill Ayers

    There is a lot of sample code on GitHub (https://github.com/SharePoint/sp-dev-fx-webparts). For example for jQuery, see: https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/jquery-photopile

    Or look at Waldek’s https://github.com/SharePoint/sp-dev-fx-webparts/blob/master/samples/jquery-cdn/ which uses CDN.

    In essence you need to add a dependency to the library using

    npm install --save awesomelibrary

    and then add an import in your MyWebpart.ts.

  • #497

    Tony Phillips

    Thanks Bill, I hadn’t seen the Photo Pile example. It’s a good example with lots of dependencies on jQuery.

    I think I have narrowed my specific problems down to jQuery Cycle 2. Doesn’t seem to work when referenced as an external file from CDN…

  • #500

    Bill Ayers

    A few libraries seem to take a dependency on jQuery 1.9 and stop there. I think there were some big changes with jQuery when they went to version 2.

  • #517

    Mark Stokes

    I have rolled many projects back from 2.x to 1.9x especially if you need horrible old IE support.

You must be logged in to reply to this topic.