Hi,
I'm using jsdelivr to serve some my libraries directly from npm, and I find the minification feature very useful.
The only problem is, that it does not support ES6 code, so adding .min.js to a filename produces an error message and keeps the file as is.
I've noticed that you're using UglifyJS, and seems like it does not support ES6, so I assume that is the root of the problem.
Hi @bluzi,
as you noticed, UglifyJS doesn't support ES2015+, which is why jsDelivr doesn't support it as well. I just checked and there's a relatively new package uglify-es, which didn't exist a few months back when we launched this feature. At some point, we'll definitely add support for minification of ES2015+ code, and possibly also support for transpiling it to ES5.
In the meantime, you should ship ES5 code, not only because of jsDelivr, but also because of older browsers that don't support all new features yet.
you should ship ES5 code
I can understand opinionation, but no generators (transcompiler hell)? Uglify strict mode by default?
@0joshuaolson1 sorry I don't think I understand what you are suggesting.
@MartinKolarik Hi, I interpreted the comment I quoted to imply this enhancement has low priority.
UglifyJS (on the topic of opinionation) and transpilers both have their problems. jsdelivr uses the former, and apparently for ES6 libraries requires the latter.
Perhaps out of scope for this issue, major browsers support some ES7 features as well. Something to think about.
We're planning to add support for modern JS in the near future - that includes minification of ES2015+, bundling and/or other way of handling modules, and possibly also transpiling.
@martinheidegger Any updates? It's been nearly a year since you last commented, and you removed your assignment around a six weeks ago. Terser is the lastest uglification library, forked from UglifyES.
@jhpratt: I think you meant @MartinKolarik
Sorry guys, this is still planned but no ETA yet.
@MartinKolarik Anything the community can do to help you get this prioritized? Any word on timing?
We've just shipped an update that replaces UglifyJS with Terser 馃帀
ES2015+ code should now minify correctly. If you find a file which already failed to minify using Uglify and is cached at the CDN, let me know and I'll purge the cache.
@MartinKolarik
If you find a file which already failed to minify using Uglify and is cached at the CDN, let me know and I'll purge the cache.
An example: https://cdn.jsdelivr.net/npm/[email protected]/index.min.js
Don't you have an automated script to purge cache automatically if errored?
Don't you have an automated script to purge cache automatically if errored?
We respond with the original file in that case, so it's technically not an error response and we don't keep a list of all files that failed. The advantage of this approach is that you can make automated requests for minified files and the result is always a file that works, even if it failed to minify.
I also realized I was wrong and we're not easily able to purge the files that previously errored because they are also stored in our own persistent storage and deleting files from there is too complicated :(
they are also stored in our own persistent storage and deleting files from there is too complicated
This is kind of joke, right?
So in case of malwared files you don't delete the files either? 馃ぃ
Files can be blocked at the application layer and then it doesn't really matter whether they are still stored anywhere, they won't be accessible.
C'mon, don't tell me that you cannot delete files in the system you designed. We do live in XXI century, don't we?
I never said that. Just that it isn't so easy that I'd be willing to do it for every link posted here.
Just that it isn't so easy that I'd be willing to do it for every link posted here.
That's OK for as long as it works out.
Most helpful comment
We're planning to add support for modern JS in the near future - that includes minification of ES2015+, bundling and/or other way of handling modules, and possibly also transpiling.