In previous versions it was possible to create a new Croppie instance using:
import Croppie from 'croppie';
var croppie = new Croppie(ref, opts);
Following the latest update this is no longer possible, you need to use the following syntax for it to work:
import Croppie from 'croppie';
var croppie = new Croppie.Croppie(ref, opts);
Is this an intended change in how the library is supposed to be used with npm, or is there something wrong?
Thanks for the nice submission. Nice to see that the new issue template is finally getting some use.
No this wasn't an intended change. I would say this PR is responsible for this change.
https://github.com/Foliotek/Croppie/pull/452
@sarunint If you and @oystehei could figure out a nice compromise for this case, I'll gladly change the file and create a new version asap.
Do any of these definitions resolve your guys' problems? https://github.com/umdjs/umd
Unfortunately, in my projects with Croppie, I haven't gotten the chance to upgrade to webpack/requirejs/commonjs etc. So I don't have a good setup to test with.
I have the same problem (2.6.1) :
When I use
this.croppie = new Croppie.Croppie(this.croppieElement.nativeElement, { ... });
I get
core.js:1427 ERROR TypeError: Cannot read property 'Croppie' of undefined
and when I use
this.croppie = new Croppie(this.croppieElement.nativeElement, { ... });
I get
ERROR TypeError: croppie_1.default is not a constructor
Second approach worked up until I updated to 2.6.1.
Edit: I solved it with changing :
import Croppie from 'croppie';
to
import { Croppie } from 'croppie/croppie';
OK, I'll need to look into how to import Croppie in different build systems.
I'll take a look tomorrow.
Any news??
Update:
I've been spending today trying to convert Croppie to more modern Javascript. (I mean ES2015.)
I'm expecting it to be done next week.
Update 2:
The quick fix is going to be in #479. After this, I shall try to convert them to ES2015.
Most helpful comment
I have the same problem (2.6.1) :
When I use
this.croppie = new Croppie.Croppie(this.croppieElement.nativeElement, { ... });I get
and when I use
this.croppie = new Croppie(this.croppieElement.nativeElement, { ... });I get
Second approach worked up until I updated to 2.6.1.
Edit: I solved it with changing :
import Croppie from 'croppie';to
import { Croppie } from 'croppie/croppie';