Third party non-NPM packages integration with TypeScript-based Sharepoint Framework’s Web Part

Occasional Contributor

Hello.

 

I have js file and d.ts file of some third party library that could not be installed through NPM installer.

I tried to integrate this package within Typescript-based Sharepoint Framework’s Web Part project but didn’t succeed.

I need a help and, if possible, an example solving this issue.

 

Thanks, Alex.

5 Replies

why not try using the CDN instead of installing...?

Unfortunately, the CDN is not an option for me.

What library is it? What problem are you having? How are you trying to integrate it in your project?

Hello, Waldek.

The library I try to integrate is Keylines network library from Cambridge Intelligence Company.

It's a proprietary library that is not distributed via NPM and can be accessed only with username and password at their dedicated web site.

They provide js and d.ts files for a work with Typescript.

I built a project with yeoman and I have to add manually js, d.ts files and reference them.

How should I configure such kind of library and what is the best way to deal with libraries that are not exposed through NPM installer?

Thanks, Alex.

As you can't install it via NPM, you don't have much choice other than directly referencing it in your project. Because you have TypeScript type definitions, you should be able to include the reference using an import statement. I don't know the library you mentioned so can't tell exactly how that statement should look like. If it turns out that the library isn't distributed as a module, you can use a reference clause instead. It's a bit cryptic but it's hard to provide more details without knowing the library. Hope it helps.