WebCompiler
WebCompiler copied to clipboard
Error when trying to minify a js that is over 100KB
When trying to minify a js that is over 100KB there is a warning from babel:
Warning [BABEL] Note: The code generator has deoptimised the styling of "path/to/file" as it exceeds the max of "100KB".
Even though its a warning, it prevents from starting an application.
To Reproduce Steps to reproduce the behavior:
Create a js file that is over 100KB Minify Add to minify on build See error Expected behavior There should be babel option in config that allows to change compact property to false
Additional context It is an easy fix (Done it myself locally). Steps to fix: in BabelOptions.cs add: [JsonProperty("compact")] public bool Compact { get; set; }
in BabelCompiler.cs ConstructArguments method add: if (!options.Compact) arguments += " --compact false";
Does the compact false option change anything other than the size limit?
Research I did indicate that version of babel used in this extension limits the file size to 100KB and latest version has this limit set to 500KB. Official documentation says that option "compact" defaults to "auto" which has the following effect: ""auto" will set the value by evaluating code.length > 500_000" So it should affect anything else.
Would the 500kb limit be sufficient for you if I just update the library?
Yes it would be sufficient for now. Would appreciate that
I'm trying to get a new version out, but I am getting errors trying to update the node_modules... I'm getting errors from node-gyp compiling node-sass. Is anyone able to rebuild the node_module.7z file using the build.cmd file?
// I may have to drop node_sass support if I cannot get this working
I couldnt do anything about babel version itself so I went with my initial idea of adding an option. This option doesnt do much at all so I don't see a reason why not to implement it (https://babeljs.io/docs/options#compact).
In this PR I also changed old referencing scheme (from net4.8 to net48). It caused me some issues specifically when building i had 4 folders instead of 3 (net4.8 with just .dll files, net48 with only .exe file, netcoreapp3.1 with .dll files, netstandart2.1 with .dll files). What I found interesting when testing is that even though I created a test app in .net 8 when building MSBuildRuntimeType was Full instead of Core. It happened when I was building the solution using Visual Studio 2022 and with msbuild. When I run dotnet build this variables value was Core. Next thing I had some problems with was msbuild RunWebCompiler variable which I had to specify in .csproj of my testing app manually
@IgnacyPawlak Thanks, I'll take a look at your PR as soon as I can; I tried fixing the referencing scheme in the past, but every time I changed it from net4.8 to net48, it messed up the nuget package... If you could break this up into two PR's it would be easier; one for the babel option and one for the referencing scheme.
I did as You asked: Just the option for babel: https://github.com/failwyn/WebCompiler/pull/102 Just the net48 upgrade: https://github.com/failwyn/WebCompiler/pull/103
remember to delete the nuget folder from C:/Users/User/.nuget by default its called buildwebcompiler2022