sindresorhus / cli-truncate

Truncate a string to a specific width in the terminal
MIT License
85 stars 14 forks source link

Transpiling ES6 to ES5 on "prepublish" -> fixing Safari "const" #4

Closed thgala closed 7 years ago

thgala commented 7 years ago

Current library uses ES6 code in main output file. Safari 10.11.* (El Captain) does not support ES6 "const" in "strict mode" (as well as arrow functions). Original console error message: "Const declarations are not supported in strict mode".

On "prepublish" command I suggest transpile all ES6 code (include node_modules) to ES5, minify and make ES5 /lib/bundle.js as a main library file (for NPM). In github ES6 source code will be available in /src folder.

sindresorhus commented 7 years ago

This module mainly targets Node.js, not the browser. It's up to you to transpile it with Babel if you want to use it in the browser. You can find a more detailed explanation here: https://github.com/sindresorhus/ama/issues/446