angular2-img-cropper icon indicating copy to clipboard operation
angular2-img-cropper copied to clipboard

Doesn't support webpack? How to make it work?

Open miliu99 opened this issue 8 years ago • 16 comments

I'm using webpack for my project. npm start has no error, but the brower console shows

Uncaught SyntaxError: Unexpected token export
    at Object.<anonymous> (main.js:555)
    at __webpack_require__ (vendor.js:51)
    at eval (eval at <anonymous> (main.js:49), <anonymous>:22:25)
    at Object.<anonymous> (main.js:49)
    at __webpack_require__ (vendor.js:51)
    at eval (eval at <anonymous> (main.js:5), <anonymous>:4:20)
    at Object.<anonymous> (main.js:5)
    at __webpack_require__ (vendor.js:51)
    at webpackJsonpCallback (vendor.js:22)
    at main.js:1

Clicking main.js, it points to: eval("// core\nexport { ImageCropperModule } from './src/imageCropperModule';\nexport { ImageCropperComponent } from './src/imageCropperComponent';\n// extra classes\nexport { ImageCropper } from './src/imageCropper';\nexport { CropperSettings } from './src/cropperSettings';\nexport { CropperDrawSettings } from './src/cropperDrawSettings';\n// models\nexport { Bounds } from './src/model/bounds';\nexport { CropPosition } from './src/model/cropPosition';\n//# sourceMappingURL=index.js.map\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9+L25nMi1pbWctY3JvcHBlci9pbmRleC5qcz9iZmM4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0FBQ0EsUUFBUSxxQkFBcUI7QUFDN0IsUUFBUSx3QkFBd0I7QUFDaEM7QUFDQSxRQUFRLGVBQWU7QUFDdkIsUUFBUSxrQkFBa0I7QUFDMUIsUUFBUSxzQkFBc0I7QUFDOUI7QUFDQSxRQUFRLFNBQVM7QUFDakIsUUFBUSxlQUFlO0FBQ3ZCIiwiZmlsZSI6IjM4NS5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vIGNvcmVcbmV4cG9ydCB7IEltYWdlQ3JvcHBlck1vZHVsZSB9IGZyb20gJy4vc3JjL2ltYWdlQ3JvcHBlck1vZHVsZSc7XG5leHBvcnQgeyBJbWFnZUNyb3BwZXJDb21wb25lbnQgfSBmcm9tICcuL3NyYy9pbWFnZUNyb3BwZXJDb21wb25lbnQnO1xuLy8gZXh0cmEgY2xhc3Nlc1xuZXhwb3J0IHsgSW1hZ2VDcm9wcGVyIH0gZnJvbSAnLi9zcmMvaW1hZ2VDcm9wcGVyJztcbmV4cG9ydCB7IENyb3BwZXJTZXR0aW5ncyB9IGZyb20gJy4vc3JjL2Nyb3BwZXJTZXR0aW5ncyc7XG5leHBvcnQgeyBDcm9wcGVyRHJhd1NldHRpbmdzIH0gZnJvbSAnLi9zcmMvY3JvcHBlckRyYXdTZXR0aW5ncyc7XG4vLyBtb2RlbHNcbmV4cG9ydCB7IEJvdW5kcyB9IGZyb20gJy4vc3JjL21vZGVsL2JvdW5kcyc7XG5leHBvcnQgeyBDcm9wUG9zaXRpb24gfSBmcm9tICcuL3NyYy9tb2RlbC9jcm9wUG9zaXRpb24nO1xuLy8jIHNvdXJjZU1hcHBpbmdVUkw9aW5kZXguanMubWFwXG5cblxuLyoqKioqKioqKioqKioqKioqXG4gKiogV0VCUEFDSyBGT09URVJcbiAqKiAuL34vbmcyLWltZy1jcm9wcGVyL2luZGV4LmpzXG4gKiogbW9kdWxlIGlkID0gMzg1XG4gKiogbW9kdWxlIGNodW5rcyA9IDBcbiAqKi8iXSwic291cmNlUm9vdCI6IiJ9");

miliu99 avatar Apr 08 '17 01:04 miliu99

Same issue. Using webpack and "ng2-img-cropper": "^0.8.6"

curtiscovington avatar Apr 09 '17 17:04 curtiscovington

Hello, I am going to need more info on this. Tried with a fork of: https://github.com/AngularClass/angular2-webpack-starter

and worked perfectly: image

here is a gist: https://gist.github.com/cstefanache/8c5590afedba56d55f84f62bdecba269

cstefanache avatar Apr 21 '17 04:04 cstefanache

Hi.. I have same issue "Unexpected token export" with webpack. This library works perfectly fine with systemJs. Please suggest a possible solution.

Thanks in advance :)

crossme avatar Apr 24 '17 08:04 crossme

Try [email protected], working for me. 0.8.6 doesn't, probably because of #148.

image

c-geek avatar Apr 26 '17 13:04 c-geek

The error I get with [email protected] is Processing of node_modules/ng2-img-cropper/index.js failed. SyntaxError: 'import' and 'export' may only appear at the top level (6:0)

I'm using brunch http://brunch.io/.

c-geek avatar Apr 26 '17 13:04 c-geek

do you have babel-preset-es2015 preset for babel installed?

cstefanache avatar Apr 26 '17 13:04 cstefanache

Yes I had it, but because of this bug I removed babel to be sure it wasn't involved. And I still had the upper error message.

c-geek avatar Apr 26 '17 13:04 c-geek

I'll try to do another release in few minutes with another trial

cstefanache avatar Apr 26 '17 13:04 cstefanache

I will test it for sure.

c-geek avatar Apr 26 '17 13:04 c-geek

OK I was probably wrong about #148, because [email protected] is working. But not >= 0.8.4.

c-geek avatar Apr 26 '17 13:04 c-geek

I am going to try to publish it with commonjs as module and see if it works edit: problem is that if I am going to introduce .ts files again people will start complaining from the other side!

cstefanache avatar Apr 26 '17 13:04 cstefanache

can you give it a try? 0.8.8 published with tree-shaking & all

cstefanache avatar Apr 26 '17 13:04 cstefanache

Perfect with 0.8.8 :+1:

c-geek avatar Apr 26 '17 13:04 c-geek

Will close if the rest of the people will agree with you. Thank you for your help

cstefanache avatar Apr 26 '17 13:04 cstefanache

Thank you a lot for angular2-img-cropper, you saved me a lot of work!

c-geek avatar Apr 26 '17 13:04 c-geek

Hehe, glad to help. I am going to add more features soon - the irony is that I am not using Angular2 - just needed a cropper for a test of mine

cstefanache avatar Apr 26 '17 13:04 cstefanache