Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to minify a js that is over 100KB #94

Open
IgnacyPawlak opened this issue Jan 17, 2024 · 8 comments
Open

Error when trying to minify a js that is over 100KB #94

IgnacyPawlak opened this issue Jan 17, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@IgnacyPawlak
Copy link

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";

@failwyn
Copy link
Owner

failwyn commented Feb 28, 2024

Does the compact false option change anything other than the size limit?

@IgnacyPawlak
Copy link
Author

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.

@failwyn failwyn added the enhancement New feature or request label Apr 3, 2024
@failwyn
Copy link
Owner

failwyn commented Apr 3, 2024

Would the 500kb limit be sufficient for you if I just update the library?

@IgnacyPawlak
Copy link
Author

Yes it would be sufficient for now. Would appreciate that

@failwyn
Copy link
Owner

failwyn commented Jul 19, 2024

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

@IgnacyPawlak
Copy link
Author

IgnacyPawlak commented Aug 5, 2024

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

@failwyn
Copy link
Owner

failwyn commented Aug 5, 2024

@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.

@IgnacyPawlak
Copy link
Author

I did as You asked:
Just the option for babel:
#102
Just the net48 upgrade:
#103

remember to delete the nuget folder from C:/Users/User/.nuget
by default its called buildwebcompiler2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants