untyped / sbt-plugins

SBT plugins for Javascript, Coffeescript, LESS, SASS, and Mustache compilation
73 stars 23 forks source link

VariableRenamingPolicy.OFF makes no difference #45

Closed magnusart closed 10 years ago

magnusart commented 10 years ago

Hi

If I use sbt-js and set the configuration (JsKeys.variableRenamingPolicy in Compile) := VariableRenamingPolicy.OFF it makes no difference. The variables are still renamed to shorter names.

However if I change the configuration as follows (JsKeys.compilationLevel in (Compile, JsKeys.js)) := CompilationLevel.WHITESPACE_ONLY the variable names are not shortened.

I'm using AngularJS which is picky about this. Plugin version 0.6.

davegurnell commented 10 years ago

Hi Magnus,

Thanks for the heads up. It looks like there's a bug in the scoping here:

https://github.com/untyped/sbt-plugins/blob/develop/sbt-js/src/main/scala/com/untyped/sbtjs/Plugin.scala#L134

Your intuition of scoping against JsKeys,js should work around the problem:

(JsKeys.variableRenamingPolicy in (Compile, JsKeys,js)) :=

VariableRenamingPolicy.OFF

These JS-specific keys shouldn't be scoped by task. I'll work on fixing this in the next release.

Best regards,

Dave

On 7 January 2014 22:02, Magnus Andersson notifications@github.com wrote:

Hi

If I use sbt-js and set the configuration (JsKeys.variableRenamingPolicy in Compile) := VariableRenamingPolicy.OFF it makes no difference. The variables are still renamed to shorter names.

However if I change the configuration as follows (JsKeys.compilationLevel in (Compile, JsKeys.js)) := CompilationLevel.WHITESPACE_ONLY the variable names are not shortened.

I'm using AngularJS which is picky about this. Plugin version 0.6.

— Reply to this email directly or view it on GitHubhttps://github.com/untyped/sbt-plugins/issues/45 .

Dave Gurnell, Untyped http://untyped.com 07967 004805

magnusart commented 10 years ago

Hi

I believe I tried that as well (JsKeys.variableRenamingPolicy in (Compile, JsKeys.js)) := VariableRenamingPolicy.OFF but that didn't make any difference, or it's working but not in the way I expect.

thatsmydoing commented 10 years ago

In https://github.com/untyped/sbt-plugins/blob/develop/sbt-js/src/main/scala/com/untyped/sbtjs/Plugin.scala#L143

Shouldn't the setting options.variableRenaming = variableRenamingPolicy come after compilationLevel.setOptionsForCompilationLevel(options)? Otherwise the compilation level will overwrite the settings.

davegurnell commented 10 years ago

Hi Thomas,

That sounds like a reasonable hypothesis. I'm tied up this weekend and next week -- if you can provide a test case and PR I'll merge it in as soon as I can. Otherwise it'll be a while until I can look into it.

Dave

On 2 May 2014 10:43, Thomas Dy notifications@github.com wrote:

In https://github.com/untyped/sbt-plugins/blob/develop/sbt-js/src/main/scala/com/untyped/sbtjs/Plugin.scala#L143

Shouldn't the setting options.variableRenaming = variableRenamingPolicycome after compilationLevel.setOptionsForCompilationLevel(options)? Otherwise the compilation level will overwrite the settings.

Reply to this email directly or view it on GitHubhttps://github.com/untyped/sbt-plugins/issues/45#issuecomment-42010201 .

Dave Gurnell, Untyped http://untyped.com 07967 004805

davegurnell commented 10 years ago

PR merged with thanks.