Просмотр исходного кода

@uppy/image-editor: add workaround for when `Cropper` is loaded as ESM (#3218)

* @uppy/image-editor: add workaround for when `Cropper` is loaded as ESM

Fixes: https://github.com/transloadit/uppy/issues/3199

* Update packages/@uppy/image-editor/src/Editor.js

Co-authored-by: Kevin van Zonneveld <kevin@vanzonneveld.net>

* Add backlog entry

Co-authored-by: Kevin van Zonneveld <kevin@vanzonneveld.net>
Antoine du Hamel 3 лет назад
Родитель
Сommit
46b0540e92
2 измененных файлов с 6 добавлено и 1 удалено
  1. 1 0
      BACKLOG.md
  2. 5 1
      packages/@uppy/image-editor/src/Editor.js

+ 1 - 0
BACKLOG.md

@@ -30,6 +30,7 @@ PRs are welcome! Please do open an issue to discuss first if it's a big feature,
 ## `3.0.0`
 
 - [ ] Switch to ES Modules (ESM)
+- [ ] @uppy/image-editor: Remove silly hack to work around non-ESM.
 
 ## `4.0.0`
 

+ 5 - 1
packages/@uppy/image-editor/src/Editor.js

@@ -1,6 +1,10 @@
-const Cropper = require('cropperjs')
+const CropperImport = require('cropperjs')
 const { h, Component } = require('preact')
 
+// @TODO A silly hack that we can get rid of when moving to ESM.
+// eslint-disable-next-line no-underscore-dangle
+const Cropper = CropperImport.__esModule ? CropperImport.default : CropperImport
+
 module.exports = class Editor extends Component {
   constructor (props) {
     super(props)