failwyn / WebCompiler

Visual Studio extension for compiling LESS and Sass files
Other
77 stars 16 forks source link

Disable "use strict" on minifying javascript #50

Open ElStupid opened 2 years ago

ElStupid commented 2 years ago

Installed product versions

Description

A compilerconfig.json option for using "use strict" in javascript minification is highly wanted. It has been asked in Mads' version multiple times, but never created. Now the compiled version of a javascript file always has the "use strict" statement whenever we use Webcompiler, Re-compile file. It also recompiles all files when you add a new js to the compilerconfig and thus add the "use strict" again.

Steps to recreate

  1. create a simple js file, without the "use strict" statement.
  2. minify it
  3. confirm the minified version does not have "use strict" statement.
  4. choose re-compile file
  5. confirm the minified version has the "use strict" statement

Current behavior

Re-compiled minified javascript files get the "use strict" statement by default. This is unwanted, because if one would like to use strict, one should enable that in unminified javascript or have an option to enable it. In which case the minifier should use it too. There's no option to switch off this behavior in compilerconfig.

Expected behavior

Have an option in compilerconfig.json. enabled by default. When set to disabled and no statement in unminified version, the minified version shouldn't have it too. Only when enabled by default or explicitly set, we should get "use strict" in the minified javascript file.

ElStupid commented 2 years ago

Updated problem description above. The "use strict" is only generated when Re-compile file is chosen.

ElStupid commented 1 year ago

@failwyn Any updates on this issue? I read more people suffer from this. I have a lot of troubles with minified files. It would be very usefull to have an option for this (maybe on a per file basis)

failwyn commented 1 year ago

@ElStupid I’ll take a look at it; I’m trying to wait for a new NUglify release to fix a few issues as well.