Ok guys, I was able, with help of @fengyuanchen from cropperjs, to update my project to the last version of cropperjs and solve the issue we had with that last version.
Here how I have proceeded:
-
If you already have cropperjs in your project remove it
sudo npm remove cropperjs --save
-
Install the last version of cropperjs
sudo npm install cropperjs --save
-
If you don’t have it yet, install the typescript definition (if you had cropperjs in your project before, skip)
typings install dt~cropperjs --save --global
-
IMPORTANT STEP The typescript definition isn’t compatible with the last version of cropperjs, therefore you have to edit manually. Edit file “typings/globals/cropperjs/index.d.ts” and replace following line of code (at the end of the file)
export = Cropper;
with
export default Cropper;
Note: This is the fix to the issue we discussed before with the last version of the library.
5 Update or add to your gulp file a task to include the cropperjs stylesheet in your build. For those who had cropperjs before in their project, note the new subpath “/dist” instead of “/src/scss”
gulp.task('sass', function(){
return buildSass({
sassOptions: {
includePaths: [
'node_modules/ionic-angular',
'node_modules/ionicons/dist/scss',
'node_modules/cropperjs/dist'
]
}
});
});
6 cropperjs isn’t shipped anymore with a scss file but with a less file. that’s why you can’t include the source stylesheet anymore, but, luckily, scss let you include css file. Therefore, update or add in your app.core.scss following import:
@import "cropper";
Note: Yes that’s right, without any extension to “cropper”. Explicitly works like this for me.
7 The typescript code remain the same as described above except the import of the library which should now be done like following:
import Cropper from 'cropperjs';
Note: As you see, no more “* as” in the import. This was indicated by the creator of the library, see https://github.com/fengyuanchen/cropperjs/issues/94#issuecomment-249396533 for mor details
That’s it. Hope it will work for you too.
P.S.: about an update of the definition file, I opened following issue:
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11482