Ticket #2528054 (closed task)

Reporter


Robert Tsai
Opened: 07/24/10
Last modified: 08/13/10
Status: closed
Type: task
Resolution: wontfix

Owner


Reid Burke
Target Release:
Priority: P3 (normal)
Summary: [Pull Request] - Add a new --globals option to pre-declare global variables; e.g., "YUI"
Description:

The idea is for YUI Build Tool to invoke the compressor with "--globals YUI" to avoid all the extraneous "[WARNING] Found an undeclared symbol: YUI" messages.

--robtsai@yahoo-inc.com

Type: task Observed in Version: development master
Component: YUICompressor Severity: S3 (normal)
Assigned To: Reid Burke Target Release:
Location: Priority: P3 (normal)
Tags: pull request, github Relates To:
Browsers: All
URL: http://github.com/rtsai/yuicompressor/commit/a04c8d4239b69db2c3e1172f52f006e8c8f2cadf
Test Information:

Change History

Robert Tsai

Posted: 07/24/10

Eric Miraglia

YUI Contributor

Posted: 07/24/10

Eric Miraglia

YUI Contributor

Posted: 07/24/10

Reid Burke

YUI Developer

Posted: 08/10/10
  • status changed from assigned to accepted

Reid Burke

YUI Developer

Posted: 08/10/10

Reid Burke

YUI Developer

Posted: 08/10/10
  • component changed from None to YUICompressor
  • milestone changed to NEXT
  • owner changed from Reid Burke to Adam Moore
  • status changed from checkedin to assigned
  • version changed to development master

Signed off.

Reid Burke

YUI Developer

Posted: 08/10/10

Reid Burke

YUI Developer

Posted: 08/10/10
  • status changed from assigned to checkedin

Signed off.

Adam Moore

YUI Contributor

Posted: 08/10/10

I've already removed the warning, so this patch should not be necessary. From the latest github source:

if (symbol.length() <= 3 && !builtin.contains(symbol)) {
// Here, we found an undeclared and un-namespaced symbol that is
// 3 characters or less in length. Declare it in the global scope.
// We don't need to declare longer symbols since they won't cause
// any conflict with other munged symbols.
globalScope.declareIdentifier(symbol);

// I removed the warning since was only being done when
// for identifiers 3 chars or less, and was just causing
// noise for people who happen to rely on an externally
// declared variable that happen to be that short. We either
// should always warn or never warn -- the fact that we
// declare the short symbols in the global space doesn't
// change anything.
// warn("Found an undeclared symbol: " + symbol, true);
}

Adam Moore

YUI Contributor

Posted: 08/10/10
  • milestone changed from NEXT
  • status changed from checkedin to reopened

Adam Moore

YUI Contributor

Posted: 08/10/10
  • status changed from reopened to infoneeded

Reid Burke

YUI Developer

Posted: 08/10/10
  • status changed from infoneeded to assigned

Adam: Okay. Shouldn't the appropriate fix be to always warn, regardless of symbol length, unless specified in --globals?

Adam Moore

YUI Contributor

Posted: 08/10/10

I don't think the globals option is necessary at all (this warning was removed some time ago -- before this patch). I think the warning was a red herring, possibly because at one time the compressor didn't handle the potential collision with short symbols (the compressor generates symbols for obfuscation up to 3 chars in length). It does handle this now, so there isn't really anything to warn about.

Adam Moore

YUI Contributor

Posted: 08/10/10

My suggestion is to revert the patch; the warning has already been removed.

Reid Burke

YUI Developer

Posted: 08/10/10

Adam: Thanks for your explanation. I was testing this change with an older YUI Compressor we're using for our build system which doesn't have your patch.

I'll revert it.

Reid Burke

YUI Developer

Posted: 08/10/10
  • resolution changed to wontfix
  • status changed from assigned to closed

Reverted on yuisource.

Robert Tsai

Posted: 08/13/10

Is there another yuicompressor branch somewhere that I should be using? Using http://github.com/yui/yuicompressor , I see the following in my build output:

YuiSharedTargets.minify:
[echo] Running yuicompressor on /Users/rob/work/myphotos/messageread/src/apiclients/build_tmp/pp-ymailclient.js
[java]
[java] [WARNING] Found an undeclared symbol: YUI
[java] ---> YUI <--- .add("pp-ymailclient",function(Y){
[echo] Running yuicompressor on /Users/rob/work/myphotos/messageread/src/apiclients/build_tmp/lang/pp-ymailclient.js

Adam Moore

YUI Contributor

Posted: 08/13/10

Sorry about that, I hadn't checked in one of the changes that gets rid of that. It is there now.