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 Profile photo of Mark Stokes Mark Stokes 3 months, 3 weeks ago.

  • Author
    Posts
  • #471
    Profile photo of Tony Phillips
    Tony Phillips
    Participant

    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
    Profile photo of Bill Ayers
    Bill Ayers
    Keymaster

    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
    Profile photo of Tony Phillips
    Tony Phillips
    Participant

    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
    Profile photo of Bill Ayers
    Bill Ayers
    Keymaster

    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
    Profile photo of Mark Stokes
    Mark Stokes
    Keymaster

    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.