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

Wrong js concatenating after minification in some cases #266

Open
ogorodnikovInfopulse opened this issue Feb 2, 2023 · 0 comments
Open

Comments

@ogorodnikovInfopulse
Copy link

If we have setup like

//Concatenate all to one file and minify this file
pipeline.AddBundle(path, contentType, files)
             .EnforceFileExtensions(".js")
             .Concatenate() 
             .MinifyJavaScript()

and if some files are already minified, we will minify them one more time. It's wrong.

If we change sutup like

//Minify all non minified files and then concatenate .min to one file
pipeline.AddBundle(path, contentType, files)
            .EnforceFileExtensions(".js")
            .MinifyJavaScript()
            .Concatenate()

to minify all except already minified, then it's possible when

  • one js file ends with anonymous immediately invoked function
  • and next file starts with anonymous immediately invoked function

we need to add separator ';' to avoid wrong syntax like

(function(){})()(function(){})()

when correct syntaxt is (function(){})();(function(){})();

I guess the best solution is to add separator as parameter in .Concatenate() to have setup like

pipeline.AddBundle(path, contentType, files)
             .EnforceFileExtensions(".js")
             .MinifyJavaScript()
             .Concatenate(";") //with custom separator

Or add this separator as default between js files

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

No branches or pull requests

1 participant