AlexCuse / SquishIt

Lets you *easily* bundle some css and javascript! Check out the Google group if you have questions!
http://groups.google.com/group/squishit
MIT License
4 stars 1 forks source link

Javascript function with async gets ignored #25

Open danieljurican opened 3 years ago

danieljurican commented 3 years ago

Hi. I am having problem with minified js files,... When I use javascript function like below (calling async), it gets ignored by SquishIt. Function is missing from minified version. I am using version 1.0.4 (same is with version 0.9).

example 1:

async function postData(url = '', data = {}) {           
            const response = await fetch(url, {
                method: 'POST', // *GET, POST, PUT, DELETE, etc.
                mode: 'cors', // no-cors, *cors, same-origin
                cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
                credentials: 'same-origin', // include, *same-origin, omit
                headers: {
                    'Content-Type': 'application/json'
                    // 'Content-Type': 'application/x-www-form-urlencoded',
                },
                redirect: 'follow', // manual, *follow, error
                referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
                body: JSON.stringify(data) // body data type must match "Content-Type" header
            });
            return response.json(); // parses JSON response into native JavaScript objects
        }

example 2:


function sweetAlertOpen() {
    (async () => {

        const { value: formValues } = await Swal.fire({
            title: 'Sweetalert title....',
            type: 'info',
...
AlexCuse commented 3 years ago

This is usually an issue with the minifier itself. If you are using the default (MS ajax) you can try using it with yahoo with something like:

Configuration.Apply(iso => iso.DefaultMinifier = new Minifiers.Javascript.YUIMinifier())

or similar. I am not really doing much .net stuff lately but if this doesn't help I can probably get set up in a couple days. You can look at the configuration options available to either minifier as well - maybe just need to set them up to allow async or something. If you find anything about a minimum version of ajax min or yui I will look into what we can do here to support it as well.

Out of curiosity what asp.net etc versions are you using?

AlexCuse commented 3 years ago

(do the above in your startup pipeline somewhere, you can also change at the bundle level using .WithMinifier method)

danieljurican commented 3 years ago

I am working on ASP.NET 4 (Web forms project, VB.NET)

Where exactly should I put WithMinifier method,... I am using bundle now with line: Bundle.JavaScript().RenderNamed("combojs")

EDIT: I think I found solution: Bundle.JavaScript().WithMinifier(Of Minifiers.JavaScript.YuiMinifier).RenderNamed("combojs")

AlexCuse commented 3 years ago

Sorry for the late reply - I could have sworn I sent before. I think this is right but I don't really know VB.net.

I assume this worked for you?