thibaudcolas / draftjs-conductor

📝✨ Little Draft.js helpers to make rich text editors “just work”
https://thibaudcolas.github.io/draftjs-conductor
MIT License
40 stars 6 forks source link

UglifyJs error #288

Closed varunarora closed 2 years ago

varunarora commented 3 years ago

https://github.com/thibaudcolas/draftjs-conductor/blob/e8abd65b653f6eca239d4119ba635ada34bc0b0a/src/lib/api/copypaste.js#L142

This line is giving my UglifyJS webpack config this error:

ERROR in app.js from UglifyJs
Unexpected token: punc (() [app.js:<line number>, <col number>]

Possible to resolve somehow?

thibaudcolas commented 2 years ago

Hi @varunarora,

Most likely this is because UglifyJS doesn’t understand this syntax. This shorthand method definition syntax is valid JS.

For the published draftjs-conductor package, the syntax is automatically converted to valid ES5 code for the best compatibility:

unregister: function unregister() {
      editorElt.removeEventListener("copy", onCopyCut);
      editorElt.removeEventListener("cut", onCopyCut);
    }

Please make sure you’re using the published package on the npm registry – this is the only supported way to use this project.