0

I am using jspm install npm:cropper

which installs cropper and adds "cropper": "npm:cropper@^2.0.1" to package.json aslo i could find it under \jspm_packages\npm folder

But its not loading in network tab. any idea what am missing?

P.S:- I did not find the type definitions for cropper.js so i have declared the cropper like

declare var cropper: any;
declare module "cropper" {
    export = cropper;
}

and imported it as import * as cropper from 'cropper'; which is not giving any error, but still no luck with cropper loading.

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
hasain
  • 333
  • 3
  • 10

2 Answers2

0

But its not loading in network tab. any idea what am missing

It will not be loaded unless its required. E.g.

var foo = require('cropper');
console.log(foo);
basarat
  • 261,912
  • 58
  • 460
  • 511
0

There are two steps. The first step is to install cropper which is what you did when you added the package to package.json. The second step is to actually load the package - see https://github.com/systemjs/systemjs how to do that.

If you want to import the package yourself, you should not use import ... from 'cropper'but

var cropper = require('cropper');

because otherwise TypeScript compiler will check if the module is written in TypeScript and if it is located under node_packages folder.

MartyIX
  • 27,828
  • 29
  • 136
  • 207
  • using var cropper = System.import("cropper"); did load the cropper.js require does't work for some reason. – hasain Nov 23 '15 at 07:55
  • Yes, `require` is used in commonjs. (it can work with systemjs too: https://github.com/systemjs/systemjs/blob/master/docs/module-formats.md#requirejs-support) but `System.import('cropper')` is proper way for systemjs – MartyIX Nov 23 '15 at 08:00
  • I have the EXACT same problem, but haven't been able to figure it out. I import like this and the file DOES get downloaded, but I can't call new Cropper(...); ----------> import * as Cropper from 'cropper/dist/cropper.min.js'; – Programmer9000 Mar 05 '16 at 22:20