avoidwork / filesize.js

JavaScript library to generate a human readable String describing the file size
https://filesizejs.com
BSD 3-Clause "New" or "Revised" License
1.61k stars 97 forks source link

"use strict" out of function started to be global after compression #88

Closed ivmakk closed 7 years ago

ivmakk commented 7 years ago

After using of the package in compression job (joining list of files to single assert, like UglifyJS) "use strickt" will be placed in global scope.

For providing isolation of libraries scope better to move "use strict" usage into function's block:

(function (global) {
    "use strict";
    // code... 
})(typeof window !== "undefined" ? window : global);
avoidwork commented 7 years ago

That's the result of https://github.com/mishoo/UglifyJS so you can open a bug there.

avoidwork commented 7 years ago

btw, technically there's no difference as it's packaged by the build task. 'use strict' is scoped to the script which is correct. repackaging the lib is not my concern. i'm not even sure why you'd be running code that didn't work with 'use strict'.

avoidwork commented 7 years ago

You would also want to file a bug with https://github.com/babel/babili for the minified es6 file.