Skip to content

publish es5-compatible version on npm #6

@fczuardi

Description

@fczuardi

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:

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions