I am watching this video : https://www.youtube.com/watch?v=kHifDVw5t_w . And in this video it is mentioned that uglify-js
does not support es6 and above version of js. But when I try to minify js code(Es6 and above) with the help of uglify-js
, it is perfectly minify the js file and did not throw any error.
Asked
Active
Viewed 3,773 times
2

Vikas Sharma
- 31
- 1
- 5
1 Answers
3
You should rely on official documentation instead of random YouTube videos:
Note:
- uglify-js supports JavaScript and most language features in ECMAScript.
- For more exotic parts of ECMAScript, process your source file with transpilers like Babel before passing onto uglify-js.
- uglify-js@3 has a simplified API and CLI that is not backwards compatible with uglify-js@2.
You should be fine unless you are using features such as optional chaining that were only recently added to the standard, in which case the module authors simply haven't had enough time to add support.
-
1Terser's page is misleading in that case, as it says: "uglify-js does not support ES6+." I guess they refer to previous versions, and not to the newest uglify-js@3 (version 3) - but - still misleading. Anyhow, seems that uglify-js@3 indeed supports ES6... – Ronen Rabinovici Nov 16 '22 at 14:50