You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using it as a dependency on a code that gets compressed using uglify-js, and as it is it doesnt support es6 and the process fail because of the let keyword and because the use of string literals `:
Errors:
Parse error at dist/www/bundle.js:38333,6
let milli = Math.abs(isNaN(+t2) ? t1 : t2 - t1);
^
SyntaxError: Unexpected token: name (milli)
at JS_Parse_Error.Object.defineProperty.get (eval at <anonymous> (/Users/fabricio/20k/road/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:86:23)
at /Users/fabricio/20k/road/node_modules/uglify-js/bin/uglifyjs:384:39
at time_it (/Users/fabricio/20k/road/node_modules/uglify-js/bin/uglifyjs:620:15)
at /Users/fabricio/20k/road/node_modules/uglify-js/bin/uglifyjs:345:9
at tryToString (fs.js:449:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436:12)
Parse error at dist/www/bundle.js:38354,9
return `${n + (mode === 'short' ? '' : ' ')}${unit}${mode === 'short' || n ===
^
SyntaxError: Unexpected character '`'
at JS_Parse_Error.Object.defineProperty.get (eval at <anonymous> (/Users/fabricio/20k/road/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:86:23)
at /Users/fabricio/20k/road/node_modules/uglify-js/bin/uglifyjs:384:39
at time_it (/Users/fabricio/20k/road/node_modules/uglify-js/bin/uglifyjs:620:15)
at /Users/fabricio/20k/road/node_modules/uglify-js/bin/uglifyjs:345:9
at tryToString (fs.js:449:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436:12)
Maybe we can either just replace those two lines with var and regular strings, or add a npm script to run the lib through babel with es2020 preset before publishing to npm.
I can create a PR for either option if you want :)
The text was updated successfully, but these errors were encountered:
one workaround for people creating bundles with browserify is to use viralify to inject your es6 transform(es2020, es2040, babelify) in the package, something like this should work:
Thanks for bring this to my attention. Sorry it took me a while to respond. It seems like publishing ES5 code to npm is still the norm. Since converting a few declarations and strings is pretty easy, there are no dependencies, and it'll be compatible with the newer Node versions we already support, I think we should convert to both ES5 source and published code (I would like to keep those the same).
If you're still up for it, I'd be happy to review a PR!
Hi, thanks for the package.
I am using it as a dependency on a code that gets compressed using uglify-js, and as it is it doesnt support es6 and the process fail because of the let keyword and because the use of string literals `:
Errors:
Maybe we can either just replace those two lines with var and regular strings, or add a npm script to run the lib through babel with es2020 preset before publishing to npm.
I can create a PR for either option if you want :)
The text was updated successfully, but these errors were encountered: