PDA

View Full Version : [FIXED] [3.0.0.181 - Ext JS 4.1.1a] unable to disable yui compression



Curtis Fletcher
4 Oct 2012, 2:15 AM
Simple question: how do I disable yui compression? it's not clear what the new command line options actually are, my assumption is that the following should disable compression (for testing, equivalent to the previous "sencha app build testing")


sencha app build -e testing
Gives me:

[INFO ] init-properties:
[INFO ]
[INFO ]
[INFO ] init-sencha-command:
[INFO ]
[INFO ]
[INFO ] init:
[INFO ]
[INFO ]
[INFO ] -before-app-build:
[INFO ]
[INFO ]
[INFO ] app-build-impl:
[INFO ]
[INFO ] Compiling page null
[INFO ] Processing classPath entry : C:\work\Webscreen_test\sencha-compile-temp-dir
[INFO ] Processing classPath entry : C:\work\Webscreen_test\ext\src
[INFO ] Processing classPath entry : C:\work\Webscreen_test\app
[INFO ] Processing class inheritance graph
[INFO ] Processing instantiation refereces to classes and aliases
[INFO ] Processing source dependencies
[INFO ] Compressing data with YuiJavascriptCompressor
[INFO ] Concatenating output to file C:\work\Webscreen_test\build\WS\all-classes.js
[INFO ]
[INFO ] -after-app-build:
[INFO ]
[INFO ]
[INFO ] app-build:
[INFO ]

The build/WS/all-classes.js file is compressed and undebuggable (and the app doesn't work but I'm not apportioning blame there until I can debug it :) )

Curtis Fletcher
4 Oct 2012, 5:02 AM
Ok, looking at the release notes included with Sencha Cmd 3.0.0.181 I see that it suggests that the correct way build an app is:

sencha ant [production|testing|native|package] build
However while

sencha app build -e testing
does build (yet compressed)

sencha ant testing build
Simply gives me:

[ERROR] Target "testing" does not exist in the project "@@@".
Looking in the build.xml I can see

<project name="@@@" default=".help">
<import file="${basedir}/.sencha/app/build-impl.xml"/>
I'm assuming that when you do "sencha app build" you get some kind of "default" ant build.xml that I'm not getting when I directly invoke sensha ant? If so How can I modify my build.xml to get roughly the seam build operation as the usual "sencha app build"

Curtis Fletcher
4 Oct 2012, 5:18 AM
Ok, looking in .sencha/app/build-impl.xml it suggests the following

The following properties can be used to disable certain steps in the buildprocess.


* skip.page Do not build the HTML page.
* skip.sass Do not build the SASS.
* skip.theme Do not build the theme images.


These options can be stored in a local.properties file in this folder or in the
local.properties file in the workspace.


Alternatively, these can be supplied on the command line. For example:


ant -Dskip.sass=1 build


To see all currently defined properties, do this:
Note is see no "testing" target in build-impl.xml but lets start with just getting it building under sencha ant first

sencha ant -Dskip.sass=1 build
Doesn't work, but looking at the help, it seem like "sencha ant -p " is the equivalent of "ant -D" hence

sencha ant -p skip.sass:1 build
Does produce a working build, but still not a debug build. So I guess now my question is:

What can I put in my build.xml that will disable yui compression?

Curtis Fletcher
4 Oct 2012, 5:41 AM
I've found a taskdef inside antlib.xml inside the sencha.jar

<taskdef name="x-compress-js" classname="com.sencha.ant.CompressJS"/>
But I can't find anywhere that this taskdef is used, I'm guessing it's generated dynamically based on a config option that we (I) don't know.

I can see that the sencha touch build process does the following in /plugins/touch/current/app-build.js

compressor = new ClosureCompressor();
microloader = (environment == 'production'
? 'production'
: 'testing') +
'.js';
but it uses a different process entirely.

I can see the css compression directives in build-impl.xml

<x-compress-css srcfile="${build-css-dir}/${sass.name}/*.css"
outdir="${build-css-dir}/${sass.name}"/>

Interesting to note that they don't seen to care about the environment either, anything that uses the build target "-sass" gets compressed css whether they like it of not.

Has anyone got Sencha Cmd v3.0.0.181 to make a testing (uncompressed) build? I'm pretty much at my investigation limit short of de-compiling java bytecode.

kkrohe
4 Oct 2012, 7:21 AM
The actual compile command execution for both extjs and touch applications is handled in the app-build target of the plug-in structure.

For all Sencha Cmd v3 applications, there is a .sencha/app folder containing application metadata, and an associated .sencha/workspace folder containing metadata related to the workspace and frameworks contained in the workspace.

Both the app and workspace metadata folders contain a file named plugin.xml. This is an ant file the provides the actual implementations many sencha commands. For example, 'sencha app build' performs various validations against command line arguments, then delegates control to the plugin structure by invoking the 'app-build' target plugin and passes the cli arguments in as properties prefixed with 'args.'.

The plugins are structured such that the app plugin imports the workspace plugin, which imports the base plugin from the framework. The framework plugin (in this case located in <Sencha Cmd install folder>/Sencha/Cmd/3.0.0.181/plugins/ext/current/plugin.xml) contains the default implementation of the various targets, which are inherited through the plugin import process.

Each primary plugin target (app-build, generate-app, app-refresh, etc.) provides a '-before-<target>' and a '-after-<target>' to have custom build logic or validation layers like jshint executed at key points during the build process. Since these targets are loaded and executed via the import process starting at the plugin file located in .sencha/app folder, they may be overridden at both the app and workspace level.

However, each primary target also provides a '<target>-impl' ant target that contains the core implementations, and since these are loaded via the same mechanism, they may be overridden as well in situations such as this.

For ext applications, the core app-build-impl target is the following:



<target name="app-build-impl">
<!-- initialize the build.dir parameter if it hasn't been already -->
<local name="build.dir"/>
<property name="build.dir" location="${workspace.build.dir}"/>


<!-- compile the page -->
<x-sencha-command>
compile
page
+yui
-in=index.html
-out=${build.dir}/index.html
</x-sencha-command>
</target>


As you can see, the fact that this target isn't providing any conditionalization logic for the build environment is where the problem you're running into stems from.

I've gone ahead and pushed this thread to the bug tracker to ensure we do provide support for these types of operations in the future.

However, as a workaround for now, you should be able to override the app-build-impl target by providing a target by that name in the .sencha/app/plugin.xml file with something like the following content:



<target name="app-build-impl">
<!-- initialize the build.dir parameter if it hasn't been already -->
<local name="build.dir"/>
<property name="build.dir" location="${workspace.build.dir}"/>


<if>
<equals arg1="${args.environment}" arg2="testing"/>
<then>
<x-sencha-command>
compile
page
-in=index.html
-out=${build.dir}/index.html
</x-sencha-command>
</then>
<else>
<x-sencha-command>
compile
page
+yui
-in=index.html
-out=${build.dir}/index.html
</x-sencha-command>
</else>
</if>
</target>


The recently added build.xml ant file, which for ext apps provides the sass compilation and theme slicing actions, delegates back to to the 'sencha app build' command to execute the js compilation process. That's why you're not seeing the actual compile command call in those files.

welshcathy
31 Oct 2012, 3:35 AM
For Cmd 3.0.0.230 it looks like the related code has been moved into

<app base folder>/.sencha/app/build-impl.xml

So same problem - just in a different place :)

dongryphon
31 Oct 2012, 9:56 AM
This is addressed in the next build with the following Ant properties (I am including their default values):



build.compression.production=-yui
build.compression.testing=


Along with that fix, we are aligning the Ext JS app build on "testing" and "production" to match Touch builds, so these will be generated in "build/production/app" or "build/testing/app" folders.

welshcathy
31 Oct 2012, 9:59 AM
Excellent news - sounds like you guys are keeping very busy :)

mikih
29 Nov 2012, 4:39 AM
is there a new build yet which fixed that?


Cheers

Florian

shanlin
15 Dec 2012, 2:26 PM
I am using a newer version of Sencha Cmd 3.0.0.250 for building an touch app using Sencha Touch 2.1. Both 'sencha app build -e testing' and 'sencha ant testing build' gives the following error:

[ERR] The following error occurred while executing this line:
/Users/shanlin/touch/st21/build/myapp/.sencha/app/build-impl.xml:120: javax.script.ScriptException: sun.org.mozilla.javascript.internal.WrappedException: Wrapped com.sencha.exceptions.BasicException: Cannot read directory /Users/shanlin/touch/st21/build/myapp/sdk/sencha-touch.js (<Unknown source>#197) in <Unknown source> at line number 197
It tries to look for a file called '.../sdk/sencha-touch.js'. But since touch 2.1 it should be called '.../touch/sencha-touch.js'.

If I use commands 'sencha app build' or 'sencha ant build' which builds an compressed production version, it works. But I need the uncompressed version to diagnose problems. How could I fix this issue?

Philip Murphy
3 Oct 2013, 11:06 AM
Is there anyway to pass a yuicompressor option to the Sencha build tool e.g. line-break=1?

Philip Murphy
3 Oct 2013, 1:28 PM
Is there anyway to pass a yuicompressor option to the Sencha build tool e.g. line-break=1?

Ok, I'm going to answer my own question.

Modify C:\Users\Philip\bin\Sencha\Cmd\3.1.0.192\plugins\touch\current\app-build.js

Re-write this:



writeFileContent(
cleanDestinationFile,
compressor.compress(readFileContent(cleanDestinationFile)));


to be:



if(asset.type == 'js') {
writeFileContent(
cleanDestinationFile,
compressor.compress(readFileContent(cleanDestinationFile), 1, true, false, false, false));
// All options are same as Sencha defaults except for 2nd argument '1' which preserves linebreaks.
} else {
writeFileContent(
cleanDestinationFile,
compressor.compress(readFileContent(cleanDestinationFile)));
}


This will call the correct sencha.jar!com.sencha.tools.compressors.yui.YuiJavascriptCompressor method with the appropriate arguments:

public String compress(String srcData, int lineBreak, boolean munge, boolean verbose, boolean preserveSemis, boolean disableOptimizations)

For other options: http://yui.github.io/yuicompressor/

(http://yui.github.io/yuicompressor/)This is handy for debugging out in the wild. I report any errors back from my app to a Google spreadsheet (timestamp, line number, message, and app version). However, usually they are useless as the line number is always 1. At least now I'll have a better idea where the problem is.

"sencha app build" will now generate minified JS with preserved linebreaks.

Size difference is negligible (esp. for native app) - for example: 537KB compressed JS file normally is now 543KB (~<6KB diff)