cujojs / curl

curl.js is small, fast, extensible module loader that handles AMD, CommonJS Modules/1.1, CSS, HTML/text, and legacy scripts.
https://github.com/cujojs/curl/wiki
Other
1.88k stars 216 forks source link

Including curl after jQuery undefines everything under $? #114

Closed ghost closed 12 years ago

ghost commented 12 years ago

I don't know what went on in the past few months since I last pulled an update, but the current version is just breaking everything left and right.

ghost commented 12 years ago

Even if I bring in curl before jquery, I suddenly have no $.location defined.

I'm using the one explicitly labeled curl-for-jQuery.

unscriptable commented 12 years ago

Hey @khiltd,

I'm not seeing this problem. Actually, I'm not sure what $.location is. I see other properties on the $ object, though. Can you elaborate or post a code sample?

Thanks!

-- John

ghost commented 12 years ago

Absolutely:

<!DOCTYPE html>
<html>
<head>
    <title>Curl's Broken</title>

    <script type="text/javascript" src="/js/jquery/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="/js/curl.js/dist/curl-for-jQuery/curl.js"> </script>

    <script type="text/javascript">

        (function() 
        {
            var test = $.Deferred()

            console.log(test)

        })();

    </script>

</head>

<body>
</body>
</html>

Watch the console spew as curl jacks up jQuery.

Reverse the order, and suddenly it works. This is highly undesirable behavior.

ghost commented 12 years ago

As for what $.location is: I'm not too sure myself. It's in the curl.js source and comes up undefined.

.fixSchemalessUrls:$.location.protocol)?a.replace(ua,c+"//"):
unscriptable commented 12 years ago

This appears to be an issue with closure compiler. I found a way to prevent it from clobbering $, but I'm concerned that it's also spitting out dozens of global vars now.

ghost commented 12 years ago

Interesting. I always stick to the less-intelligent minifiers.

One thing that would be tremendously useful is if the build script took a flag telling it whether or not to minify at all so those of us who are merely tourists in the source base can more readily debug such things ourselves and opt to use alternate means of compression if we so desire.

unscriptable commented 12 years ago

Interesting. I always stick to the less-intelligent minifiers.

words of wisdom :)

Found the new closure compiler "feature": http://code.google.com/p/closure-compiler/wiki/FAQ#When_using_Advanced_Optimizations,_Closure_Compiler_adds_new_var

One thing that would be tremendously useful is if the build script took a flag telling it whether or not to minify at all so those of us who are merely tourists in the source base can more readily debug such things ourselves and opt to use alternate means of compression if we so desire.

yah, it's hard-coded into compile.sh atm. Those files are supposed to be temporary until the "real" optimizer is ready. :)