Importing trackingjs third party library

I am trying to import the trackingjs library (https://www.npmjs.com/package/tracking) into my ionic2 project.

By following the documentation (https://ionicframework.com/docs/v2/resources/third-party-libs/) I can import the lodash library and use it.

But with tracking js all I get is an empty object

import tracking from 'tracking/build/tracking';

I installed the tracking module with npm and then installed the corresponding types (https://www.npmjs.com/package/@types/tracking). I can see the code from the module in my main.js file when using ionic serve so it seems to be included correctly, but I can’t get it to work.

Did I miss anything obvious or is there something more to do with that library? Any help will be appreciated.

I found a way to access the library in my app and with no errors in the editor. The solution was provided by @mikewagz in Importing external libraries

I now import trackingjs like this:

import 'tracking';

All this does is include the library via Webpack and it gives me access to the global named tracking (actually obviously window.tracking as created by the library), without error messages in the editor.

Somehow this is very unsatisfying… and it seems wrong.

Can someone shed some light on how/if it could be improved and how things actually work under the hood?


PS: there is not need to specify the full path to the library file (as written in my question).

Hi there, I’m a student working on a school project with ionic and planing to use trackingjs as well and I stumble into your topic here.
Did you manage to use trackingjs in ionic? and is trackingjs is fully compatible with ionic to do some real time image processing (using the camera)?

You’ll be a lot of help, thanks before.